Chinaunix首页 | 论坛 | 博客
  • 博客访问: 294640
  • 博文数量: 70
  • 博客积分: 1990
  • 博客等级: 上尉
  • 技术积分: 686
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-02 08:52
文章分类

全部博文(70)

文章存档

2015年(2)

2014年(9)

2013年(2)

2012年(20)

2011年(1)

2010年(36)

分类: LINUX

2010-11-30 21:40:11

Iptables 指南 1.1.19

1.ip_conntrack状态

防火墙看到请求包就将连接置为NEW,看到应答包就将连接置为ESTABLISHED状态。

 

2.ICMP返回的“网络不可达”信息是在试图连接某台主机时不成功(可能该主机已经关闭)时,数据包所到达的最后一台路由器返回

的。这时候的ICMP状态时RELATED

 

3.iptables 3个表,mangle,nat,Filter,默认的表是Filter

 

4.Filter表的3个内建链:INPUT,FORWORD,OUTPUT.

见上面图片。

 

5.iptables使用举例:

iptables 使用(环境:CPE的端口21-23已经映射到本地PC的21-23端口)
1. iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:30005
ACCEPT     all  --  anywhere             224.0.0.0/3        
ACCEPT     all  --  anywhere             224.0.0.0/3        
REDIRECT_FIRST_HTTP  tcp  --  192.168.1.0/24      !192.168.1.1         tcp dpt:www
DNAT       tcp  --  anywhere             anywhere            tcp dpts:ftp:telnet to:192.168.1.2
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:2121 redir ports 21
DNAT       all  --  anywhere             anywhere            to:192.168.1.2
DNAT       tcp  --  anywhere             anywhere            tcp dpt:44500 to:192.168.1.2:44500-0
DNAT       tcp  --  anywhere             anywhere            tcp dpt:44501 to:192.168.1.2:44501-0
DNAT       udp  --  anywhere             192.168.1.1         udp dpt:domain to:172.24.11.10

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination        
MASQUERADE  all  --  192.168.1.0/24       anywhere           

Chain OUTPUT (policy ACCEPT)

2. iptables -t filter  -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:9080
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:30006
urlfilter  tcp  --  anywhere             anywhere            tcp dpt:30005
ACCEPT     2    --  anywhere             anywhere           
ACCEPT     udp  --  anywhere             anywhere            udp dpt:tftp
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
ACCEPT     2    --  anywhere             anywhere           
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
LOG        tcp  --  anywhere             anywhere            tcp flags:SYN,RST,ACK/SYN limit: avg 6/hour burst 5 LOG level alert prefix `Intrusion -> '
DROP       all  --  anywhere             anywhere           
           tcp  --  anywhere             anywhere           
           tcp  --  anywhere             anywhere           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             192.168.1.2         tcp dpt:44501
ACCEPT     tcp  --  anywhere             192.168.1.2         tcp dpt:44500
ACCEPT     all  --  anywhere             192.168.1.2        
ACCEPT     tcp  --  anywhere             192.168.1.2         tcp dpts:ftp:telnet
ACCEPT     all  --  anywhere             224.0.0.0/3        
ACCEPT     all  --  anywhere             224.0.0.0/3        
ACCEPT     all  --  anywhere             192.168.1.0/24     
DROP       all  --  anywhere             anywhere           
ACCEPT     all  --  anywhere             192.168.1.0/24     
DROP       all  --  anywhere             anywhere           
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
DROP       all  --  anywhere             anywhere           
           all  --  anywhere             anywhere           
           all  --  anywhere             anywhere           
           all  --  anywhere             anywhere           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        
DROP       all  --  anywhere             239.255.255.250    

Chain urlfilter (1 references)
target     prot opt source               destination        
QUEUE      tcp  --  anywhere             anywhere            tcp dpt:30005

target     prot opt source               destination  

 

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

上一篇:linux技术小结

下一篇:C专家编程笔记

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