How To Save and Restore Iptables Rules Permanently In Ubuntu, CentOS, Fedora, Debian, Kali, Mint? – POFTUT

How To Save and Restore Iptables Rules Permanently In Ubuntu, CentOS, Fedora, Debian, Kali, Mint?


Iptables is standard and popular firewall provides by Linux distributions like Ubuntu, CentOS, Fedora, Debian etc. Iptables rules are managed in run time where a lot of rules are added, changed and remove. These changes are temporary changes where only running configuration is changed but do not saved temporarily. In this tutorial we will look how to save iptables rules permanently in Linux.

Save Ipv4 Rules in Debian, Ubuntu, Mint, Kali

We can use iptables-save command which will save the current iptables rules into /etc/iptables/rules.v4

$ iptables-save > /etc/iptables/rules.v4

Save Ipv4 Rules in CentOS, Fedora, RedHat

We can use iptables-save command which will save the current iptables rules into /etc/sysconfig/iptables

$ iptables-save > /etc/sysconfig/iptables

Save Ipv6 Rules in Debian, Ubuntu, Mint, Kali

We can use iptables-save command which will save the current IPv6 iptables rules into /etc/iptables/rules.v6

$ ip6tables-save > /etc/iptables/rules.v6

Save Ipv6 Rules in CentOS, Fedora, RedHat

We can use ip6tables-save command which will save the current IPv6 iptables rules into /etc/sysconfig/ip6tables

$ ip6tables-save > /etc/sysconfig/ip6tables

iptables-persistent Package For Debian, Ubuntu, Mint, Kali

Debian, Ubuntu, Kali and Mint provides package named iptables-persistent. This package will automatically save the iptables rules to the /etc/iptables/rules and also automatically load during boot. The rule names will be rules.v4 for IPv4 and rules.v6 for IPv6

Restore/Reload Ipv4 Rules in Debian, Ubuntu, Mint, Kali

We can restore IPv4 iptables rules with the iptables-restore command from /etc/iptables/rules.v4

$ iptables-restore < /etc/iptables/rules.v4

Restore/Reload Ipv4 Rules in CentOS, Fedora, RedHat

We can restore IPv4 iptables rules with the iptables-restore command from /etc/sysconfig/iptables

$ iptables-restore < /etc/sysconfig/iptables

Restore/Reload Ipv6 Rules in Debian, Ubuntu, Mint, Kali

We can restore IPv6 iptables rules with the ip6tables-restore command from /etc/iptables/rules.v6

$ ip6tables-restore < /etc/iptables/rules.v6

Restore/Reload Ipv6 Rules in CentOS, Fedora, RedHat

We can restore IPv6 iptables rules with the ip6tables-restore command from /etc/sysconfig/ip6tables

$ ip6tables-restore < /etc/iptables/ip6tables

LEARN MORE  What Is A Firewall and How Its Work?

Leave a Comment