ROS菜鸟系列4--简单路由策略实现
ROS多线路自动策略路由切

ROS多线路自动策略路由切2.9.X 电信+网通+ 1条ADSL 多线路自动策略路由切换+备份第一ip设好/ ip addressadd address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 \interface=lan comment="" disabled=noadd address=电信地址/掩码network=自动设置broadcast=自动设置interface=TEL comment="" disabled=noadd address=网通地址/掩码network=自动设置broadcast=自动设置interface=CNC comment="" disabled=no这里如果你有PPPOE的ADSL 也可以+上ADSL记住要改MSS/ ip firewall mangleadd chain=forward out-interface=pppoe-out1 protocol=tcp tcp-flags=syn \action=change-mss new-mss=1400 comment="" disabled=no/ ip firewall natadd chain=srcnat src-address=192.168.1.0/24 action=masquerade comment="" \ disabled=no--------------------------------------------------------------------------------------------------第2步添加网通的路由网关电信的服务器在网络中占了绝大多数所以不需要考虑电信的服务器/ ip routeadd dst-address=59.80.0.0/14 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.0.0.0/13 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.8.0.0/15 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.10.0.0/16 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.12.0.0/16 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.13.0.0/18 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.13.128.0/17 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.16.0.0/12 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=60.55.0.0/16 gateway=网通网关check-gateway=ping \add dst-address=60.208.0.0/13 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=60.216.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=60.220.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.4.79.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.4.64.0/20 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=61.48.0.0/13 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.128.210.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.133.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.98.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.108.0/22 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.120.0/28 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.112.0/20 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.96.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.134.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.135.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.136.64.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.137.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.138.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.139.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.148.0.0/15 gateway=网通网关check-gateway=ping \add dst-address=61.156.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.158.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.159.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.161.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.161.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.167.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=61.168.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.176.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.179.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.180.13.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.180.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.181.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.182.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.189.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.233.7.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.233.59.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=61.237.148.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.95.98.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.96.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.96.66.0/24 gateway=网通网关check-gateway=ping \add dst-address=202.96.64.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.97.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.98.0.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.99.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.102.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.102.224.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.106.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=202.107.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.108.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.110.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.110.192.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=202.111.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=203.88.200.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=203.88.203.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.95.192.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.97.245.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.148.8.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.151.130.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.158.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=211.163.0.0/16 gateway=网通网关check-gateway=ping \add dst-address=218.7.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.8.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.12.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.24.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.28.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.56.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.60.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.62.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=218.67.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.68.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.104.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.106.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.107.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.108.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=218.109.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=219.154.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=219.156.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=219.158.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=219.159.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=220.248.0.0/15 gateway=网通网关check-gateway=ping \add dst-address=220.250.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.0.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.4.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.6.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.7.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.7.64.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.7.128.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.8.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.10.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=221.11.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.11.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.11.192.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.12.0.0/17 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.12.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.13.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.13.64.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.14.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.136.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.192.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.196.0.0/15 gateway=网通网关check-gateway=ping \add dst-address=221.198.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.199.0.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.199.32.0/20 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.199.128.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.199.192.0/20 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.200.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.204.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.207.0.0/18 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.208.0.0/14 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.212.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=221.214.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=221.216.0.0/13 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.128.0.0/12 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.160.0.0/15 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.162.0.0/16 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.163.0.0/19 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.173.101.0/24 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.173.102.0/23 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.173.104.0/22 gateway=网通网关check-gateway=ping \ distance=0 scope=255 target-scope=10 comment="CNC" disabled=no add dst-address=222.173.108.0/23 gateway=网通网关check-gateway=ping \add dst-address=222.208.65.0/24 gateway=网通网关check-gateway=ping \distance=0 scope=255 target-scope=10 comment="CNC" disabled=noadd dst-address=0.0.0.0/0 gateway=222.218.157.97 check-gateway=ping distance=0 \scope=255 target-scope=10 comment="TEL" disabled=no(最后这条的意义就是保证在上面找不到网通的网关后IP包自动走电信的线路如果想拷贝这个规则就用替换功能换上具体的IP就可以了)-------------------------------------------------------------------------------------------------------第3步设置好监控的开关/ tool netwatchadd host=电信网关timeout=1s interval=1m up-script=dxup \down-script=dxdown comment="TEL" disabled=noadd host=网通网关timeout=1s interval=1m up-script=CNCup \down-script=CNCdown comment="CNC" disabled=no--------------------------------------------------------------------------------------------------------第四写好脚本自动切换/ system scriptadd name="dxup" source="/ip route set \[/ip route find comment=TEL\] gateway \ 电信网关\n" policy=ftp,reboot,read,write,policy,test,winbox,passwordadd name="CNCup" source="/ip route set \[/ip route find comment=CNC\] gateway \网通网关\n" policy=ftp,reboot,read,write,policy,test,winbox,passwordadd name="dxdown" source=":if \(\[/tool netwatch get \[/tool netwatch find \ comment=CNC\] status\]=\"down\"\) do {/ip route set \[/ip route find \comment=TEL\] gateway \[/ip address get \[/ip address find \interface=pppoe-out1\] network\]} else {/ip route set \[/ip route find \comment=TEL\] gateway 网通网关}" \policy=ftp,reboot,read,write,policy,test,winbox,passwordadd name="CNCdown" source=":if \(\[/tool netwatch get \[/tool netwatch find \ comment=TEL\] status\]=\"down\"\) do {/ip route set \[/ip route find \comment=CNC\] gateway \[/ip address get \[/ip address find \interface=pppoe-out1\] network\]} else {/ip route set \[/ip route find \comment=CNC\] gateway 电信网关}" \policy=ftp,reboot,read,write,policy,test,winbox,password。
ROS软路由详细教程

ROS软路由详细教程ROS(RouterOS)是一种基于Linux内核开发的软路由操作系统,具有丰富的功能和灵活的配置选项。
在本教程中,我将为您提供一个详细的ROS软路由配置教程。
2.连接到ROS路由器3.配置基本设置在登录网页中,输入用户名和密码(默认情况下为“admin”)。
然后,选择“IP”选项卡,并选择“Addresses”子选项卡。
在这里,您可以配置路由器的IP地址、网关和子网掩码。
4.配置网络接口在“Interfaces”子选项卡中,您可以配置网络接口的设置。
首先,选择您要配置的接口,然后为其分配IP地址、设置网关和DHCP选项等。
5.配置DHCP服务器在“IP”选项卡中,选择“DHCP”子选项卡。
在这里,您可以启用和配置DHCP服务器,为连接到路由器的设备分配IP地址和其他网络参数。
6.配置防火墙在“IP”选项卡中,选择“Firewall”子选项卡。
您可以使用防火墙规则来管理网络流量并保护您的网络安全。
可以添加规则以阻止或允许特定IP地址、端口或协议的流量。
7.配置NAT在“IP”选项卡中,选择“NAT”子选项卡。
在这里,您可以配置网络地址转换(NAT)规则,以允许内部网络中的设备访问Internet,并且可以将特定的端口映射到特定的内部IP地址。
8.配置无线网络在“无线”选项卡中,您可以配置无线接口和无线网络的设置。
您可以为无线接口分配一个唯一的名称,选择您喜欢的频率和信道,并配置无线安全性选项(如WPA2-PSK)。
9.配置VPN在“IP”选项卡中,选择“VPN”子选项卡。
在这里,您可以配置各种VPN(Virtual Private Network)协议,如PPTP、L2TP和OpenVPN,以创建安全的远程访问链接。
10.配置路由在“IP”选项卡中,选择“Routes”子选项卡。
在这里,您可以添加和管理路由,以确定数据包的最佳路径。
您可以添加静态路由,也可以使用动态路由协议如OSPF(Open Shortest Path First)。
ROS多线路由策略原理详解

以下为命令行模式下的配置:
/ ip firewall nat
add chain=srcnat connection-mark=1 action=src-nat to-addresses=116.21.32.241
to-ports=0-65535
add chain=srcnat connection-mark=2 action=src-nat to-addresses=121.32.177.37
add chain=prerouting in-interface=Local connection-mark=1 action=mark-routing
new-routing-mark=1 passthrough=no
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=1,1,1
/ ip route
add dst-address=0.0.0.0/0 gateway=121.32.177.37 scope=255 target-scope=10
第六步填加防掉线脚步:脚本是ROS官方提供的,虽然短短几行代码,但具体是怎样的工作原理我也实在没弄通,不过好在脚本是通用的,将脚本设置成自动运行就可以了,以下是配置图:
至此,所有配置工作完成,由于ROS基础配置过程较多,所以在这里只针对ADSL配置和负载平衡进行了详细的介绍,由于实际当中配置多条ADSL多为重复过程,所以在这里只以两条线为例,如果配置多条ADSL来实现叠加网速,还要注意一些细节,可以说按照以上流程,再详细掌握了以下细节后就可以应用自如了。
以下为命令行模式下的配置: / ip route
ROS快速配置上网设置教程

ROS快速配置上网设置教程ROS(RouterOS)是由MikroTik开发的一款操作系统,用于配置和管理路由器设备。
在配置ROS上网设置时,有几个关键步骤需要遵循。
下面是一个ROS快速配置上网设置的教程,详细说明了每个步骤。
1.连接路由器首先,将计算机通过以太网线连接到ROS路由器的网口上。
确保计算机和路由器之间的连接是稳定的。
2. 访问路由器Web界面打开计算机上的任意浏览器,输入路由器的默认IP地址(通常为192.168.88.1)。
在地址栏中输入该地址,并按下Enter键。
这将打开ROS路由器的Web界面。
3.登录路由器在Web界面上,输入默认用户名和密码来登录路由器。
默认情况下,用户名是“admin”,密码为空。
然后点击“登录”按钮。
4.配置LAN接口在Web界面的左侧导航栏中,找到并点击“接口”选项。
然后在下拉菜单中选择“以太网”选项。
接着,找到“接口列表”中的“ether1”,这是连接到你的计算机的接口。
在“ether1”下方有一个按钮标记为“IP设置”,点击它。
在弹出的界面上,选择“静态”并填写你的计算机IP地址、网关和DNS服务器的IP地址。
根据你的网络提供商和网络设置,这些信息可能会有所不同。
然后点击“应用”按钮。
5.配置WAN接口在Web界面的左侧导航栏中,找到并点击“接口”选项。
在下拉菜单中选择“以太网”选项。
找到“接口列表”中的“ether2”,这是连接到你的互联网提供商(ISP)的接口。
点击“ether2”下方的“IP设置”按钮。
在弹出的界面上,选择“动态客户端”选项。
这将允许路由器通过DHCP获取IP地址。
然后点击“应用”按钮。
6.配置NAT规则在Web界面的左侧导航栏中,找到并点击“防火墙”选项。
然后点击“NAT”选项。
在NAT列表中,点击“+”按钮以创建新的NAT规则。
在弹出的界面上,配置以下设置:- Chain: srcnat- Action: masquerade- Out. Interface: ether2(WAN接口)点击“应用”按钮。
RouterOS菜鸟篇教你一步一步成为ROS能手(图)

一:安装1、光盘版的(转自雨纷飞大哥作品)将iso文件刻录成可引导光盘。
机器的硬盘设置为IDE0,即第一个IDE通道的主盘。
bios设置光盘引导系统,放入光盘启动机器得到如下画面:选择 2:Install RouteOS 2.8.18后稍等,得到如下画面:用方向键和空格选择你需要的模组功能后,摁“i“键确定安装。
会再次询问你继续?yes or no?,摁“Y“.然后又问:do you want to keep lod configuraton?你需要保留旧的结构么?摁“N“.然后开始自动的格式化磁盘、安装核心、安装模组。
最后提示:Press ENTER to Reboot,按回车重新启动机器。
重新启动后出现图1的那个引导画面(如果没有出现而直接进了登陆界面说明用硬盘引导了):选择3: Crack RouteOS Floppy Disk,开始破解。
破解过程都是中文的。
如果你的硬盘在IDE0:0的话破解是不会有问题的。
否则可能出现系统文件被破坏、启动时0123456...循环出现等问题。
问你是否重启呢。
把光盘拿出来后按下Y确定重启动重新启动后开始登陆。
初始用户名admin,初始密码为空。
咦?怎么还有提示注册的信息和Soft ID?原来是还需要一个命令激活注册补丁才可以哦:输入命令:/system license import file-name=key或者缩写为/sy lic i f key然后提示你是否重新启动。
按Y重新启动重新启动并用admin:““登陆后发现,提示注册的信息已经完全消失了,现在是正式版了现在服务器启动起来了,但是还没有任何配置,若想用winbox对其进行控制,则必须激活和配置网卡的ip 掩码等。
这里我装了三块网卡,一块接电信,一块接网通,一块路由后接内网交换机。
首先看看三块网卡是否都被识别出来了,命令是:print可以缩写为/intpri以后用缩写不再另外注名。
结果应该如下图:然后我们来激活他们,命令是:ENABLE 0ENABLE 1ENABLE 20是第一块网卡。
ros 路由器配置

1)安装==>注意硬盘内容会被删除!还有,机器内存不能小于24 M,并安装上二块网卡!安装过程中提示注册,注意注册码的大小写2)启动后,使用admin 密码为空,进入3)设第一块网卡的ip:在提示符下输入setup命令,如果你的网卡是PCI的,会提示你设置ether2(就是第二块网卡),输入ipaddress(ip地址):192.168.0.254、netmask(子网掩码24):255.255.255.0、gateway:(用外网的网关)、network:192.168.0.0、broadcast:192.168.0.255。
默认直接回车就行了。
4)从windows端机器,ip设成192.168.0.x ,在ie 地址栏输上192.168.0.1 出现routeos 的欢迎画面。
点击,提示下载winbox ,保存如果不能连接,就把网线连接到另外一块网卡5)运行winbox 输上192.168.0.1 用户名admin 密码不输,选连接。
会出现路由的管理界面。
如果你的机器上使用网络防火墙,这里需要关闭或者修改规则6启用网卡:点击interface ,点击第二块卡,选择对号,启用(颜色不是虚的了)7)设置地址:ip --》address ,选择+号,输入第二块卡的ip地址(isp 给你的)为了便于管理,最好从这里把两块卡的别名,改成public 和local ,另外,这里支持一个网卡多个ip,如果因为管理需要,你可以这样设8)增加静态路由:ip--》routes 选择+号,选中gateway,输上网关地址在这里,destination 可以使用默认0.0.0.0 ,表示路由所有的地址,也可以根据你的需要,只对你指定的ip范围路由。
静态路由可以有多条,比如可以分别指定多个ip段,达到管理的目的9)设置NAT共享上网:ip --》firewall -source nat ,选择+号,选择action,action里面选择masquerade ,其余选择默认即可至此,共享上网就完成了剩下的,需要增加设置防火墙规则,否则,安全没有保障ip -》firewall -》filter fules ,选择+号,in interface 选择内网网卡(local),其他默认这条路由允许来自内网的连接,如果有限制,可以修改src address 的ip段,或者content 内容过滤ip -》firewall -》filter chains 选中input ,选择drop这条规则禁止所有的外部连接以上两条规则,屏蔽来自外网的所有连接,还要注意,顺序不要弄错,不然,你也连接不上路由了,即:允许来自内网的连接的规则在前,拒绝所有的连接的规则在后。
ROS菜鸟系列4--简单路由策略实现

ROS菜鸟系列4--简单路由策略实现本章节是以“ROS菜鸟系列1”为基础,同时也可以应用到系列2,系列3上面,实现功能的完善,路由策略:可以实现数据传输路径的优化,数据分流,线路备份,变相的实现带宽添加等。
本章节涉及的主要是较为简单的三种路由策略:1)基于端口分流的路由策略,2)基于目标地址3)基于源地址只有在具备多条外网线路的情况下才涉及到分流,备份及优化的部分,因此假定引进第二条ISP线路:外网IP地址:10.10.10.2/28,网关10.10.10.1实现第一步:添加IP地址[admin@MikroTik] > ip address[admin@MikroTik] /ip address> add address=10.10.10.2/28 interface=wan[admin@MikroTik] /ip address> printFlags: X - disabled, I - invalid, D - dynamic# ADDRESS NETWORK BROADCAST INTER FACE0 192.168.1.1/24 192.168.1.0 192.168.1.255 lan1 172.16.0.2/28 172.16.0.0 172.16.0.15 wan2 10.10.10.2/28 10.10.10.0 10.10.10.15 wan实现第二步:标记数据包1)基于端口标记假定:对所有去访问目标80端口数据进行标记,同时客户可以根据自己的需要对其他端口进行标记,以达到符合的自己要求[admin@MikroTik] > ip[admin@MikroTik] /ip>firewall[admin@MikroTik] /ip firewall>mangle#添加连接标记规则[admin@MikroTik] /ip firewall mangle>add chain=prerouting protocol=tcp dst-port=80 action=mark-connection new-connection-mark=web passthrough=yes #添加路由标记规则[admin@MikroTik] /ip firewall mangle>add chain=prerouting connection-mark=web action=mark-routing new-routing-mark=80 passthrough=no[admin@MikroTik] /ip firewall mangle> printFlags: X - disabled, I - invalid, D - dynamic0 chain=prerouting action=mark-connection new-connection-mark=webpassthrough=yes protocol=tcp dst-port=801 chain=prerouting action=mark-routing new-routing-mark=80 passthrough=no connection-mark=web以上完成对访问端口的标记,# 假定所有的80端口数据将从第二条ISP线路走,而其他的数据从第一条ISP线路走[admin@MikroTik] /ip firewall mangle>/[admin@MikroTik]ip route[admin@MikroTik] /ip route>add gateway=10.10.10.2 routing-mark=80 check-gateway=pingadmin@MikroTik] /ip route> printC - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,B - blackhole, U - unreachable, P - prohibit# DST-ADDRESS PREF-SRC GATEWAY-STATE GATEWAY DISTANCE INTERFACE0 A S 0.0.0.0/0 reachable 10.10.10.2 1 wa n1 A S 0.0.0.0/0 reachable 172.16.0.1 1 wa n2ADC 10.10.10.0/28 10.10.10.2 0 w an3ADC 172.16.0.0/28 172.16.0.2 0 w an4ADC 192.168.1.0/24 192.168.1.1 0 lan2)基于目标地址分流假定访问目标地址为58.17.1.234的数据从第二条ISP线路走第一种方法:此时可以直接在IP-ROUTE里面添加规则如:[admin@MikroTik] > ip[admin@MikroTik] /ip> rout[admin@MikroTik] /ip route>add dst-address=58.17.1.234 gateway=10.10.10.1 check-gateway=pingadmin@MikroTik] /ip route> printC - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,B - blackhole, U - unreachable, P - prohibit# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE IN..0 A S 0.0.0.0/0 r 172.16.0.1 1 wan1ADC 10.10.10.0/28 10.10.10.2 0 wan2 A S 58.17.1.234/32 r 10.10.10.1 1 wan3ADC 172.16.0.0/28 172.16.0.2 0 w an4ADC 192.168.1.0/24 192.168.1.1 0第二种:可以先在IP--route--rule里面添加:[admin@MikroTik] >ip rou[admin@MikroTik] /ip route>rule[admin@MikroTik] /ip route rule>add dst-address=58.17.1.234 Table=static action=lookup[admin@MikroTik] /ip route rule>printFlags: X - disabled, I - inactive0 dst-address=58.17.1.234/32 action=lookup table=static然后在添加路由:[admin@MikroTik] /ip route rule>..[admin@MikroTik] /ip route>add gateway=10.10.10.1 routing-mark=static check-gateway=ping[admin@MikroTik] /ip route>printFlags: X - disabled, A - active, D - dynamic,C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,B - blackhole, U - unreachable, P - prohibit# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE IN..0 A S 0.0.0.0/0 r 172.16.0.1 1 wan1 A S 0.0.0.0/0 r 10.10.10.1 1 wan2ADC 10.10.10.0/28 10.10.10.2 0 wan 3ADC 172.16.0.0/28 172.16.0.2 0 wan 4ADC 192.168.1.0/24 192.168.1.1 0 lan 第三种:可以先在ip---firewall--address-list里面添加地址表[admin@MikroTik] >ip firewall address-list[admin@MikroTik] /ip firewall address-list>add list=static address=58.17.1.234[admin@MikroTik] /ip firewall address-list>printFlags: X - disabled, D - dynamic# LIST ADDRESS0 static 58.17.1.234对目标地址标记:[admin@MikroTik] /ip firewall address-list>..[admin@MikroTik] /ip firewall>mangle[admin@MikroTik] /ip firewall mangle>add chain=prerouting dst-address-list=static action=mark-routing new-routing-mark=static passthrough=no[admin@MikroTik] /ip firewall mangle>printFlags: X - disabled, I - invalid, D - dynamic0 chain=prerouting action=mark-routing new-routing-mark=staticpassthrough=no dst-address-list=static添加路由标记[admin@MikroTik] /ip firewall mangle>/[admin@MikroTik] >ip route[admin@MikroTik] /ip route>add gateway=10.10.10.1 routing-mark=static check-gateway=ping[admin@MikroTik] /ip route>printFlags: X - disabled, A - active, D - dynamic,C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,B - blackhole, U - unreachable, P - prohibit# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE IN..0 A S 0.0.0.0/0 r 172.16.0.1 1 wan1 A S 0.0.0.0/0 r 10.10.10.1 1 wan2ADC 10.10.10.0/28 10.10.10.2 0 wan 3ADC 172.16.0.0/28 172.16.0.2 0 wan 4ADC 192.168.1.0/24 192.168.1.1 0 lan使用第一种方法,可以快速简单的添加定义每一条规则,但会使用整个ip-route里面显得很杂乱,不便于管理,第二种方法和第三种方法相对比较复杂些,但会让整个ip-route里面简单明了,便于管理3)基于源地址策略第一种:假定内网192.168.1.0/25走第一条ISP出口,内网192.168.1.128/25走第二条ISP出口#做标记[admin@MikroTik] >ip firewall mangle[admin@MikroTik] /ip firewall mangle>add chain=prerouting src-address=192.168.1.0/25 action=mark-routing new-routing-mark=GA[admin@MikroTik] /ip firewall mangle>add chain=prerouting src-address=192.168.1.128/25 action=mark-routing new-routing-mark=GB[admin@MikroTik] /ip firewall mangle>printFlags: X - disabled, I - invalid, D - dynamic0 chain=prerouting action=mark-routing new-routing-mark=GA passthrough=yessrc-address=192.168.1.0/251 chain=prerouting action=mark-routing new-routing-mark=GB passthrough=yessrc-address=192.168.1.128/25#做路由策略[admin@MikroTik] /ip firewall mangle>/[admin@MikroTik] >ip[admin@MikroTik] /ip>route[admin@MikroTik] /ip route>add gateway=172.16.0.1 routing-mark=GA check-gateway=ping[admin@MikroTik] /ip route>add gateway=10.10.10.1 routing-mark=GB check-gateway=ping[admin@MikroTik] /ip route>printFlags: X - disabled, A - active, D - dynamic,C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,B - blackhole, U - unreachable, P - prohibit# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE IN..0 A S 0.0.0.0/0 R 10.10.10.1 1 wan1 A S 0.0.0.0/0 r 172.16.0.1 1 wan2 A S 0.0.0.0/0 R 172.16.0.1 1 wan3ADC 10.10.10.0/28 10.10.10.2 0 wan4ADC 172.16.0.0/28 172.16.0.2 0 wan 5ADC 192.168.1.0/24 192.168.1.1 0 lan 这种方法,其实可以只用做192.168.1.128/25的内网IP段的标记即可,因为存在一条默认路由:1 A S 0.0.0.0/0 r 172.16.0.1 1 wan ,当192.168.1.0/25的Ip段,当找不到相应的标记路由时,路由器会最终选择默认路由进行转发出去。
ROS软路由超详细的PCC设置步骤,实现一线多拨,五条宽带叠加

PCC实验一、基本配置,使网络能够正常连通1.pppoe拨号:拨通五个帐号PPPOE client的连接状态,已连接设备NAT:5个接口出去都做NAT创建一个bridge,把其他局域网口添加到bridge中。
添加其他局域网口到bridge中DHCP 服务器设置(局域网自动获取IP地址)局域网的网段为192.168.10.0/24把192.168.10.254作为内网的网关设置网关的地址,接口添加到bridge1上一般我们用DHCP setup来自动设置DHCP server这种设置比较简单快速路由配置:所有的基本配置都设置好了,局域网可以正常上网了,但是为了实现更好的网络环境,我们需要做更好的策略。
这就需要使用PCC了,下面就看看PCC怎么做的吧。
二、PCC的配置Mangle标记标记内网地址为192.168.10.0的五条线路的连接标记标记第一条连接:同理:配置剩余的4调链路:5/1,c2; 5/2.c3; 5/3,c4; 5/4,c5.从连接中提取路由标记:从连接里提取路由标记标记第一条连接c1,命令为R1同理:提出其他4调路由命名为R2,R3,R4,R5.标记连接,的命名配置方式为:[admin@MikroTik] /ip firewall mangle> printFlags: X - disabled, I - invalid, D - dynamic0 chain=prerouting action=mark-connection new-connection-mark=c1passthrough=yes src-address=192.168.10.0/24 dst-address-type=!localper-connection-classifier=both-addresses:5/01 chain=prerouting action=mark-connection new-connection-mark=c2passthrough=yes src-address=192.168.10.0/24 dst-address-type=!localper-connection-classifier=both-addresses:5/12 chain=prerouting action=mark-connection new-connection-mark=c3passthrough=yes src-address=192.168.10.0/24 dst-address-type=!localper-connection-classifier=both-addresses:5/23 chain=prerouting action=mark-connection new-connection-mark=c4passthrough=yes src-address=192.168.10.0/24 dst-address-type=!localper-connection-classifier=both-addresses:5/34 chain=prerouting action=mark-connection new-connection-mark=c5passthrough=yes src-address=192.168.10.0/24 dst-address-type=!localper-connection-classifier=both-addresses:5/4提取路由的命令5 chain=prerouting action=mark-routing new-routing-mark=R1 passthrough=yes src-address=192.168.10.0/24 connection-mark=c16 chain=prerouting action=mark-routing new-routing-mark=R2 passthrough=yes src-address=192.168.10.0/24 connection-mark=c27 chain=prerouting action=mark-routing new-routing-mark=R3 passthrough=yes src-address=192.168.10.0/24 connection-mark=c38 chain=prerouting action=mark-routing new-routing-mark=R4 passthrough=yes src-address=192.168.10.0/24 connection-mark=c49 chain=prerouting action=mark-routing new-routing-mark=R5 passthrough=yes src-address=192.168.10.0/24 connection-mark=c5回程路由设置需要将从那个口进入就从相应的口回去,即保证每个外网口的数据能得到正确的路由同理标记c2,c3,c4,c5的回程路由提取回程路由同理提取c2,c3,c4,c5命令方式:10 chain=input action=mark-connection new-connection-mark=c1 passthrough=yesin-interface=pppoe-out111 chain=input action=mark-connection new-connection-mark=c2 passthrough=yesin-interface=pppoe-out212 chain=input action=mark-connection new-connection-mark=c3 passthrough=yesin-interface=pppoe-out313 chain=input action=mark-connection new-connection-mark=c4 passthrough=yesin-interface=pppoe-out414 chain=input action=mark-connection new-connection-mark=c5 passthrough=yesin-interface=pppoe-out515 chain=output action=mark-routing new-routing-mark=R1 passthrough=yesconnection-mark=c116 chain=output action=mark-routing new-routing-mark=R2 passthrough=yesconnection-mark=c217 chain=output action=mark-routing new-routing-mark=R3 passthrough=yesconnection-mark=c318 chain=output action=mark-routing new-routing-mark=R4 passthrough=yesconnection-mark=c419 chain=output action=mark-routing new-routing-mark=R5 passthrough=yesconnection-mark=c5路由设置添加五条默认路由,指定标记的路由内网PC上开启迅雷下载资料,可以看到所有的拨号出口都有流量。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ROS的filter规则等同于华为或者思科的ACL规则,安装好的ROS系统,在初始情况下,默认的防火规则有三种:input,output,forward三种链。
简单说一下每一种的作用:input是指作用于所有去访问路由器本身的数据流,output是指作用于从路由器本身发出或者回应给其他访问的数据流,forward是指作用于通过路由器转发的数据流,主要是用于过滤内网用户与外网的数据交互。
;}$X&K L F:M9g_(y%t0Q%{(j!t'e举些简单的应用例子:"X6}+{/O(Y'z;a1)假定不允许从IP地址是192.168.1.100的机器登录路由器:/^*@%C.\5P;e[admin@MikroTik] > ip:V,c0\8j*U5L&`[admin@MikroTik] /ip> firewall filter,J6S2r D!;I'~&1$P[admin@MikroTik] /ip firewall filter> add chain=input src-address=192.168.1.100 action=drop4k'X)x#a h-}, [admin@MikroTik] /ip firewall filter> printFlags: X - disabled, I - invalid, D - dynamic0 chain=input action=drop src-address=192.168.1.100d.{:e!X#@1W"j(m-O2)假定不允许路由器回应外网用户的PING探测:"f3h5X.x![+U:u8Z v S4N[admin@MikroTik] /ip firewall filter> add chain=output protocol=icmp out-interface=wan icmp-options=0 action=drop[admin@MikroTik] /ip firewall filter> printFlags: X - disabled, I - invalid, D - dynamic8_!u*k&}0l0 chain=input action=drop src-address=192.168.1.1001 chain=output action=drop protocol=icmp out-interface=wanicmp-options=0:0-255解释相关的部分参数:protocol参数是指选择的协议,如TCP,UDP,ICMP等。
icmp-options意思是指ICMP的选项,代码0表示:echo replay。
3)假定禁止内网的机器使用192.168.1.200-192.168.1.220的IP地址访问外部网络&w0J3j v.C x,[admin@MikroTik] /ip firewall filter> add chain=forward src-address=192.168.1.200-192.168.1.220 action=drop6o)n%w.a-V*b[admin@MikroTik] /ip firewall filter> printFlags: X - disabled, I - invalid, D - dynamic0 chain=input action=drop src-address=192.168.1.1004}1L)T6O B^3t'r!7k1 chain=output action=drop protocol=icmp out-interface=wan:{1H!@"%w9ficmp-options=0:0-2552 chain=forward action=drop src-address=192.168.1.200-192.168.1.220$K z#d&t"y8l1r4)假定要实现防止外部网络使用TCP连接攻击路由器本身.Z Q9`2h3e,g1R[admin@MikroTik] /ip firewall filter> add chain=input protocol=tcp connection-limit=5,32 action=add-src-to-address-list address-list=black-address address-list-timeout=1d0}K5X#w:)H [admin@MikroTik] /ip firewall filter> add chain=input src-address-list=black-addressaction=drop~%k.?7]&D!i$w2q'y,[admin@MikroTik] /ip firewall filter> print;D0c9}7Z4X%m)|#VFlags: X - disabled, I - invalid, D - dynamic0 chain=input action=drop src-address=192.168.1.100:t'i/?&}%n3q"m1 chain=output action=drop protocol=icmp out-interface=wanicmp-options=0:0-255;x2y)N-q%6D2 chain=forward action=drop src-address=192.168.1.200-192.168.1.220!b8S3g)s&]3 chain=input action=add-src-to-address-list protocol=tcp7[+y.a2|C#M/address-list=black-address address-list-timeout=1dconnection-limit=5,321u6D(`9}$O2@5N-n'*F G4 chain=input action=drop src-address-list=black-address"A&j,3a'\以上的功能实现也可以利用filter与mangle相互配合使用:4v!O3m5F6H[admin@MikroTik] /ip firewall filter> ..[admin@MikroTik] /ip firewall> mangle7e;L*N)E|/j,_8A2P&J[admin@MikroTik] /ip firewall mangle> add chain=input protocol=tcp connection-limit=5,32 action=add-src-to-address-list address-list=black-address address-list-timeout=1d[admin@MikroTik] /ip firewall mangle> print3{-h;a(\y,~Flags: X - disabled, I - invalid, D - dynamic&a8w4x:;p2I1X+{^*W0 chain=input action=add-src-to-address-list protocol=tcp&w9z.?4u3x'[;{%e-o+Uaddress-list=black-address address-list-timeout=1d/|:l6J5q'R%v8g aconnection-limit=5,32#|8n)[$L*}J[admin@MikroTik] /ip firewall mangle> ..4};?-a"v!k*~,E[admin@MikroTik] /ip firewall> filter[admin@MikroTik] /ip firewall filter> add chain=input src-address-list=black-addressaction=drop[admin@MikroTik] /ip firewall filter> print2Y!D7t0M5F&X#d^.\Flags: X - disabled, I - invalid, D - dynamic'K%D7o C,V-T:P0 chain=input action=drop src-address-list=black-address*k0M"D O6Z%@;_解释一下相关部分参数:action=add-src-to-address-list意思是把引起超过限制连接数的源地址提取出来,放入名称为black-address 的地址列表中。
address-list-timeout参数的意思是放进black-address 地址列表中的IP地址在多久后释放出来。
connection-limit参数是配置连接数的限制,connection-limit=5,32 参数中5代表5个连接数,32是指IP地址的子网掩码,意思是每一个来访问路由器的源地址同时只允许最多建立5个TCP连接数。
#m*C)a5W/T.{rfilter规则的默认执行顺序是从上往下的顺序执行,在执行的过程中可以对规则的action参数相关配置对执行顺序作跳转,如跳转到用户自定义的链执行完了会再返回原来的序列往下执行。
5)假定为了抑制ICMP包攻击,设定对转发和路由本身的对ICMP的请求及回应的ICMP包数据进行限定[admin@MikroTik] /ip firewall filter> add chain=icmp protocol=icmp icmp-options=0 limit=5,32 action=accept9v%b0_1n5i$K6z[admin@MikroTik] /ip firewall filter> add chain=icmp protocol=icmp icmp-options=8 limit=5,32 action=accept#u+p3Y6C2v/I[admin@MikroTik] /ip firewall filter> printFlags: X - disabled, I - invalid, D - dynamic0 chain=icmp action=accept protocol=icmp icmp-options=0:0-255 limit=5,32,q5X!o%W)K0Z'E2]:r3n1 chain=icmp action=accept protocol=icmp icmp-options=8:0-255 limit=5,32解释一下相关部分参数:chain=icmp意思是建立自定义的链ICMP)p$a'L!@/G2]*u[admin@MikroTik] /ip firewall filter> add chain=input protocol=icmp action=jump jump-target=icmp/z:b S3y#}70X,~[admin@MikroTik] /ip firewall filter> add chain=forward protocol=icmp action=jump jump-target=icmp#K,x5M"q/X!d8i2~[admin@MikroTik] /ip firewall filter> printFlags: X - disabled, I - invalid, D - dynamic0 chain=icmp action=accept protocol=icmp icmp-options=0:0-255 limit=5,321 chain=icmp action=accept protocol=icmp icmp-options=8:0-255 limit=5,32-o2E"L1h#S8b4M*]B2 chain=input action=jump jump-target=icmp protocol=icmp1k!{$i.R&j:N(q'_"z*}3 chain=forward action=jump jump-target=icmp protocol=icmp7~8i6K(g.o以上在filter规则里面的执行顺序如下:路由器先对数据流一一与0,1 这两个条匹配,不匹配时,往下执行。