运行iptables -L可以显示目前数据包的规则设置状态
输入iptables -F与-X可以清除所有的规则
iptables -D INPUT 3(按号码匹配)
ICMP相关应用
使自己不能ping 通 127.0.0.1
Iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP
192.168.0.0/24 网段无法ping能本机
iptables -A INPUT -s 192.168.0.0/24 -p icmp -j DROP
禁所有机器
# iptables -A INPUT -s 0/0 -p icmp -j DROP
# ICMP(PING) 接受 ! echo-request
/sbin/iptables -A INPUT -p icmp –icmp-type ! echo-request -j ACCEPT
accept_redirects
# echo “0” > /proc/sys/net/ipv4/conf/all/accept_redirects
or
# sysctl net.ipv4.conf.all.accept_redirects=”0″
禁止IP访问自己
[root@linux root]# iptables -A INPUT -s 192.168.0.111 -j DROP
封杀MSN
/sbin/iptables -I FORWARD -d gateway.messenger.hotmail.com -j DROP
/sbin/iptables -I FORWARD -p tcp –dport 1863 -j DROP
封杀QQ
/sbin/iptables -A FORWARD -p tcp -d tcpconn.tencent.com –dport 80 -j DROP
/sbin/iptables -A FORWARD -p tcp -d tcpconn.tencent.com –dport 443 -j DROP
/sbin/iptables -A FORWARD -p tcp -d tcpconn2.tencent.com -j DROP
/sbin/iptables -A FORWARD -i eth0 -p udp –dport 8000 -j DROP
封杀BT
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 6881:6890 -j DROP
WWW
# 禁止>>WWW
/sbin/iptables -A FORWARD -p tcp –dport 80 -j DROP
/sbin/iptables -A FORWARD -s 192.168.0.111 -p tcp –dport 80 -j DROP
# 开放>>WWW
/sbin/iptables -A FORWARD -p tcp –dport 80 -j ACCEPT
FTP
# 禁止FTP
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 20 -j DROP
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 21 -j DROP
# 开放FTP
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 20 -j ACCEPT
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 21 -j ACCEPT
SMTP,POP3
# 禁止SMTP,POP3
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 25 -j DROP
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 110 -j DROP
# 开入SMTP,POP3
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 25 -j ACCEPT
/sbin/iptables -A FORWARD -i eth0 -p tcp –dport 110 -j ACCEPT
Samba
# 禁止Samba
[root@linux root]# iptables -A FORWARD -p tcp –sport 137:139 -j DROP
[root@linux root]# iptables -A FORWARD -p udp –sport 137:139 -j DROP
DROP
# DROP OTHERS
/sbin/iptables -A FORWARD -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -s 192.168.1.0/24 -j DROP