Firewall usage guide

This section contains useful information and best-practice guides for configuring firewall3.

Depending on network topology, there can be a large number of fw3 rules. For maintenance, and debugging, it helps to create a naming scheme to enter in the name option of the config sections. Use whatever pattern works well for you.

One possible pattern for rule names is: target-port-source-dest, where:

  • target is the netfilter target,
  • port is the port number (see RFC 793, Section 2.7),
  • source is the zone, device, or specific station the packet originates from, and...
  • dest is the zone, device, or specific station the packet is destined for


ACCEPT a SSH request from any device in the WAN zone of the router to any device in the LAN zone.

option name 'ACCEPT-SSH-WAN-LAN'

ACCEPT an SSH request from any device in the WAN zone to the router. This is only necessary if the default rule and WAN zone config rule are set to REJECT or DROP.


The enabled option is defined for each functional section and defaulted to true. To override it add option enabled '0' to a particular rule (or toggle the LuCI Network → Firewall → Traffic Rule → Enable checkbox.)

This is very useful when adding a rule and quickly enabling/disabling it.

For example, the following rule disables SSH access from a particular station on the WAN-side of the reference network to devices on the LAN-side. Note, for production, it is probably easier to use a MAC address instead of setting up a static DHCP lease and adding separate rules for IPv4 and IPv6.

config rule
	option	src		'wan'
	option	dest		'lan'
	option	proto		'tcp'
	option	dest_port	'22'
	option	src_ip		''
	option	target		'REJECT'
	option	name		'REJECT-SSH-WANSTA-LAN'
	option	enabled		'0'

It is important to test each firewall rule you have added. If it works, GREAT!

If it does not produce the desired result then it is almost certainly a problem with the resulting netfilter rule(s) or rule order. See Openwrt Netfilter Management for tips on debugging the problem.

When the openwrt image is first installed on the target device, it contains a “safe” /etc/config/firewall file. This is a useful file to study and potentially save for backup. Note there are a large number of rules commented out that could be uncommented for your use.

It will generally need to be modified for your needs.

The original source for the firewall configuration file is in the firewall package source as firewall.config. This is installed to the root file system for the image.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2020/07/16 14:47
  • by vgaetera