免费注册 查看新帖 |

Chinaunix

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

[网络相关] 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 16:41 |只看该作者
很多子站的  ,一般css,图片都不放主站,放子站,就算打开,体验也会很差。

评分

参与人数 1信誉积分 +5 收起 理由
yufeiluo + 5 很给力!

查看全部评分

论坛徽章:
0
3 [报告]
发表于 2017-02-09 21:12 |只看该作者
那如何设置?
需求:仅仅允许www.sina.com.cn 的这些ip被访问,上面的办法不可行,速度太慢,如何让速度快呢?

论坛徽章:
24
申猴
日期:2014-10-10 15:56:39射手座
日期:2014-10-10 15:57:18黑曼巴
日期:2018-05-14 11:05:122016科比退役纪念章
日期:2018-05-14 11:05:0715-16赛季CBA联赛之北控
日期:2018-05-14 11:05:0015-16赛季CBA联赛之江苏
日期:2017-02-27 18:11:0715-16赛季CBA联赛之上海
日期:2018-08-15 09:48:5415-16赛季CBA联赛之佛山
日期:2018-07-20 17:14:2315-16赛季CBA联赛之佛山
日期:2019-09-10 18:08:4615-16赛季CBA联赛之山西
日期:2020-03-26 09:40:5115-16赛季CBA联赛之佛山
日期:2020-05-08 09:03:54
4 [报告]
发表于 2017-02-13 17:57 |只看该作者
iptable有7层的模块支持,需要编译内核
而且这个模板不是官方的,也不是所有IPTABLES版本都支持
针对域名的控制还是上行为管理吧ROUTEOS也有这方面功能
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP