# tar zxvf l7-protocols-2009-05-28.tar.gz
# cd l7-protocols-2009-05-28
# make install
# vim ~/iptables
修改内容
:%s#/sbin/$IPTABLES#/usr/sbin/$IPTABLES#g 全局替换内容
# mv ~/iptables /etc/rc.d/init.d/
# service iptables start
这样整个环境的设置就算是完成,接下来就是应用了。
5、使用l7-filter来过滤指定的流量,达到预想的设置效果:
#iptables -A FORWARD -p tcp -s 192.168.1.12 -d 192.168.1.13 -o eth0 -j DROP(禁止IP)
#iptables -A FORWARD -p tcp -s 192.168.1.11/24 -d www.qq.com -o eth0 -j DROP(禁止网段)
#安全规则类似windows防火墙
#iptables -A INPUT -p tcp –-dport 1:1024 -j DROP
#iptables -A INPUT -p udp –-dport 1:1024 -j DROP 这两条可以防止nmap探测
防止攻击扫描
防止同步包洪水(Sync Flood)
# iptables -A FORWARD -p tcp –-syn -m limit –-limit 1/s -j ACCEPT
也可以写作
#iptables -A INPUT -p tcp –-syn -m limit –-limit 1/s -j ACCEPT
–-limit 1/s 限制syn并发数每秒1次,可以根据自己的需要修改
防止各种端口扫描
# iptables -A FORWARD -p tcp –-tcp-flags SYN,ACK,FIN,RST RST -m limit –-limit 1/s -j ACCEPT
Ping洪水攻击(Ping of Death)
# iptables -A FORWARD -p icmp –-icmp-type echo-request -m limit –-limit 1/s -j ACCEPT
# Null Scan(possibly)XiKc.om
iptables -A INPUT -i eth0 -p tcp –-tcp-flags ALL NONE -j DROP
iptables NAT 策略:
#iptables -t nat -A PREROUTING -p tcp --dport 80 -d $INTERNET_ADDR -j DNAT –-to-destination 192.168.100.2
只允许访问指定的网段:
#iptables -A Filter -d www.linuxidc.com -j ACCEPT
#iptables -A Filter -d www.linuxidc.net -j ACCEPT
开放多个端口的例子:
#iptables -A Filter -p tcp -m multiport –-source-port 22,53,80,110 -s 192.168.20.3 -j REJECT
#iptables -A Filter -p tcp –source-port 2:80 -s 192.168.20.3 -j REJECT
指定时间上网
#iptables -A Filter -s 10.10.10.253 -m time –-timestart 6:00 –-timestop 11:00 –-days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j DROP
#iptables -A Filter -m time –-timestart 12:00 –-timestop 13:00 –-days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT
#iptables -A Filter -m time –-timestart 17:30 –-timestop 8:30 –-days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT
基于MAC,只能收发邮件,其它都拒绝
#iptables -I Filter -m mac –-mac-source 00:0A:EB:97:79:A1 -j DROP
#iptables -I Filter -m mac -–mac-source 00:0A:EB:97:79:A1 -p tcp --dport 25 -j ACCEPT
#iptables -I Filter -m mac –-mac-source 00:0A:EB:97:79:A1 -p tcp --dport 110 -j ACCEPT
