本策略适用于防范UDP流量攻击(比如阿拉丁UDP攻击器)。TCP连接数攻击限制下单机连接数就行了,我就不多说了。
首先要新建一个网桥,将自己内网卡加入到桥接。
ROS防火墙脚本
- /interface bridge settings set use-ip-firewall=yes
- /ip firewall filter add action=add-src-to-address-list address-list=att address-list-timeout=10m chain=input connection-rate=10M-4294967295 protocol=udp src-address=192.168.0.0/24
- /ip firewall mangle add action=add-src-to-address-list address-list=att address-list-timeout=10m chain=postrouting connection-rate=10M-4294967295 protocol=udp src-address=192.168.0.0/24
修改IP为自己的内网IP地址范围。
ROS计划任务脚本
- :global attip
- :global defint
- :global taa 0
- :global nowmonth
- :global allmonth jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec
- :foreach lizi in=[$allmonth] do={
- :if ([:pick [/system clock get date] 0 3]=$lizi) do={
- :set nowmonth ($taa+1)}
- :set taa ($taa + 1)}
- :global atttime ([:pick [/system clock get date] 7 11].$nowmonth.[:pick [/system clock get date] 4 6]."-".[/system clock get time]);
- :foreach fatt in=[/ip firewall address-list find list=att] do={
- :set attip [/ip firewall address-list get $fatt address]
- :if ([/interface bridge nat find arp-dst-address=($attip."/32")]="") do={
- /interface bridge nat add action=src-nat arp-dst-address=($attip."/32") chain=srcnat mac-protocol=arp comment=("att-".$atttime)}}
- :foreach fattd in=[/interface bridge nat find] do={
- :if ([/ip firewall address-list find list=att address=[:pick [/interface bridge nat get $fattd arp-dst-address] 0 ([:len [/interface bridge nat get $fattd arp-dst-address]]-3)]]="") do={
- /interface bridge nat remove $fattd}}
设置为定时循环执行,建议间隔时间为3-5秒左右为宜。
本策略原理是将攻击者的IP记录下来,加入攻击者的IP到桥防火墙,攻击者的 IP将在ARP缓存超时后(WIN7系统5次测试计算后得到平均值为20秒左右。)无法和ROS通讯,因为找不到ROS的MAC,包括流量攻击也打不上 来,因为找不到目标。(进入桥防火墙后即使攻击者再手工绑定路由MAC也无法成功。)
缺点:若客户机在攻击前已绑定路由MAC,则防御无法生效。因为ARP缓存不会超时。