iptables 基础知识介绍(构造相关命令参数等):
http://tech.anquan365.com/application/other/201201/167224.html
删除或者修改某条chain时举例:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8080
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:11211 #欲删除的chain
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8080
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:11211 #欲删除的chain
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited #新添加的chain需要放在 这一条前面才有效。
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
例如上面要删除一个INPUT链的规则的话可以这样:
iptables -D INPUT 4
意思是删除第4条规则。
还有第二种方法
第二种办法是 -A 命令的映射,不过用-D替换-A。当你的链中规则很复杂,而你不想计算它们的编号的时候这就十分有用了。
也就是说,你如何一开始时用iptables -A.... 语句定义了一个规则,那么删除此条规则时直接用 -D 来代替- A, 其余的都不变即可,而不需要什么编号了。
iptables的实例分析:
http://blog.chinaunix.net/uid-263488-id-2138186.html