Iptables

From Alpine Linux

Iptables is a generic firewalling software that allows you to define rulesets. Each rule within an IP table consists of a number of classifiers (iptables matches) and one connected action (iptables target). iptables is the userspace command line program used to configure the Linux 2.4.x and later packet filtering ruleset. It is targeted towards system administrators.


Install iptables/ip6tables

  • To install iptables (includes ip6tables in alpine 3.19 and up):

# apk add iptables

  • To install ip6tables (Alpine older than 3.19 only):

# apk add ip6tables

  • To install the man pages for iptables and ip6tables:

# apk add iptables-doc

Configure iptables/ip6tables

Save Firewall Rules

For iptables

  1. Set iptables to start on reboot
    • # rc-update add iptables

  2. Write the firewall rules to disk
    • # rc-service iptables save

  3. If you use Alpine Local Backup:
    1. Save the configuration
      • # lbu ci

For ip6tables

  1. Set ip6tables to start on reboot
    • # rc-update add ip6tables

  2. Write the firewall rules to disk
    • # rc-service ip6tables save

  3. If you use Alpine Local Backup:
    1. Save the configuration
      • # lbu ci

See also

Official website