Hi everyone, in this post I want to show you how to set up a basic MikroTik firewall for security. The firewall decides which packets are allowed to reach the router and which ones are allowed to pass through to your network. Without a proper firewall, services such as WinBox, SSH, or telnet can be reached by anyone on the internet and become targets for password guessing.
The lab uses a MikroTik CHR running RouterOS 7.25.2, connected to the internet through a PPPoE client. I used a second router as the ISP and also as the attacker on the internet side. The result was quite a surprise: the firewall I built in the basic configuration article turned out to protect nothing at all after the internet connection moved to PPPoE.
Why the Old Firewall Does Not Work
Check the current firewall rules

/ip firewall filter print stats where chain=input and dynamic=no
/interface list member printThe rule that blocks router access from the WAN uses in-interface=ether1, and its counter is still at 0 packets. The problem is that the router now reaches the internet through pppoe-out1, not ether1. The WAN interface list already contains pppoe-out1, but the old firewall rule does not use that list.
Test from the internet side

From the ISP router, I tried to ping and telnet to the lab router’s WAN IP, 100.64.10.50.
/ping 100.64.10.50 count=2
/system telnet 100.64.10.50Telnet connected and the Login prompt appeared right away. This means anyone on the internet can try to guess the router’s username and password. That is exactly why firewall rules should use interface lists instead of interface names.
The Firewall Pattern Recommended by MikroTik
The MikroTik default configuration uses a simple pattern that is very effective.
Input chain : protects the router itself
1. accept established, related, untracked connections
2. drop invalid connections
3. accept ICMP (ping)
4. accept destination 127.0.0.1 (internal router services)
5. drop everything that does not come from the LAN
Forward chain : protects the network behind the router
1. accept established, related, untracked connections
2. drop invalid connections
3. drop new connections from the WAN that are not port forwardingOrder matters a lot, because the firewall reads the rules from the top and the first matching rule is the one that applies. A packet that does not match any rule is accepted.
Applying the Firewall Safely
Before changing the firewall, turn on Safe Mode in the top right corner of WinBox. If a rule you create cuts off your connection, all changes are rolled back automatically. You can find the full explanation in the MikroTik Safe Mode article.
Create the LAN interface list

/interface list add name=LAN
/interface list member add list=LAN interface=bridge1
/interface list member add list=LAN interface=ether3
/ppp profile set paket-lab interface-list=LAN
/interface list member printEvery trusted interface goes into LAN, including the bridge for the admin network and ether3 for the hotspot. PPPoE server customers are also added automatically through the interface-list setting in the PPP profile. The WAN list already contains ether1 and pppoe-out1.
Add the new rules

/ip firewall filter
add chain=input action=accept connection-state=established,related,untracked comment="input: terima koneksi lanjutan"
add chain=input action=drop connection-state=invalid comment="input: buang invalid"
add chain=input action=accept protocol=icmp comment="input: izinkan ping"
add chain=input action=accept dst-address=127.0.0.1 comment="input: izinkan loopback"
add chain=input action=drop in-interface-list=!LAN log=yes log-prefix="DROP-INPUT" comment="input: buang selain LAN"
add chain=forward action=accept connection-state=established,related,untracked comment="forward: terima koneksi lanjutan"
add chain=forward action=drop connection-state=invalid comment="forward: buang invalid"
add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="forward: buang koneksi baru dari WAN"The comments are in Indonesian to match the screenshots. They mean accept ongoing connections, drop invalid, allow ping, allow loopback, drop everything except LAN, and drop new connections from the WAN. After adding these rules, delete the old ones. The allow loopback rule is needed because User Manager in this lab receives RADIUS requests on 127.0.0.1. The last input chain rule has logging turned on so that access attempts from outside are recorded. In WinBox, you create the rules in IP, Firewall, on the Filter Rules tab, and you can change their order by dragging them.
My experience: On the first print after adding the rules, a few of them briefly showed the I flag, meaning invalid. Just like in the Queue Tree article, this only lasts a moment while the rules are being processed. Printing again a few seconds later showed all rules as normal. More importantly, my WinBox session stayed connected, so Safe Mode had nothing to roll back.
Testing the Firewall
Attacks from the WAN are blocked

From the ISP router, ping to 100.64.10.50 still works because ICMP is allowed, but telnet stops at Connecting and never reaches the Login prompt.
Check the rule counters

/ip firewall filter print stats where dynamic=no and chain=inputThe input: buang selain LAN rule (drop everything except LAN) is now counting dropped packets. Counters are the fastest way to confirm that a rule is really working. A rule whose counter always stays at 0 deserves a closer look.
Look at the recorded log

/log print where message~"DROP-INPUT"The log records every telnet attempt from 100.64.10.1 to port 23 through pppoe-out1, along with the time. Some of the other entries are neighbor discovery packets on port 5678 from the ISP router, which are dropped as well.
Make sure the LAN still works normally

ping -c 2 8.8.8.8; nslookup mamangdigital.comClients on the LAN can still reach the internet and resolve domain names. The firewall does not get in the way of users, it only closes access from outside.
Closing Unused Services
Disable and restrict IP Services

/ip service disable telnet,api,api-ssl
/ip service set winbox,ssh available-from=192.168.56.0/24
/ip service printTelnet sends passwords without encryption, and the API is rarely used, so it is safer to turn them off. WinBox and SSH are restricted to the admin network 192.168.56.0/24, so even if the firewall has a mistake, these services still refuse other addresses. In WinBox, these settings are in IP, Services.
Turn off Safe Mode

Once everything has been tested, click Safe Mode again to turn it off and keep the changes. When I ran the command above with the old address= parameter, RouterOS 7.25.2 showed a Deprecation warning because that parameter will be removed. That is why I used available-from= in the command above.
Use the new available-from syntax

/ip service set winbox,ssh available-from=192.168.56.0/24
/ip service print where name~"winbox|ssh"With available-from, the command runs without a warning and the AVAILABLE-FROM column shows 192.168.56.0/24 for ssh and winbox. Older tutorials that still use address= will keep working for now, but it is a good idea to start moving to the new syntax.
Common Problems and How to Fix Them
Locked out of the router after creating a drop rule
Turn on Safe Mode before changing the firewall. If it is already too late, connect by MAC address from the Neighbors tab in WinBox on a LAN port, because WinBox over MAC does not go through the IP firewall.
The drop rule never counts any packets
The rule uses the wrong interface name, for example ether1 when the WAN is already pppoe-out1. Use interface lists and make sure every WAN interface is in the WAN list.
LAN clients cannot open websites after the firewall is applied
Usually DNS is blocked too because the LAN interface has not been added to the LAN list. Check with /interface list member print.
Port forwarding cannot be reached from outside
The last forward chain rule only drops new connections from the WAN that are not dstnat. Make sure your dstnat NAT rule is correct, because that traffic is allowed automatically.
The firewall feels slow
Use logging only on important rules, and avoid creating too many rules for individual IP addresses. Use an address list to group addresses together.
At this point the router is protected from internet access, unused services are closed, and LAN users keep working normally. The same firewall can also be used to block websites on MikroTik with an address list. If you have ever come across a router that was open to the internet, share your experience in the comments.












