MikroTik Firewall Script Generator
Build a RouterOS v6 or v7 hardening .rsc script locally in your browser. No data leaves your device.
Router configuration
RouterOS version
WAN match type
Allowed: letters, numbers, dots, hyphens, underscores (e.g. WAN, ether1, pppoe-out1).
Used for the mgmt-trusted address list and WinBox/SSH service restriction.
mikrotik-firewall-v7.rsc
41 rules# MikroTik Firewall & Hardening Script (RouterOS v7)# Generated by Centipid Access — https://centipidaccess.com/tools/mikrotik-firewall-generator# IMPORTANT: Enable Safe Mode (Ctrl+X in CLI or Safe Mode button in WinBox) before pasting.# WAN matcher: in-interface-list=WAN | Management subnet: 192.168.88.0/24
# 1. Ensure the "WAN" interface list exists (add your WAN port(s) to it if not already present)/interface list:if ([:len [find name="WAN"]] = 0) do={ add name="WAN" }
# Trusted management address list/ip firewall address-listadd list=mgmt-trusted address=192.168.88.0/24 comment="Trusted management subnet"
# Harden RouterOS IP services/ip serviceset telnet disabled=yesset ftp disabled=yesset www disabled=yesset api disabled=yesset api-ssl disabled=yesset winbox address=192.168.88.0/24set ssh address=192.168.88.0/24
# Disable MAC-WinBox, MAC-Telnet, MAC-Ping and restrict Neighbor Discovery/tool mac-server set allowed-interface-list=none/tool mac-server mac-winbox set allowed-interface-list=none/tool mac-server ping set enabled=no/ip neighbor discovery-settings set discover-interface-list=!WAN
# Bogon address list (remove RFC1918/CGNAT entries if your WAN uplink uses private IPs)/ip firewall address-listadd list=bogons address=0.0.0.0/8 comment="Bogon subnet"add list=bogons address=10.0.0.0/8 comment="Bogon subnet"add list=bogons address=100.64.0.0/10 comment="Bogon subnet"add list=bogons address=127.0.0.0/8 comment="Bogon subnet"add list=bogons address=169.254.0.0/16 comment="Bogon subnet"add list=bogons address=172.16.0.0/12 comment="Bogon subnet"add list=bogons address=192.0.0.0/24 comment="Bogon subnet"add list=bogons address=192.0.2.0/24 comment="Bogon subnet"add list=bogons address=192.168.0.0/16 comment="Bogon subnet"add list=bogons address=198.18.0.0/15 comment="Bogon subnet"add list=bogons address=198.51.100.0/24 comment="Bogon subnet"add list=bogons address=203.0.113.0/24 comment="Bogon subnet"add list=bogons address=224.0.0.0/4 comment="Bogon subnet"add list=bogons address=240.0.0.0/4 comment="Bogon subnet"
# Firewall filter rules — input chain/ip firewall filteradd action=accept chain=input connection-state=established,related,untracked comment="Accept established and related"add action=drop chain=input connection-state=invalid comment="Drop invalid input packets"add action=drop chain=input in-interface-list=WAN src-address-list=bogons comment="Drop bogon sources on WAN"add action=drop chain=input in-interface-list=WAN protocol=tcp psd=21,3s,3,1 comment="Drop TCP port scans on WAN"add action=drop chain=input in-interface-list=WAN protocol=udp dst-port=53 comment="Drop WAN DNS amplification (UDP 53)"add action=drop chain=input in-interface-list=WAN protocol=tcp dst-port=53 comment="Drop WAN DNS queries (TCP 53)"add action=accept chain=input protocol=tcp dst-port=8291,22 src-address-list=mgmt-trusted comment="Allow WinBox and SSH from trusted management subnet"add action=accept chain=input protocol=icmp limit=50/5s,2:packet comment="Allow rate-limited ICMP"add action=drop chain=input in-interface-list=WAN comment="Drop all other input from WAN"
# Firewall filter rules — forward chain/ip firewall filteradd action=fasttrack-connection chain=forward connection-state=established,related hw-offload=yes comment="FastTrack established and related"add action=accept chain=forward connection-state=established,related,untracked comment="Accept established and related forward"add action=drop chain=forward connection-state=invalid comment="Drop invalid forward packets"add action=drop chain=forward in-interface-list=WAN src-address-list=bogons comment="Drop bogon forward traffic from WAN"add action=drop chain=forward connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="Drop new WAN forward traffic not DSTNATed"
# Enable TCP SYN cookies and loose reverse-path filtering/ip settings set tcp-syncookies=yes rp-filter=loose