当前位置:文档之家› ROS基本防护脚本

ROS基本防护脚本

本适用于ROS 2.9.2.7保存以下脚本后缀改为rsc,用winbox上传到路由上,用命令:import 文件名导入。

具体的脚本定义内容,在脚本里已经做了注释,请自行参阅修改。

使用前请进行综合测试,以确保适合本网吧使用。

本站不为盲目操作带来的任何损失负责。

------------------------------------------------------------------------------------------------------------------#注意这里的设置中假定外网网卡的名字是wan,如果是大写需要更改。

#关于TCP连接的一些设置,主要是减少连接的存活时间/ip firewall connection trackingset enabled=yes tcp-syn-sent-timeout=1m tcp-syn-received-timeout=1m \tcp-established-timeout=1d tcp-fin-wait-timeout=10s \tcp-close-wait-timeout=10s tcp-last-ack-timeout=10s \tcp-time-wait-timeout=10s tcp-close-timeout=10s udp-timeout=10s \udp-stream-timeout=3m icmp-timeout=10s generic-timeout=10m#删除已有的防火墙(如果有的话):foreach i in=[/ip firewall filter find] do=[/ip firewall filter disable $i]:foreach i in [/ip firewall filter find] do [/ip firewall filter remove $i]#在短时间内从同一地址用不断变化的端口向本机发送大量数据包,视为端口扫描#短时间内同时建立大量TCP连接(超过10) ,视为DDoS 拒绝服务攻击, 进黑名单一天!#黑名单上的只能建立三个并发连接#内网的数据包不转发#禁止从外网ping路由主机,默认关闭#针对路由主机的,input/ip firewall filteradd chain=input connection-state=established action=accept comment="accept established connection packets" disabled=noadd chain=input connection-state=related action=accept comment="accept related connection packets" disabled=noadd chain=input connection-state=invalid action=drop comment="drop invalid packets"add chain=input protocol=tcp psd=21,3s,3,1 action=drop comment="detect and drop port scan connections" disabled=noadd chain=input protocol=tcp connection-limit=3,32 src-address-list=black_list action=tarpit comment="suppress DoS attack" disabled=noadd chain=input protocol=tcp connection-limit=10,32 action=add-src-to-address-list address-list=black_list address-list-timeout=1d comment="detect DoS attack" disabled=noadd chain=input dst-address-type=!local action=drop comment="drop all that is not to local" disabled=noadd chain=input src-address-type=!unicast action=drop comment="drop all that is not from unicast" disabled=noadd chain=input protocol=icmp action=jump jump-target=ICMP comment="jump to chain ICMP" disabled=noadd chain=input action=jump jump-target=services comment="jump to chain services" disabled=noadd chain=input action=jump jump-target=virus comment="jump to chain virus" disabled=no add chain=input action=log log-prefix="input" comment="log everything else" disabled=yes#针对ICMP数据包/ip firewall filteradd chain=ICMP protocol=icmp icmp-options=0:0-255 limit=5,5 action=accept comment="0:0 allow ping and limit for 5pac/s" disabled=noadd chain=ICMP protocol=icmp icmp-options=3:3 limit=5,5 action=accept comment="3:3 allow trace and limit for 5pac/s" disabled=noadd chain=ICMP protocol=icmp icmp-options=3:4 limit=5,5 action=accept comment="3:4 allow MTU discovery and limit for 5pac/s" disabled=noadd chain=ICMP protocol=icmp icmp-options=8:0-255 limit=5,5 action=accept comment="允许外网PING路由" disabled=noadd chain=ICMP protocol=icmp icmp-options=11:0-255 limit=5,5 action=accept comment="11:0 allow TTL exceeded and limit for 5pac/s" disabled=noadd chain=ICMP protocol=icmp action=drop comment="Drop everything else" disabled=no#路由主机上开启的一些端口,用于路由器上的网络服务。

默认没有启用几个/ip firewall filteradd chain=services src-address=127.0.0.1 dst-address=127.0.0.1 action=accept comment="accept localhost" disabled=noadd chain=services protocol=tcp dst-port=20-21 action=accept comment="allow ftp" disabled=no add chain=services protocol=tcp dst-port=22 action=accept comment="allow sftp, ssh" disabled=noadd chain=services protocol=tcp dst-port=23 action=accept comment="allow telnet" disabled=no add chain=services protocol=tcp dst-port=80 action=accept comment="allow http, webbox"add chain=services protocol=tcp dst-port=8291 action=accept comment="Allow winbox" disabled=noadd chain=services protocol=udp dst-port=20561 action=accept comment="allow MACwinbox " disabled=noadd chain=services src-address=159.148.172.205 protocol=tcp dst-port=7828 action=accept comment="..." disabled=yesadd chain=services protocol=tcp dst-port=2000 action=accept comment="Bandwidth server" disabled=yesadd chain=services protocol=udp dst-port=5678 action=accept comment=" MT Discovery Protocol" disabled=yesadd chain=services protocol=tcp dst-port=53 action=accept comment="allow DNS request" disabled=yesadd chain=services protocol=udp dst-port=53 action=accept comment="Allow DNS request" disabled=yesadd chain=services protocol=udp dst-port=1701 action=accept comment="allow L2TP" disabled=yesadd chain=services protocol=tcp dst-port=1723 action=accept comment="allow PPTP" disabled=yesadd chain=services protocol=gre action=accept comment="allow PPTP and EoIP" disabled=yes add chain=services protocol=ipencap action=accept comment="allow IPIP" disabled=yesadd chain=services protocol=udp dst-port=1900 action=accept comment="UPnP" disabled=yes add chain=services protocol=tcp dst-port=2828 action=accept comment="UPnP" disabled=yes add chain=services protocol=udp dst-port=67-68 action=accept comment="allow DHCP" disabled=yesadd chain=services protocol=tcp dst-port=8080 action=accept comment="allow Web Proxy" disabled=yesadd chain=services protocol=tcp dst-port=123 action=accept comment="allow NTP" disabled=yes add chain=services protocol=tcp dst-port=161 action=accept comment="allow SNMP" disabled=yesadd chain=services protocol=tcp dst-port=443 action=accept comment="allow https for Hotspot" disabled=yesadd chain=services protocol=tcp dst-port=1080 action=accept comment="allow Socks for Hotspot" disabled=yesadd chain=services protocol=udp dst-port=500 action=accept comment="allow IPSec connections" disabled=yesadd chain=services protocol=ipsec-esp action=accept comment="allow IPSec" disabled=yesadd chain=services protocol=ipsec-ah action=accept comment="allow IPSec" disabled=yesadd chain=services protocol=tcp dst-port=179 action=accept comment="Allow BGP" disabled=yesadd chain=services protocol=udp dst-port=520-521 action=accept comment="allow RIP" disabled=yesadd chain=services protocol=ospf action=accept comment="allow OSPF" disabled=yesadd chain=services protocol=udp dst-port=5000-5100 action=accept comment="allow BGP"add chain=services protocol=tcp dst-port=1720 action=accept comment="allow Telephony" disabled=yesadd chain=services protocol=udp dst-port=1719 action=accept comment="allow Telephony" disabled=yesadd chain=services protocol=vrrp action=accept comment="allow VRRP " disabled=yes#丢弃已知的病毒特征包virus/ip firewall filteradd chain=virus protocol=tcp dst-port=445 action=drop comment="Drop Blaster Worm" disabled=noadd chain=virus protocol=udp dst-port=445 action=drop comment="Drop Blaster Worm" disabled=noadd chain=virus protocol=tcp dst-port=593 action=drop comment="________" disabled=no add chain=virus protocol=tcp dst-port=1024-1030 action=drop comment="________" disabled=noadd chain=virus protocol=tcp dst-port=1080 action=drop comment="Drop MyDoom" disabled=no add chain=virus protocol=tcp dst-port=1214 action=drop comment="________" disabled=noadd chain=virus protocol=tcp dst-port=1363 action=drop comment="ndm requester" disabled=no add chain=virus protocol=tcp dst-port=1364 action=drop comment="ndm server" disabled=no add chain=virus protocol=tcp dst-port=1368 action=drop comment="screen cast" disabled=no add chain=virus protocol=tcp dst-port=1373 action=drop comment="hromgrafx" disabled=no add chain=virus protocol=tcp dst-port=1377 action=drop comment="cichlid" disabled=noadd chain=virus protocol=tcp dst-port=1433-1434 action=drop comment="Worm" disabled=no add chain=virus protocol=tcp dst-port=2745 action=drop comment="Bagle Virus" disabled=no add chain=virus protocol=tcp dst-port=2283 action=drop comment="Drop Dumaru.Y" disabled=noadd chain=virus protocol=tcp dst-port=2535 action=drop comment="Drop Beagle" disabled=no add chain=virus protocol=tcp dst-port=2745 action=drop comment="Drop Beagle.C-K" disabled=noadd chain=virus protocol=tcp dst-port=3127-3128 action=drop comment="Drop MyDoom" disabled=noadd chain=virus protocol=tcp dst-port=3410 action=drop comment="Drop Backdoor OptixPro" disabled=noadd chain=virus protocol=tcp dst-port=4444 action=drop comment="Worm" disabled=noadd chain=virus protocol=udp dst-port=4444 action=drop comment="Worm" disabled=noadd chain=virus protocol=tcp dst-port=5554 action=drop comment="Drop Sasser" disabled=no add chain=virus protocol=tcp dst-port=8866 action=drop comment="Drop Beagle.B" disabled=no add chain=virus protocol=tcp dst-port=9898 action=drop comment="Drop Dabber.A-B" disabled=noadd chain=virus protocol=tcp dst-port=10000 action=drop comment="Drop Dumaru.Y" disabled=noadd chain=virus protocol=tcp dst-port=10080 action=drop comment="Drop MyDoom.B"add chain=virus protocol=tcp dst-port=12345 action=drop comment="Drop NetBus" disabled=no add chain=virus protocol=tcp dst-port=17300 action=drop comment="Drop Kuang2" disabled=no add chain=virus protocol=tcp dst-port=27374 action=drop comment="Drop SubSeven" disabled=noadd chain=virus protocol=tcp dst-port=65506 action=drop comment="Drop PhatBot, Gaobot" disabled=no#转发的数据包forward/ip firewall filteradd chain=forward connection-state=established action=accept comment="accept established packets" disabled=noadd chain=forward connection-state=related action=accept comment="accept related packets" disabled=noadd chain=forward connection-state=invalid action=drop comment="drop invalid packets" disabled=noadd chain=forward src-address-type=!unicast action=drop comment="drop all that is not from unicast" disabled=noadd chain=forward in-interface=wan src-address-list=not_in_internet action=drop comment="drop data from bogon IP's" disabled=noadd chain=forward in-interface=!wan dst-address-list=not_in_internet action=drop comment="drop data to bogon IP's" disabled=noadd chain=forward protocol=icmp action=jump jump-target=ICMP comment="jump to chain ICMP" disabled=noadd chain=forward action=jump jump-target=virus comment="jump to virus chain" disabled=no add chain=forward action=accept comment="Accept everything else" disabled=no#从路由主机访问外网的数据包output/ip firewall filteradd chain=output connection-state=invalid action=drop comment="drop invalid packets" disabled=noadd chain=output connection-state=related action=accept comment="accept related packets" disabled=noadd chain=output connection-state=established action=accept comment="accept established packets" disabled=no#定义内网特殊地址列表bogon IP/ip firewall address-listadd list=not_in_internet address=0.0.0.0/8 comment="" disabled=noadd list=not_in_internet address=172.16.0.0/12 comment="" disabled=noadd list=not_in_internet address=192.168.0.0/16 comment="" disabled=noadd list=not_in_internet address=10.0.0.0/8 comment="" disabled=noadd list=not_in_internet address=169.254.0.0/16 comment="" disabled=noadd list=not_in_internet address=127.0.0.0/8 comment="" disabled=noadd list=not_in_internet address=224.0.0.0/3 comment="" disabled=no#防LAN二级代理/ip firewall mangleadd chain=prerouting action=change-ttl new-ttl=decrement:1 comment="" disabled=no#关闭所有服务端口/ip serviceset ftp disabled=yesset ssh disabled=yesset telnet disabled=yesset www disabled=yesset www-ssl disabled=yes#定义连接时间判断与限制/ip firewall connection trackingset enabled=yes tcp-syn-sent-timeout=2m tcp-syn-received-timeout=1m \ tcp-established-timeout=10h tcp-fin-wait-timeout=2m \tcp-close-wait-timeout=1m tcp-last-ack-timeout=30s \tcp-time-wait-timeout=2m tcp-close-timeout=10s udp-timeout=30s \udp-stream-timeout=3m icmp-timeout=30s generic-timeout=10m#关闭路由主机服务/ip firewall service-portset pptp disabled=yesset ftp ports=21 disabled=yesset tftp ports=69 disabled=yesset irc ports=6667 disabled=yesset h323 disabled=yesset quake3 disabled=yesset gre disabled=yes。

相关主题