Install Iptables On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora And Raspbian

Install Iptables On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora And Raspbian

iptables

Program that allows configuration of tables, chains and rules provided by the Linux kernel firewall.

Maintainer: Debian Netfilter Packaging Team



Section: net

Install iptables

  • Debian apt-get install iptables Click to copy
  • Ubuntu apt-get install iptables Click to copy
  • Alpine OS apk add iptables Click to copy
  • Arch Linux pacman -S iptables Click to copy
  • Kali Linux apt-get install iptables Click to copy
  • CentOS yum install iptables Click to copy
  • Fedora dnf install iptables Click to copy
  • Raspbian apt-get install iptables Click to copy

Program that allows configuration of tables, chains and rules provided by the Linux kernel firewall.

How to use iptables?

Below are few example commands for iptables that you can use in the terminal.

View chains, rules, and packet/byte counters for all tables:
sudo iptables -vnLClick to copy
Set chain policy rule:
sudo iptables -P chain ruleClick to copy
Append rule to chain policy for IP:
sudo iptables -A chain -s ip -j ruleClick to copy
Append rule to chain policy for IP considering protocol and port:
sudo iptables -A chain -s ip -p protocol --dport port -j ruleClick to copy
Delete chain rule:
sudo iptables -D chain rule_line_numberClick to copy
Save iptables configuration of a given table to a file:
sudo iptables-save -t tablename > path/to/iptables_fileClick to copy
Restore iptables configuration from a file:
sudo iptables-restore < path/to/iptables_fileClick to copy
Installing iptables command is simple. just copy one of the above commands for your operating system and paste it into terminal. This command is available for Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora and Raspbian operating systems. Once you run the command it will install the latest version of iptables 2026 package in your OS.