|
我用的坛子上一位老兄写的iptables脚本,自己稍微改了一下。能够全部控制QQ登录不上。但是却做不到开放某一个单机可以上的情况:
我下面的脚本可以使所以的QQ都登录不上去:
#!/bin/sh
echo "Add iptables's new rules......"
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# clear iptables's rules
iptables -F
iptables -X
#ip address get
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp -d ! 192.168.0.1/24 --dport 80 -j REDIRECT --to-port 3128
#my rules
#NEW RULES
iptables -N mine
# ip address back
iptables -A mine -m state --state ESTABLISHED,RELATED -j ACCEPT
# but ppp0's datapragram
iptables -A mine -m state --state NEW -i ! ppp0 -j ACCEPT
iptables -A mine -p tcp --dport 80 -i ppp0 -j ACCEPT
iptables -A mine -p tcp --dport 22 -i ppp0 -j ACCEPT
iptables -A mine -p icmp --icmp-type echo-request -i ppp0 -j DROP
iptables -A mine -i ppp0 -m limit --limit 5/minute
iptables -A mine -j DROP
iptables -A INPUT -j mine
iptables -A FORWARD -p tcp --dport 8000 -j DROP
iptables -A FORWARD -p udp --dport 8000 -j DROP
iptables -A FORWARD -p tcp --dport 8000 -j DROP
iptables -A FORWARD -p udp --dport 8000 -j DROP
iptables -A FORWARD -p tcp --dport 4000 -j DROP
iptables -A FORWARD -p udp --dport 4000 -j DROP
iptables -A FORWARD -j mine
echo "iptables rules is OK......"
这个时候所有的QQ都登录不上去。但是如果我象下面这样写的话,所有的QQ又都可以登录上去。
#!/bin/sh
echo "Add iptables's new rules......"
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# clear iptables's rules
iptables -F
iptables -X
#ip address get
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp -d ! 192.168.0.1/24 --dport 80 -j REDIRECT --to-port 3128
#my rules
#NEW RULES
iptables -N mine
# ip address back
iptables -A mine -m state --state ESTABLISHED,RELATED -j ACCEPT
# but ppp0's datapragram
iptables -A mine -m state --state NEW -i ! ppp0 -j ACCEPT
iptables -A mine -p tcp --dport 80 -i ppp0 -j ACCEPT
iptables -A mine -p tcp --dport 22 -i ppp0 -j ACCEPT
iptables -A mine -p icmp --icmp-type echo-request -i ppp0 -j DROP
iptables -A mine -i ppp0 -m limit --limit 5/minute
iptables -A mine -j DROP
iptables -A INPUT -j mine
iptables -A FORWARD -s 192.168.0.8/24 -o ppp0 -p tcp --dport 8000 -j ACCEPT
iptables -A FORWARD -s 192.168.0.8/24 -o ppp0 -p udp --dport 8000 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8000 -j DROP
iptables -A FORWARD -p udp --dport 8000 -j DROP
iptables -A FORWARD -p tcp --dport 8000 -j DROP
iptables -A FORWARD -p udp --dport 8000 -j DROP
iptables -A FORWARD -j mine
echo "iptables rules is OK......"
这是为什么呢?请各位大大和斑竹帮忙看看。
谢谢了。 |
|