免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2135 | 回复: 1
打印 上一主题 下一主题

[网络相关] iptables的规则为何使得上网速度超级慢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-02-08 18:52 |显示全部楼层 |倒序浏览
我在学习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 ,两分钟过后,只能打开一点点





请问,为何?

wireshark.png (94 KB, 下载次数: 37)

wireshark.png

论坛徽章:
0
2 [报告]
发表于 2017-02-09 21:12 |显示全部楼层
那如何设置?
需求:仅仅允许www.sina.com.cn 的这些ip被访问,上面的办法不可行,速度太慢,如何让速度快呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP