Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4010276
  • 博文数量: 366
  • 博客积分: 9916
  • 博客等级: 中将
  • 技术积分: 7195
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-29 23:27
个人简介

简单!

文章分类

全部博文(366)

文章存档

2013年(51)

2012年(269)

2011年(46)

分类: LINUX

2013-07-12 15:39:08

#添加流入/出的iptables规则
  1. $ iptables -I INPUT -d 192.168.1.100
  2. $ iptables -I OUTPUT -s 192.168.1.100

#查看流量

  1. $ iptables -nvx -L

#清除规则

  1. $ iptables -F

  1. $ iptables -I FORWARD -s 192.168.1.100 -j ACCEPT
  2. $ iptables -I FORWARD -d 192.168.1.100 -j ACCEPT

  1. $ sudo iptables -t filter -A INPUT -p all -s 174.121.79.132 -j ACCEPT
  2. $ sudo iptables -t filter -A OUTPUT -p all -d 174.121.79.132 -j ACCEPT


删除规则的方法

方法一的语法是:
iptables -D chain rulenum [options]

其中, chain是链的意思,就是INPUT FORWARD 之类的;rulenum 是规则的编号,从1 开始,可以使用--line-numbers 列出规则的编号。比如列出INPUT 链所有的规则

  1. $ iptables -L INPUT --line-numbers

  2. num target prot opt source destination
  3. 1 REJECT tcp -- anywhere anywhere tcp dpt:microsoft-ds reject-with icmp-port-unreachable
  4. 2 REJECT tcp -- anywhere anywhere tcp dpt:135 reject-with icmp-port-unreachable
  5. 3 REJECT tcp -- anywhere anywhere tcp dpt:netbios-ssn reject-with icmp-port-unreachable
  6. 4 REJECT udp -- anywhere anywhere udp dpt:microsoft-ds reject-with icmp-port-unreachable
  7. 5 REJECT udp -- anywhere anywhere udp dpt:135 reject-with icmp-port-unreachabl

删除指定行规则:
  1. $ iptables -D INPUT 4

如果要连续删除多条规则,记得NUM编号要从大向小去删除,因为每删除一条都会导致被删条目之后的行号变化。删一条就iptables -L 再确认一下行号,是比较稳妥的方法。


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

阅读(7968) | 评论(0) | 转发(0) |
0

上一篇:Base64编码解码算法

下一篇:链栈

给主人留下些什么吧!~~