当前位置: 技术问答>linux和unix
帮忙删一条规则
来源: 互联网 发布时间:2016-10-04
本文导语: [root@localhost YL]# iptables -t nat -L POSTROUTING Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- anywhere anywhere MAS...
[root@localhost YL]# iptables -t nat -L POSTROUTING
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
DROP all -- anywhere anywhere
all -- anywhere anywhere
如何删除最后和第二条规则
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
DROP all -- anywhere anywhere
all -- anywhere anywhere
如何删除最后和第二条规则
|
这样:
[root@RHEL5 sysconfig]# iptables -t nat -L -nv --line-numbers
Chain PREROUTING (policy ACCEPT 1 packets, 36 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 MASQUERADE all -- * * 197.133.133.0/24 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
[root@RHEL5 sysconfig]# iptables -t nat -D POSTROUTING 1
[root@RHEL5 sysconfig]# iptables -t nat -L -nv --line-numbers
Chain PREROUTING (policy ACCEPT 2 packets, 72 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
看明白没?
或者iptables-save > iptables.tmp1
再修改iptables.tmp1
再iptables-restore
[root@RHEL5 sysconfig]# iptables -t nat -L -nv --line-numbers
Chain PREROUTING (policy ACCEPT 1 packets, 36 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 MASQUERADE all -- * * 197.133.133.0/24 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
[root@RHEL5 sysconfig]# iptables -t nat -D POSTROUTING 1
[root@RHEL5 sysconfig]# iptables -t nat -L -nv --line-numbers
Chain PREROUTING (policy ACCEPT 2 packets, 72 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
看明白没?
或者iptables-save > iptables.tmp1
再修改iptables.tmp1
再iptables-restore