- 论坛徽章:
- 0
|
我在学习iptables,设定了一条规则,任何进入和离开本机的http协议,仅仅允许对www.sina.com.cn访问。
也就是说,如果开启一个http类型的网站,这个网站不是www.sina.com.cn,就不予INPUT OUTPUT。
先看看www.sina.com
dig www.sina.com.cn
www.sina.com.cn. 3519 IN CNAME jupiter.sina.com.cn.
jupiter.sina.com.cn. 9 IN A 183.232.24.115
jupiter.sina.com.cn. 9 IN A 183.232.24.117
jupiter.sina.com.cn. 9 IN A 183.232.24.114
jupiter.sina.com.cn. 9 IN A 183.232.24.112
jupiter.sina.com.cn. 9 IN A 183.232.24.111
jupiter.sina.com.cn. 9 IN A 183.232.24.116
jupiter.sina.com.cn. 9 IN A 183.232.24.113
进行设置:
iptables -I INPUT -s 183.232.24.111 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.112 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.113 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.114 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.115 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.116 -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -s 183.232.24.117 -p tcp --sport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.111 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.112 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.113 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.114 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.115 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.116 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -d 183.232.24.117 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -p tcp --dport 80 -j DROP
iptables -I INPUT -p tcp --sport 80 -j DROP
查看:
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 183.232.24.117 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.116 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.115 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.114 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.113 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.112 anywhere tcp spt:http
ACCEPT tcp -- 183.232.24.111 anywhere tcp spt:http
DROP tcp -- anywhere anywhere tcp spt:http
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere 183.232.24.117 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.116 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.115 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.114 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.113 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.112 tcp dpt:http
ACCEPT tcp -- anywhere 183.232.24.111 tcp dpt:http
DROP tcp -- anywhere anywhere tcp dpt:http
现在打开wireshark进行测试
1.www.163.com无法访问,没有request 也没有response
2.www.sina.com.cn打开的很慢
3。http://news.sina.com.cn/gov/xlxw ... yafenm3026400.shtml ,两分钟过后,只能打开一点点
请问,为何?
|
|