In OpenWrt's firewall, the terms Input, Output, and Forward define how traffic is handled by the firewall within a particular zone. Each zone represents a group of interfaces (e.g., LAN, WAN) with associated firewall rules. Here's what each of these terms means:
1. Input
- Definition: Controls traffic coming into the router itself (the router's IP address) from devices or networks in a particular zone.
- Implications:
- When traffic is destined for the router itself (like logging into the web interface (
LuCI), SSH access, pings, or DNS requests), the Input policy of that zone determines whether the traffic is accepted, rejected, or dropped.
- For example:
- If the WAN zone's Input policy is "Reject," nobody from the outside internet can contact the router (e.g., no remote management or pings to the router's WAN IP).
- If the LAN zone's Input policy is "Accept," devices inside your local network (LAN) can reach the router to, for example, configure it via the web interface.
2. Output
- Definition: Controls traffic leaving the router to other devices or networks from a particular zone.
- Implications:
- When the router itself generates traffic (think: sending DNS queries, NTP, or package downloads via opkg), the Output policy of the zone determines whether that traffic is allowed.
- For example:
- In the WAN zone, "Output: Accept" allows the router to send traffic to the internet (e.g., checking for updates or downloading software).
- In most cases, Output is set to "Accept" globally, as devices within the LAN and the router itself need to make outbound connections.
3. Forward
- Definition: Controls traffic that is routed through the router from one network zone to another.
- Implications:
- This applies to packets not destined for the router itself but rather to devices on either side of the router.
- For example:
- If a device on the internet (WAN zone) tries to access a device on your local network (LAN zone), the Forward setting in the WAN zone would determine whether that packet is forwarded to the LAN device.
- Similarly, LAN-to-WAN traffic (from a local device to the internet) is also controlled by Forward rules.
- A typical default setup allows LAN-to-WAN forwarding (for internet access) but blocks WAN-to-LAN forwarding (to block external parties from accessing your internal network).
Firewall Rule Values
Each policy can be set to one of the following:
- Accept: The firewall allows the packet.
- Reject: The firewall actively refuses the packet and sends a "connection refused" notification to the sender.
- Drop: The firewall silently discards the packet without responding.
Practical Default Configurations in OpenWrt
When you set up OpenWrt by default:
Example Use Cases
-
Block All Inbound Traffic from the Internet:
- Set the WAN zone's Input policy to
DROP or REJECT.
-
Prevent Router from Making Outbound Connections to the Internet:
- Set the WAN zone's Output policy to
REJECT or DROP.
-
Stop LAN Devices from Accessing the Internet:
- Set the LAN-to-WAN forwarding rule to
REJECT in the firewall configuration.
Summary
The Input, Output, and Forward rules define traffic control at three levels:
- Input: Traffic destined for the router itself.
- Output: Traffic originating from the router.
- Forward: Traffic passing through the router between zones (e.g., LAN to WAN).
These policies collectively dictate how data moves into, out of, and through the router, ensuring control over network traffic at each stage.