首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Iptables 下令实例

2012-10-19 
Iptables 命令实例iptables -h ? 查看iptables 帮组命令?-A ?Append to chain?-D ?Delete matching rule f

Iptables 命令实例

iptables -h ? 查看iptables 帮组命令

?

-A ?Append to chain?

-D ?Delete matching rule from chain

-I ? Insert in chain as rulenum (default 1=first)

-R ?Replace rule rulenum (1=first)

-L ? List the rules in a chain or all chains

-F ? Delete all rules in chain or all chains?

-Z ? Zero counters in chain or all chains

-N ? Create a new user-defined chain

-X ? Delete a user-defined chain

-P ? Change policy on chain to target?

?

Options:

?

-p ?protocol:by number or name,eg 'tcp'

?

-s ?address source specification

?

-d ?address destination specification

?

-i ?input name ?network interface name?

?

-j target target for rule

?

?

iptables规则的删除-怎么删除一条已有的iptables规则

? ? 在学习IPTABLES命令时,往往只有怎么往链里添加规则,并没有说怎么删除规则,而在实际的使用时。删除规则也很常用的。
? ? 在网上找了一下,删除规则的命令方法:
语法是: iptables -D chain rulenum [options]
? ? 其中: chain 是链的意思,就是INPUT FORWARD 之类的定语
? ? rulenum 是该条规则的编号。从1开始。可以使用iptables -L INPUT --line-numbers列出指定的链的规则的编号来。

? ? 所以,例如上面要删除一个INPUT链的规则的话可以这样:
? ? iptables -D INPUT 3
? ? 意思是删除第3条规则。

? ? 还有第二种方法
? ? 第二种办法是 -A 命令的映射,不过用-D替换-A。当你的链中规则很复杂,而你不想计算它们的编号的时候这就十分有用了。
? ? 也就是说,你如何一开始时用iptables -A.... 语句定义了一个规则,那么删除此条规则时直接用 -D 来代替- A, 其余的都不变即可,而不需要什么编号了。

? ? ======================

? ? 说一下上面的 --line-numbers 选项,如下面的命令:
iptables -L INPUT --line-numbers? 列出INPUT 链所有的规则
num? target? ? prot opt source? ? ? ? ? ? ? destination? ? ? ??
1? ? REJECT? ? tcp? --? anywhere? ? ? ? ? ? anywhere? ? ? ? ? ? tcp dpt:microsoft-ds reject-with icmp-port-unreachable?
2? ? REJECT? ? tcp? --? anywhere? ? ? ? ? ? anywhere? ? ? ? ? ? tcp dpt:135 reject-with icmp-port-unreachable?
3? ? REJECT? ? tcp? --? anywhere? ? ? ? ? ? anywhere? ? ? ? ? ? tcp dpt:netbios-ssn reject-with icmp-port-unreachable?
4? ? REJECT? ? udp? --? anywhere? ? ? ? ? ? anywhere? ? ? ? ? ? udp dpt:microsoft-ds reject-with icmp-port-unreachable?
5? ? REJECT? ? udp? --? anywhere? ? ? ? ? ? anywhere? ? ? ? ? ? udp dpt:135 reject-with icmp-port-unreachable?
...
...
? ? 删除指定的第4行规则:
iptables -D INPUT 4

?

? (1)禁止ip为192.168.0.244的计算机访问人人网

?

? iptables -A FORWARD -s 192.168.0.224 -d www.renren.com -j DROP

?

?

? ?(2)删除INPUT第二行规则

iptables -D INPUT 2

?

热点排行