
MikroTik, part 2: firewall — basic rules, router protection, and network segmentation
🌐 Machine-translated from Russian. Show original
In this part:
Logic#
- Input chain — traffic directly to the router (Winbox, DNS, VPN).
- Forward chain — traffic through the router between networks and to the internet.
- Rules are checked from top to bottom, and the first matching one is triggered.
- Principle: allow what is necessary, forbid the rest.
Basic rule set#
/ip firewall filter
add chain=input action=accept connection-state=established,related,untracked comment="input: established"
add chain=input action=drop connection-state=invalid
add chain=input action=accept protocol=icmp
add chain=input action=accept in-interface-list=LAN comment="input: из LAN"
add chain=input action=accept protocol=udp dst-port=13231 comment="input: WireGuard (часть 3)"
add chain=input action=drop comment="input: все остальное"
add chain=forward action=fasttrack-connection connection-state=established,related hw-offload=yes
add chain=forward action=accept connection-state=established,related,untracked
add chain=forward action=drop connection-state=invalid
add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="forward: из интернета только проброшенное"
⚠️ Add rules to Safe Mode and first allow the LAN rule, otherwise you may lose access to the router.
Port clearance — caution#
/ip firewall nat add chain=dstnat in-interface-list=WAN protocol=tcp dst-port=443 action=dst-nat to-addresses=192.168.10.20 to-ports=443
Upload only what really needs to be accessible from the internet (for example, a web server with HTTPS). RDP, 1C, databases, and video surveillance recorders — only via VPN (part 3.
Segmentation: VLAN#
Divide the network by purpose:
| VLAN | Purpose | Access |
|---|---|---|
| 10 | employees | internet, servers, |
| 20 | servers | as needed |
| 30 | cameras and ACS | only the ACS recorder/server, no internet |
| 40 | guests | only internet |
Creating a VLAN on a bridge:
/interface vlan add name=vlan30-cams vlan-id=30 interface=bridge-lan
/ip address add address=192.168.30.1/24 interface=vlan30-cams
The rule "cameras don't go online":
/ip firewall filter add chain=forward in-interface=vlan30-cams out-interface-list=WAN action=drop place-before=0
For full VLAN operation, configure VLAN filtering on the bridge and switch ports — that's a separate topic, carefully follow the MikroTik documentation. Why isolate cameras — in the video surveillance series.
Brute force protection#
/ip firewall filter add chain=input protocol=tcp dst-port=22 connection-state=new src-address-list=ssh_block action=drop place-before=0
Plus address lists for suspicious IPs. But the best protection is not to open management services on the internet at all.
Verification#
- Scanning an external IP from another network: only ports you have consciously opened are open.
/ip firewall filter print stats— rule trigger counters.
Comments · 0
No comments yet.Sign in to comment, rate and see all comments.