|
楼主 |
发表于 2024-2-22 09:56
|
显示全部楼层
我的防火墙规则来自这里:最新ROS防火墙初级和高级规则脚本,需要的拿去吧
在初级脚本基础上添加了openconnect(443,TCP),wireguard(6666,UDP)端口转发以及FULLCONE功能:
- # 2024-02-20 22:56:17 by RouterOS 7.13.4
- # software id = TI09-7WK3
- #
- /ip firewall address-list
- add address=10.89.1.2-10.89.1.254 list=allowed_to_router
- add address=0.0.0.0/8 comment=RFC6890 list=not_in_internet
- add address=172.16.0.0/12 comment=RFC6890 list=not_in_internet
- add address=192.168.0.0/16 comment=RFC6890 list=not_in_internet
- add address=10.0.0.0/8 comment=RFC6890 list=not_in_internet
- add address=169.254.0.0/16 comment=RFC6890 list=not_in_internet
- add address=127.0.0.0/8 comment=RFC6890 list=not_in_internet
- add address=224.0.0.0/4 comment=Multicast list=not_in_internet
- add address=198.18.0.0/15 comment=RFC6890 list=not_in_internet
- add address=192.0.0.0/24 comment=RFC6890 list=not_in_internet
- add address=192.0.2.0/24 comment=RFC6890 list=not_in_internet
- add address=198.51.100.0/24 comment=RFC6890 list=not_in_internet
- add address=203.0.113.0/24 comment=RFC6890 list=not_in_internet
- add address=100.64.0.0/10 comment=RFC6890 list=not_in_internet
- add address=240.0.0.0/4 comment=RFC6890 list=not_in_internet
- add address=192.88.99.0/24 comment="6to4 relay Anycast [RFC 3068]" list=\
- not_in_internet
- add list=ddos-attackers
- add list=ddos-target
- /ip firewall filter
- add action=accept chain=input comment=\
- "Protect the router itself:default configuration" connection-state=\
- established,related
- add action=accept chain=input src-address-list=allowed_to_router
- add action=accept chain=input protocol=icmp
- add action=accept chain=input dst-port=6666 log=yes log-prefix=wg: protocol=\
- udp
- add action=drop chain=input
- add action=fasttrack-connection chain=forward comment=FastTrack \
- connection-state=established,related hw-offload=yes
- add action=accept chain=forward comment="Established, Related" \
- connection-state=established,related
- add action=drop chain=forward comment="Drop invalid" connection-state=invalid \
- log=yes log-prefix=invalid
- add action=drop chain=forward comment=\
- "Drop tries to reach not public addresses from LAN" dst-address-list=\
- not_in_internet in-interface=ether2-LAN log=yes log-prefix=\
- !public_from_LAN out-interface=!ether2-LAN
- add action=drop chain=forward comment=\
- "Drop incoming packets that are not NAT`ted" connection-nat-state=!dstnat \
- connection-state=new in-interface=ether1-WAN log=yes log-prefix=!NAT
- add action=jump chain=forward comment="jump to ICMP filters" jump-target=icmp \
- protocol=icmp
- add action=drop chain=forward comment=\
- "Drop incoming from internet which is not public IP" in-interface=\
- ether1-WAN log=yes log-prefix=!public src-address-list=not_in_internet
- add action=drop chain=forward comment=\
- "Drop packets from LAN that do not have LAN IP" in-interface=ether2-LAN \
- log=yes log-prefix=LAN_!LAN src-address=!10.89.1.0/24
- add action=accept chain=icmp comment="Allow only needed icmp:echo reply" \
- icmp-options=0:0 protocol=icmp
- add action=accept chain=icmp comment="net unreachable" icmp-options=3:0 \
- protocol=icmp
- add action=accept chain=icmp comment="host unreachable" icmp-options=3:1 \
- protocol=icmp
- add action=accept chain=icmp comment=\
- "host unreachable fragmentation required" icmp-options=3:4 protocol=icmp
- add action=accept chain=icmp comment="allow echo request" icmp-options=8:0 \
- protocol=icmp
- add action=accept chain=icmp comment="allow time exceed" icmp-options=11:0 \
- protocol=icmp
- add action=accept chain=icmp comment="allow parameter bad" icmp-options=12:0 \
- protocol=icmp
- add action=drop chain=icmp comment="deny all other types"
- add action=return chain=detect-ddos comment="DDoS Protection" dst-limit=\
- 32,32,src-and-dst-addresses/10s
- add action=add-dst-to-address-list address-list=ddos-target \
- address-list-timeout=10m chain=detect-ddos
- add action=add-src-to-address-list address-list=ddos-attackers \
- address-list-timeout=10m chain=detect-ddos
- /ip firewall nat
- add action=endpoint-independent-nat chain=srcnat comment=FullCone-Nat \
- protocol=udp randomise-ports=no
- add action=endpoint-independent-nat chain=dstnat comment=FullCone-Nat \
- protocol=udp randomise-ports=no
- add action=masquerade chain=srcnat
- add action=masquerade chain=srcnat dst-address=10.89.1.0/24 out-interface=\
- ether2-LAN src-address=10.89.1.0/24
- add action=dst-nat chain=dstnat comment=\
- "Open 4443 TCP port for openconnect clients" dst-port=4443 protocol=tcp \
- to-addresses=10.89.1.15 to-ports=4443
- /ip firewall raw
- add action=drop chain=prerouting dst-address-list=ddos-target \
- src-address-list=ddos-attackers
复制代码
保存成文本文件(fullcone.rsc)上传RouterOS,然后用命令导入就行了。注意替换 ether1-WAN、ether2-LAN以及局域网地址
- import file-name=fullcone.rsc
复制代码
|
|