Firewall Logging, Backups & Best Practices

— Keep It Clean, Recoverable, and Easy to Maintain

Why This Matters

A solid firewall config can take hours to build — but minutes to lose.

Whether it’s:

  • A reboot gone wrong
  • A bad rule blocking your access
  • An upgrade that resets the config
  • Or simply forgetting what each rule does…

You need a system to keep your firewall alive, readable, and resilient.


🔁 1. Regular Backups and Exports

📍 Difference Between Backup and Export:

TypeWhat it does
backupBinary file of full system config (not readable/editable)
exportHuman-readable script you can tweak or version control

📥 How to Backup:

/system backup save name=firewall_config

You’ll get a file like firewall_config.backup in Files — download it to your PC!


📤 How to Export Firewall Only:

/export file=firewall_export

You’ll get firewall_export.rsc.
You can edit, version in Git, or apply on other routers.


🧼 2. Use Comments Everywhere

Every rule, every address list, every NAT line — must have a comment.

Example:

/ip firewall filter
add chain=input src-address-list=TRUSTED_IPS action=accept comment="Allow remote Winbox"
/ip firewall nat
add chain=dstnat dst-port=443 action=dst-nat to-addresses=192.168.88.100 comment="HTTPS to NAS"

It’s not optional — future you will thank you.


📚 3. Group Rules Logically

Use grouping by chain and purpose, for example:

  • Section 1: Input chain
  • Section 2: Forward chain (LAN access)
  • Section 3: Forward chain (guest/VPN)
  • Section 4: NAT rules
  • Section 5: Special protections (DoS, brute-force)
  • Section 6: Logging and drops

You can even add empty comment rules as section headers:

/ip firewall filter
add comment="=== INPUT CHAIN START ==="

📈 4. Monitor With Logging (But Not Too Much)

Logging is great — until it crashes your CPU.

Tips:

  • Only log important drops, like SSH brute-force or port scans
  • Use log-prefix= to easily grep or filter
  • Use log limits to reduce spam:
add chain=input src-address-list=SSH_BRUTE action=drop log=yes log-prefix="SSH_BRUTE " log-disabled=no

🔒 5. Lock Yourself Out? Here’s the Rescue Plan

If you apply a bad rule and lose access — do one of the following:

Option 1: MAC Winbox

  • Connect directly via Winbox using MAC address
  • It bypasses IP settings
  • Only works in L2

Option 2: Netinstall Reset

  • Use MikroTik’s Netinstall to reflash router
  • You’ll need physical access and boot from Netinstall server

🧠 6. Pro Tips From the Field

✔️ Use Address Lists for everything — even internal networks
✔️ Document every rule in a .md or .rsc file
✔️ Export rules monthly and save in Git or cloud
✔️ Use scheduled scripts to check config or notify you
✔️ Disable unused services in /ip service

✅ Final Summary

🎯 You’ve now built a fully functional, professional-grade MikroTik firewall with:

  • Clear input/forward logic
  • Dynamic protection against attacks
  • NAT and Hairpin NAT
  • Scalable address lists
  • Clean, well-commented rules
  • Backups, logging, and recovery plans

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *