–F 
#删除已经存在的规则 

iptables -P INPUT DROP 
#配置默认的拒绝规则。基本规则是:先拒绝所有的服务,然后根据需要再添加新的规则。 

iptables -A INPUT -p tcp --dport 80 -j ACCEPT 
#打开WEB服务端口的tcp协议 

iptables -A INPUT -p tcp --dport 110 -j ACCEPT 
#打开POP3服务端口的tcp协议 

iptables -A INPUT -p tcp --dport 25 -j ACCEPT 
#打开SMTP服务端口的tcp协议 

iptables -A INPUT -p tcp --dport 21 -j ACCEPT 
#打开FTP服务端口的tcp协议 

iptables -A INPUT -p tcp -s 202.106.12.130 --dport 22 -j ACCEPT 
#允许IP地址为202.106.12.130这台主机连接本地的服务端口 

iptables -A INPUT -p tcp --dport 53 -j ACCEPT 
#允许DNS服务端口的tcp数据包流入 

iptables -A INPUT -p udp --dport 53 -j ACCEPT 
#允许DNS服务端口的udp数据包流入 

iptables -A INPUT -p icmp -icmp-type echo-request -i eth1 -j DROP 
#防止死亡之ping,从接口eth1进入的icmp协议的请求全部丢弃。 

iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT 
#防止SYN Flood (拒绝服务攻击)

iptables -t nat -A POSTROUTING -o eth1 -s 192.168.0.226 -j MASQUERADE
#允许 192.168.0.226通过eth1 IP伪装出外网

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.4 -p tcp --dport 25 -j MASQUERADE
#允许 192.168.0.4通过eth0 伪装访问外网的 25端口
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。