《防火墙规则》word版.docx_第1页
《防火墙规则》word版.docx_第2页
《防火墙规则》word版.docx_第3页
《防火墙规则》word版.docx_第4页
《防火墙规则》word版.docx_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ROS软路由防火墙规则(转自网络) routeros防火墙功能非常灵活。routeros防火墙属于包过滤防火墙,你可以定义一系列的规则过滤掉发往routeros、从routeros发出、通过routeros转发的数据包。在routeros防火墙中定义了三个防火墙(过滤)链(即input、forward、output),你可以在这三个链当中定义你自己的规则。 input意思是指发往routeros自己的数据(也就是目的ip是routeros接口中的一个ip地址); output意思是指从routeros发出去的数据(也就是数据包源ip是routeros接口中的一个ip地址); forward意思是指通过routeros转发的(比如你内部计算机访问外部网络,数据需要通过你的routeros进行转发出去)。 禁止ping routeros,我们一般需要在input链中添加规则,因为数据包是发给routeros的,数据包的目标ip是routeros的一个接口ip地址。(当然如果你硬是要在output里建立一条规则过滤掉icmp信息也能做到ping不通,当你ping的数据包到达routeos时,routeos能接收这个数据包并做出回应,当routeros回应给你的包要发出去的时候会检查output的规则并过滤掉回应你的包。)在每条链中的每条规则都有目标ip,源ip,进入的接口(in interface),非常灵活的去建立规则。比如ROS禁止PING,禁止外网ping你routeros,只需要在in interface中选择你连外部网络的接口。禁止内部ping的话可以选择连你内部网络的接口。如果禁止所有的ping的话,那么接口选择all。当然禁止ping 协议要选择icmp ,action选择drop或reject。 另外要注意的就是,icmp协议并不是就指的是ping,而是 ping是使用icmp协议中的一种(我们ping 出去发送的数据包icmp协议的类型为8 代码为0,在routeros中写为icmp-options=8:0;而我们对ping做出回应icmp类型为0 代码为0),还有很多东西也属于icmp协议。打个比方,如果你禁止内部网络ping所有外部网络,可以在forward链中建立一条规则,协议为icmp,action为drop,其他默认,那么你内部网络ping不通外部任何地址,同时如果你用trancroute命令跟踪路由也跟踪不了。在做规则是要注意每一个细节。 还有就是,input,output,forward三条链在routeros中默认都是允许所有的数据。也就是除非你在规则中明确禁止,否则允许。可以通过ip firewall set input policy=drop等进行修改默认策略ros防火墙名词解释input - 进入路由,并且需要对其处理forward - 路由转发output - 经过路由处理,并且从接口出去的包action:1 accept: 接受add-dst-to-address-list - 把一个目标IP地址加入address-listadd-src-to-address-list - 把一个源IP地址加入address-list2 drop - 丢弃3 jump - 跳转,可以跳转到一个规则主题里面,如input forward,也可以跳转到某一条里面4 log - 日志记录5 passthrough - 忽略此条规则6 reject - 丢弃这个包,并且发送一个ICMP回应消息7 return - 把控制返回给jump的所在8 tarpit - 捕获和扣留 进来的TCP连接 (用SYN/ACK回应进来的TCP SYN 包)address-list (name) - 把从action=add-dst-to-address-list or action=add-src-to-address-list actions得到的IP地址放入address-list列表. 这个列表要用来对比address-list-timeout 看是什么时候用address-list parameter从address list中移走chain (forward | input | output | name) - 使用chain得到特定列表,不同的数据流经过不同的chain规则要仔细的选对正确的访问控制. 如果 input 不是非常的确定和一个新的规则需要添加注释,transfered through the particular connection0的意思是无限的,例如 connection-bytes=2000000-0 意思是2MB以上connection-limit (integer | netmask) - 地址的传输流量控制connection-mark (name) - 传输中的标记后的数据包connection-state (estabilished | invalid | new | related) - 连接的状态(连接中,不规则的连接,新的连接,相互联系的连接)connection-type 连接的类型 (ftp | gre | h323 | irc | mms | pptp | quake3 | tftp)content 包的内容dst-address (IP address | netmask | IP address | IP address) - 目标地址dst-address-list (name) - 目标地址表dst-address-type (unicast | local | broadcast | multicast) - 目标地址类型unicast -点对点local - 本地地址broadcast - 广播multicast - 多播dst-limit (integer | time | integer | dst-address | dst-port | src-address | time) - 目标限制Count - 每秒最大的包数量by Time optionTime - 时间Burst - 突发的Mode -等级优先Expire - 终止dst-port 目标端口hotspot 暂时不做学习icmp-options (integer | integer) - ICMP 选择in-interface (name) - 进入接口ipv4-options (any | loose-source-routing | no-record-route | no-router-alert | no-source-routing |no-timestamp | none | record-route | router-alert | strict-source-routing | timestamp)any - match packet with at least one of the ipv4 optionsloose-source-routing - match packets with loose source routing option. This option is used toroute the internet datagram based on information supplied by the sourceno-record-route - match packets with no record route option. This option is used to route theinternet datagram based on information supplied by the sourceno-router-alert - match packets with no router alter optionno-source-routing - match packets with no source routing optionno-timestamp - match packets with no timestamp optionrecord-route - match packets with record route optionrouter-alert - match packets with router alter optionstrict-source-routing - match packets with strict source routing optiontimestamp - match packets with timestampjump-target (forward | input | output | name) -跳转limit (integer | time | integer) - 限制Count - 每秒最大的包数量Time - 突发的总时间log-prefix (text) - 如果还有定义的字符,加入日志out-interface (name) - 流出的接口p2p (all-p2p | bit-torrent | blubster | direct-connect | edonkey | fasttrack | gnutella | soulseek | warez| winmx) - P2P协议packet-mark (text) - 给包标记packet-size (integer: 0.65535 | integer: 0.65535) - 包大小range in bytesMin - 最小Max - 最大phys-in-interface (name) - 物理上的进入接口phys-out-interface (name) -物理上的出去接口protocol (ddp | egp | encap | ggp | gre | hmp | icmp | idrp-cmtp | igmp | ipencap | ipip | ipsec-ah |ipsec-esp | iso-tp4 | ospf | pup | rdp | rspf | st | tcp | udp | vmtp | xns-idp | xtp | integer) -协议psd (integer | time | integer | integer) - 防止对ROS的端口扫描random (integer: 1.99) - matches packets randomly with given propabilityreject-with (icmp-admin-prohibited | icmp-echo-reply | icmp-host-prohibited |icmp-host-unreachable | icmp-net-prohibited | icmp-network-unreachable | icmp-port-unreachable |icmp-protocol-unreachable | tcp-reset | integer) - 改变reject的回答方式routing-mark (name) - 路由标记src-address (IP address | netmask | IP address | IP address) -源地址src-address-list (name) -源地址列表src-address-type (unicast | local | broadcast | multicast) - 源地址类型src-mac-address (MAC address) - 源MAC地址src-port (integer: 0.65535 | integer: 0.65535) - 源端口tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg) -TCP 标志类型ack - acknowledging datacwr - congestion window reducedece - ECN-echo flag (explicit congestion notification)fin - close connectionpsh - push functionrst - drop connectionsyn - new connectionurg - urgent datatcp-mss (integer: 0.65535) - TCP MSStime (time | time | sat | fri | thu | wed | tue | mon | sun) - allows to create filter based on the packetsarrival time and date or, for locally generated packets, departure time and datetos (max-reliability | max-throughput | min-cost | min-delay | normal) - specifies a match for thevalue of Type of Service (ToS) field of an IP headermax-reliability - maximize reliability (ToS=4)max-throughput - maximize throughput (ToS=8)min-cost - minimize monetary cost (ToS=2)min-delay - minimize delay (ToS=16)normal - normal service (ToS=0):foreach i in=/system logging facility find local=memory do=/system logging facility set $i local=noneRO防synip-firewall-connectionsTracking:TCP Syn Sent Timeout:50 TCP syn received timeout:30限线程脚本::for aaa from 2 to 254 do=/ip firewall filter add chain=forward src-address=(192.168.0. . $aaa) protocol=tcp connection-limit=50,32 action=dropRO端口的屏蔽ip-firewall-Filer Rules里面选择forward的意思代表包的转发firewall rule-General Dst.Address:要屏蔽的端口 Protocol:tcpAction:drop(丢弃)ros限速手动限速winbox-queues-simple queues点“+”,NAME里随便填,下面是IP地址的确定Target Address 不管,Dst. Address里填 你要限制的内网机器的IP,比如我这里有个 1号机器 IP为 01,那dst.address 里就填 01 然后是/32(这里的32不是指掩码了,个人理解为指定的意思)!interface里 记着要选你连接外网那个卡,我这里分了“local和public”,所以选public 其他的不管,我们来看最重要的东西拉,Max limit ,这个东西是你限制的上限,注意的是 这里的数值是比特位,比如我要限制下载的速度为 500K 那么就填入多少呢? 500 X 1000 X 8=400 0000=4M。 另外,很多朋友都有个疑问,到底一般的用户会有多大流量呢?一般的网络游戏,如 梦幻西游 传奇 封神榜 等等,其下行在 20Kbps以内! 最耗网络资源的就是下载-我们就是为了限制它拉,其次是VOD点播,一般DVD格式的大约要 2M多吧,所以你看情况限制拉 别搞的太绝!限速脚本::for aaa from 2 to 254 do=/queue simple add name=(queue . $aaa) dst-address=(192.168.0. . $aaa) limit-at=0/0 max-limit=2000000/2000000 说明:aaa是变量2 to 254是2254192.168.0. . $aaa是IP上两句加起来是54connection-limit=50是线程数这里为50max-limit=2000000/2000000是上行下行使用:WinBox-System-Scripts-Name(脚本名程)Source(脚本)OK-选择要运行的脚本-Run ScriptROS限速的极致应用一般我们用ros限速只是使用了max-limit,其实ros限速可以更好的运用。比如我们希望客户打开网页时速度可以快一些,下载时速度可以慢一些。ros2.9就可以实现。max-limit-我们最常用的地方,最大速度burst-limit-突破速度的最大值burst-thershold-突破速度的阀值burst-time-突破速度的时间值解释一下图片的限制意义当客户机在30秒(burst-time)内的平均值小于突破速度阀值(burst-thershold)180K时,客户机的最大下载速率可以超过最大限速值(max-limit)200K,达到突破最大值(burst-limit)400K,如果30秒内平均值大于180K,那客户机的最大速度只能达到200K。这样也就是当我们开网页时可以得到一个更大的速度400K,长时间下载时速度只能得到200K,使我们的带宽可以更有效的利用动态限速ROS动态限速(检测外网总速度进行限速开关)废话不说先看脚本原理:以下操作全部在WINBOX界面里完成介绍:可以实现在总速度不超过9M的情况下自动关闭所有生成的限速规则在总速度超过18M的时候自动启动所有生成的限速规则。说明:在输入脚本内容时不要把两边的()带上,那个是为了区分非脚本字符。 总速度=你的外网网卡当前速度。打开 /system/scripts脚本:for aaa from 1 to 254 do=/queue simple add name=(ip_ . $aaa) dst-address=(192.168.0. . $aaa) interface=wan max-limit=256000/800000 burst-limit=1000000/3000000 burst-threshold=128000/512000 burst-time=30s/1m 上面是生成限速树,对网段内所有IP的限速列表!下面进入正题:脚本名:node_on脚本内容:(:for aaa from 1 to 254 do=/queue sim en find name=(ip_ . $aaa))脚本名:node_off脚本内容:(:for aaa from 1 to 254 do=/queue sim dis find name=(ip_ . $aaa)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论