Firewall
In WinBox you can configure firewall in IP -> Firewall, or you can use terminal with command /ip firewall
The RouterOS firewall operates on multiple chains and provides comprehensive control over network traffic through filtering, NAT, and mangle rules.
Firewall fundamentals
How RouterOS firewall works
Core components:
Filter rules - Accept, drop, or reject packets based on criteria
NAT rules - Network Address Translation for routing and security
Mangle rules - Mark packets for QoS and advanced routing
Connection tracking - Stateful inspection of network connections
Address lists - Dynamic IP address groupings for rules
Processing order:
Raw - Before connection tracking (advanced users)
Mangle - Packet marking and modification
NAT - Address translation
Filter - Accept/drop decisions
Connection tracking - State management throughout
Basic firewall concepts
Chains and processing
RouterOS uses predefined chains for packet processing:
Filter chains:
input - Packets destined for the router itself
forward - Packets routed through the router
output - Packets originating from the router
NAT chains:
srcnat - Source NAT (typically for internet access)
dstnat - Destination NAT (port forwarding, load balancing)
Mangle chains:
prerouting - Before routing decision
input - To router (before input filter)
forward - Through router (before forward filter)
output - From router (before output filter)
postrouting - After routing decision
Connection states
Basic firewall configuration
Default secure firewall setup
Essential firewall rules for basic security:
Create address lists
Define network groups for easier rule management:
Advanced filtering rules
Protect against common attacks
Port knocking for enhanced security
Connection tracking and optimization
Connection tracking settings
FastTrack for performance
Enable FastTrack to bypass firewall for established connections:
Service protection
Secure management services
DNS and NTP security
IPv6 firewall basics
IPv6 firewall configuration
Monitoring and logging
Traffic monitoring
Logging configuration
Troubleshooting firewall
Debugging connectivity issues
Performance troubleshooting
Firewall topics
Detailed configurations
This firewall section covers several specialized topics:
NAT - Network Address Translation
Masquerade for internet sharing
Destination NAT for port forwarding
Source NAT for network routing
Advanced NAT scenarios and load balancing
Mangle - Packet marking and manipulation
QoS packet marking for traffic shaping
Policy-based routing with packet marks
Connection marking for bandwidth management
Advanced traffic manipulation
Layer-7 - Application protocol filtering
Deep packet inspection patterns
Protocol-specific blocking and shaping
Custom protocol detection
Application-aware firewall rules
Best practices
Security recommendations
Default deny policy - Block everything not explicitly allowed
Least privilege - Grant minimum necessary access
Regular monitoring - Watch logs and connection tables
Address list management - Use dynamic lists for threats
Service hardening - Disable unnecessary services
Performance optimization
Use FastTrack - Bypass firewall for established connections
Optimize rule order - Most frequent matches first
Connection limits - Prevent resource exhaustion
Interface lists - Use instead of individual interfaces
Regular cleanup - Remove unused rules and lists
Maintenance tips
Document rules - Use meaningful comments
Version control - Export configurations regularly
Test changes - Verify in lab environment first
Monitor impact - Check performance after changes
Emergency access - Always maintain management access
Last updated
Was this helpful?