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.
iptables是标准的,由Linux发行版(如Ubuntu,CentOS,Fedora,Debian等)提供的流行防火墙。iptables规则在运行时进行管理,其中添加,更改和删除了许多规则。 这些更改是临时更改,其中仅更改正在运行的配置,但不会临时保存。 在本教程中,我们将研究如何在Linux中永久保存iptables
规则。
在Debian,Ubuntu,Mint,Kali中保存Ipv4规则 (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
命令将当前的iptables规则保存到/etc/iptables/rules.v4
$ iptables-save > /etc/iptables/rules.v4
在CentOS,Fedora,RedHat中保存ipv4规则 (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
命令将当前的iptables规则保存到/etc/sysconfig/iptables
$ iptables-save > /etc/sysconfig/iptables
在Debian,Ubuntu,Mint,Kali中保存Ipv6规则 (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
我们可以使用iptables-save
命令将当前的IPv6 iptables规则保存到/etc/iptables/rules.v6
$ ip6tables-save > /etc/iptables/rules.v6
在CentOS,Fedora,RedHat中保存ipv6规则 (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
命令将当前的IPv6 iptables规则保存到/etc/sysconfig/ip6tables
$ ip6tables-save > /etc/sysconfig/ip6tables
iptables-persistent软件包,用于Debian,Ubuntu,Mint,Kali (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
Debian,Ubuntu,Kali和Mint提供了名为iptables-persistent
软件包。 该软件包将自动将iptables规则保存到/etc/iptables/rules
并在引导过程中自动加载。 该规则的名称将是rules.v4
IPv4和rules.v6
对IPv6
在Debian,Ubuntu,Mint,Kali中还原/重新加载Ipv4规则 (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
我们可以从/etc/iptables/rules.v4
使用iptables-restore
命令恢复IPv4 iptables规则。
$ iptables-restore < /etc/iptables/rules.v4
在CentOS,Fedora,RedHat中还原/重新加载Ipv4规则 (Restore/Reload Ipv4 Rules in CentOS, Fedora, RedHat)
We can restore IPv4 iptables rules with the iptables-restore
command from /etc/sysconfig/iptables
我们可以使用/etc/sysconfig/iptables
的iptables-restore
命令恢复IPv4 iptables规则
$ iptables-restore < /etc/sysconfig/iptables
在Debian,Ubuntu,Mint,Kali中还原/重新加载Ipv6规则 (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
我们可以从/etc/iptables/rules.v6
使用ip6tables-restore
命令恢复IPv6 iptables规则。
$ ip6tables-restore < /etc/iptables/rules.v6
在CentOS,Fedora,RedHat中还原/重新加载Ipv6规则 (Restore/Reload Ipv6 Rules in CentOS, Fedora, RedHat)
We can restore IPv6 iptables rules with the ip6tables-restore
command from /etc/sysconfig/ip6tables
我们可以从/etc/sysconfig/ip6tables
使用ip6tables-restore
命令恢复IPv6 iptables规则
$ ip6tables-restore < /etc/iptables/ip6tables