默认情况下,iptables-save会导出所有的表和链到标准输出中
$ iptables-save
# Generated by iptables-save v1.4.21 on Mon Aug 8 10:51:28 2022
*nat
:PREROUTING ACCEPT [264:21272]
:INPUT ACCEPT [5:356]
:OUTPUT ACCEPT [403:30153]
:POSTROUTING ACCEPT [403:30153]
:OUTPUT_direct - [0:0]
:POSTROUTING_ZONES - [0:0]
:POSTROUTING_ZONES_SOURCE - [0:0]
:POSTROUTING_direct - [0:0]
:POST_public - [0:0]
:POST_public_allow - [0:0]
:POST_public_deny - [0:0]
:POST_public_log - [0:0]
:PREROUTING_ZONES - [0:0]
:PREROUTING_ZONES_SOURCE - [0:0]
:PREROUTING_direct - [0:0]
:PRE_public - [0:0]
:PRE_public_allow - [0:0]
:PRE_public_deny - [0:0]
:PRE_public_log - [0:0]
...
可以将它们输出到文件中
iptables-save > iptables_bak
想要再次进行恢复,iptables-restore即可:
iptables-restore < iptables_bak
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/279589.html