[OpenWrt Wiki] Firewall overview (2024)

Table of Contents
Purpose Process control References

OpenWrt uses the firewall4 (fw4) netfilter/nftables rule builder application.It runs in user-space to parse a configuration file into a set of nftables rules, sending each to the kernel netfilter modules.

Purpose

The netfilter rule set can be very complex for a typical router.This is by necessity; each rule is tailored to a discrete capability provided by the router to protect its supported networks, provide NAT to conserve scarce IPv4 addresses, even mangle the packets during routing.A typical router has over 100 rules designed to support packet routing.

The fw4 application is used by OpenWRT to “safely” construct a rule set while hiding much of the details.

On inspecting the netfilter rule set using fw4 print, you will see a number of netfilter/nftables rules either not explicitly defined in the firewall configuration files, or more difficult to understand (thank goodness for the --comment match!)The netfilter rules include:

The firewall configuration is fairly straight forward and automatically provides the router with a base rule set of rules and an understandable configuration file for additional rules.

The rules consumed by netfilter are, at best, difficult to comprehend due to the exacting nature of netfilter.However, every rule provides desired capability or blocks malicious capability, and therefore necessary.

Process control

fw4 is managed by the firewall service.The shell script accepts the followingset of arguments:

  • boot: this is invoked during system init (bootup)

  • start: parse configuration files and write to the netfilter kernel modules

  • stop: flush configuration rules from the kernel modules (they will not be unloaded)

  • restart, reload: read the netfilter rules from the kernel, replace using the configuration files, and write back to the netfilter kernel modules.

  • flush: (dangerous) delete all rules, delete non-default chains, and reset default policies to ACCEPT.

In some cases, the argument will be accompanied by additional flags to suppress log messages, or calls to internal functions as described above to verify the configuration files.

[OpenWrt Wiki] Firewall overview (1) When invoking stop, only the rules in the configuration files will be flushed.Those rules automatically generated by fw4 will be retained.

[OpenWrt Wiki] Firewall overview (2) If all the rules are flushed by invoking flush, the default policy is set to ACCEPT and the router will pass all packets to, or forward on, to the destination network, providing no security.

In cases where the router becomes inaccessible due to DROP set as the default policy, access can be restored through one of two methods:

References

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

[OpenWrt Wiki] Firewall overview (2024)
Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6238

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.