曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 3374|回复: 0
打印 上一主题 下一主题

-L(--line-numbers)/-D --- 列出规则及删除

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34395
跳转到指定楼层
楼主
发表于 2012-3-18 09:26:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
删除规则使用 -D 选项,其语法为:
iptables [-t table] -D chain rulenum
上面 chain 是“链”,即 INPUT, OUTPUT, FORWARD 此类。
rulenum 是规则序号,用 在使用 -L 选项时可搭配 --line-number 子项看到。

使用 -L 选项列出所有规则
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
ACCEPT     tcp  --  anywhere             m50-132.163.com     tcp dpt:smtp
ACCEPT     tcp  --  anywhere             m50-133.163.com     tcp dpt:smtp

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
TCPMSS     tcp  --  172.16.36.0/24       anywhere            tcp flags:FIN,SYN,RST,ACK/SYN TCPMSS set 1356
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp

搭配 --line-numbers 给列出的规则添加编号
# iptables -L --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
2    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
3    ACCEPT     tcp  --  anywhere             m50-132.163.com     tcp dpt:smtp
4    ACCEPT     tcp  --  anywhere             m50-133.163.com     tcp dpt:smtp

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    TCPMSS     tcp  --  172.16.36.0/24       anywhere            tcp flags:FIN,SYN,RST,ACK/SYN TCPMSS set 1356
2    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp

只列出 INPUT 链的规则
# iptables -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
2    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
3    ACCEPT     tcp  --  anywhere             m50-132.163.com     tcp dpt:smtp
4    ACCEPT     tcp  --  anywhere             m50-133.163.com     tcp dpt:smtp

使用 -D 选项删除指定的规则
# iptables -D INPUT 3
# iptables -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
2    ACCEPT     tcp  --  anywhere             m50-134.163.com     tcp dpt:smtp
3    ACCEPT     tcp  --  anywhere             m50-133.163.com     tcp dpt:smtp
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2025-5-7 03:00 , Processed in 0.081136 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表