免费注册 查看新帖 |

Chinaunix

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

[proxy] squid+iptables 透明代理 QQ不能登录 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-25 11:37 |只看该作者 |倒序浏览
iptables配置(某个脚本文件):

#!/bin/bash
IPT="/sbin/iptables"
echo 1 > /proc/sys/net/ipv4/ip_forward

$IPT -t nat -F

$IPT -t nat -A PREROUTING -p tcp -s 172.16.0.0/16 --dport 80 -j REDIRECT --to-ports 3128
$IPT -t nat -A POSTROUTING -s 172.16.0.0/16 -d ! 172.16.0.0/16 -j MASQUERADE

#172.16.0.0/16为内网段



squid 3.0 配置 squid.conf文件

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

http_access allow localnet

http_access deny all


icp_access allow localnet
icp_access deny all

htcp_access allow localnet
htcp_access deny all

http_port 3128 transparent

hierarchy_stoplist cgi-bin ?

cache_dir ufs /cache 50000 16 256

access_log /usr/local/squid/var/logs/access.log squid

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern (cgi-bin|\?)    0       0%      0
refresh_pattern .               0       20%     4320

visible_hostname sgg-squid-server

icp_port 3130

coredump_dir /usr/local/squid/var/cache



以上配置客户段能够正常浏览网页,但是qq不能登录.
不使用squid即iptables注释掉以下行:
#  $IPT -t nat -A PREROUTING -p tcp -s 172.16.0.0/16 --dport 80 -j REDIRECT --to-ports 3128
客户端qq能够正常登录。请大虾们帮忙解决,不胜感激!


另:squid版本为 3.0.STABLE4  源代码下载编译,编译配置选项为:
$ ./configure --enable-linux-netfilter --prefix=/usr/local/squid
启动方式为:
#/usr/local/squid/sbin/squid

[ 本帖最后由 huang_xi_whu 于 2008-4-25 12:00 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-04-25 16:38 |只看该作者
自己顶一下

qq登录的错误:

【QQ  版本】Build 17.91.715
【QQ  号码】76431699
【操作系统】Microsoft Windows XP Service Pack 2 [Build 5.1.2600]

【网络设置】局域网内使用透明代理
【登录过程】
---------------------------------------------------------------------------
        开始登录......时间[2008-04-25 16:36:07]
        初始化登录服务器列表,上次的登录方式为【TCP登录方式】
        尝试指定服务器【58.251.62.77:80】...
        连接TCP服务器成功【58.251.62.77:80】
        TCP服务器【tcpconn2.tencent.com:80】需要域名解析...
        TCP服务器【tcpconn6.tencent.com:80】需要域名解析...
        TCP服务器【tcpconn3.tencent.com:80】需要域名解析...
        TCP服务器【tcpconn.tencent.com:80】需要域名解析...
        TCP服务器【tcpconn4.tencent.com:80】需要域名解析...
        TCP服务器【tcpconn5.tencent.com:80】需要域名解析...
        TCP服务器域名解析成功【tcpconn2.tencent.com:80】==>【219.133.60.246】
        连接TCP服务器成功【219.133.48.104:80】
        TCP服务器域名解析成功【tcpconn6.tencent.com:80】==>【121.14.74.247】
        TCP服务器域名解析成功【tcpconn3.tencent.com:80】==>【58.60.14.114】
        TCP服务器域名解析成功【tcpconn.tencent.com:80】==>【219.133.60.206】
        TCP服务器域名解析成功【tcpconn4.tencent.com:80】==>【58.60.15.41】
        TCP服务器域名解析成功【tcpconn5.tencent.com:80】==>【58.251.62.31】
        连接TCP服务器成功【219.133.60.246:80】
        连接TCP服务器成功【121.14.74.247:80】
        连接TCP服务器成功【58.60.14.114:80】
        连接TCP服务器成功【219.133.60.206:80】
        连接TCP服务器成功【58.60.15.41:80】
        连接TCP服务器成功【58.251.62.31:80】
        TCP登录服务器全部尝试失败
        UDP服务器【sz8.tencent.com:8000】需要域名解析...
        UDP服务器【sz4.tencent.com:8000】需要域名解析...
        UDP服务器【sz7.tencent.com:8000】需要域名解析...
        UDP服务器【sz3.tencent.com:8000】需要域名解析...
        UDP服务器【sz.tencent.com:8000】需要域名解析...
        UDP服务器【sz9.tencent.com:8000】需要域名解析...
        UDP服务器【sz6.tencent.com:8000】需要域名解析...
        UDP服务器【sz5.tencent.com:8000】需要域名解析...
        UDP服务器【sz2.tencent.com:8000】需要域名解析...
        UDP服务器域名解析成功【sz8.tencent.com:8000】==>【219.133.60.75】
        UDP服务器域名解析成功【sz4.tencent.com:8000】==>【58.60.14.97】
        UDP服务器域名解析成功【sz7.tencent.com:8000】==>【121.14.75.57】
        UDP服务器域名解析成功【sz3.tencent.com:8000】==>【219.133.49.172】
        UDP服务器域名解析成功【sz.tencent.com:8000】==>【219.133.60.22】
        UDP服务器域名解析成功【sz9.tencent.com:8000】==>【219.133.48.102】
        UDP服务器域名解析成功【sz6.tencent.com:8000】==>【58.251.63.60】
        UDP服务器域名解析成功【sz5.tencent.com:8000】==>【58.60.15.38】
        UDP服务器域名解析成功【sz2.tencent.com:8000】==>【58.60.14.43】
        TCP登录服务器全部尝试失败
        UDP登录服务器全部尝试失败,尝试下一种登录方式
        TCP登录服务器全部尝试失败
        UDP登录服务器全部尝试失败,尝试下一种登录方式
        最终登录失败,时间:2008-04-25 16:36:38

[ 本帖最后由 huang_xi_whu 于 2008-4-25 16:40 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2008-04-25 18:29 |只看该作者
squid的access log有如下错误:

209117532.067      0 172.16.222.110 NONE/400 1838 POST http://60.28.230.18:80/ HTTP1.1 - NONE/- text/html
1209117553.041      0 172.16.222.110 NONE/400 1838 POST http://60.28.230.18:80/ HTTP1.1 - NONE/- text/html
1209117637.399      0 172.16.222.110 NONE/400 1811 NONE error:unsupported-request-method - NONE/- text/html
1209117667.336   3634 172.16.222.110 TCP_MISS/200 510 POST http://58.254.39.8/ - DIRECT/58.254.39.8 application/octet-stream
1209117668.025    648 172.16.222.110 TCP_MISS/200 237 POST http://58.254.39.8/ - DIRECT/58.254.39.8 application/octet-stream
1209117668.034    643 172.16.222.110 TCP_MISS/200 221 POST http://58.254.39.17/ - DIRECT/58.254.39.17 application/octet-stream
1209117668.643   1264 172.16.222.110 TCP_MISS/200 221 POST http://58.254.39.10/ - DIRECT/58.254.39.10 application/octet-stream
1209117668.653   1273 172.16.222.110 TCP_MISS/200 221 POST http://58.254.39.10/ - DIRECT/58.254.39.10 application/octet-stream
1209117669.321    668 172.16.222.110 TCP_MISS/200 221 POST http://58.254.39.10/ - DIRECT/58.254.39.10 application/octet-stream
1209117671.539   4146 172.16.222.110 TCP_MISS/200 478 POST http://221.12.89.107/ - DIRECT/221.12.89.107 application/octet-stream
1209117675.957  38535 172.16.222.110 TCP_MISS/502 1929 POST http://221.5.8.35/ - DIRECT/221.5.8.35 text/html
1209117769.057  41619 172.16.222.110 TCP_MISS/502 1929 POST http://221.5.8.35/ - DIRECT/221.5.8.35 text/html
1209117919.667 584969 172.16.222.110 TCP_MISS/200 21397866 GET http://softdl.tech.qq.com/soft/21/QQ2007II.zip - DIRECT/60.28.232.82 application/octet-stream
1209118054.007      0 172.16.222.110 NONE/400 1838 POST http://60.28.230.18:80/ HTTP1.1 - NONE/- text/html
1209118075.068      0 172.16.222.110 NONE/400 1838 POST http://60.28.230.18:80/ HTTP1.1 - NONE/- text/html
1209118289.187      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209118304.457   1041 172.16.222.110 TCP_MISS/502 1650 GET http://repair.qq.com/getxml - DIRECT/58.61.33.32 text/html
1209118305.470    994 172.16.222.110 TCP_MISS/502 1650 GET http://repair.qq.com/getxml - DIRECT/58.61.33.32 text/html
1209118306.560   1086 172.16.222.110 TCP_MISS/502 1650 GET http://repair.qq.com/getxml - DIRECT/58.61.33.32 text/html
1209118538.990      1 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209118538.990      1 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html

论坛徽章:
0
4 [报告]
发表于 2008-04-25 22:42 |只看该作者
如果你能把下面这行换一下,我想你会把QQ登陆上的
$IPT -t nat -A POSTROUTING -s 172.16.0.0/16 -d ! 172.16.0.0/16 -j MASQUERADE
换成
$IPT -t nat -A POSTROUTING -s 172.16.0.0/16 -o eth0(外网网卡) -j SNAT --to A.B.C.D(外网的IP)

论坛徽章:
0
5 [报告]
发表于 2008-04-25 23:59 |只看该作者
原帖由 fuyankuncn 于 2008-4-25 22:42 发表
如果你能把下面这行换一下,我想你会把QQ登陆上的
$IPT -t nat -A POSTROUTING -s 172.16.0.0/16 -d ! 172.16.0.0/16 -j MASQUERADE
换成
$IPT -t nat -A POSTROUTING -s 172.16.0.0/16 -o eth0(外网网卡) -j ...

还是不行 ,我发现每次登录qq不成功的时候access log里总有一个错误,如下:
1208860581.101      0 172.16.222.110 NONE/400 1811 NONE error:unsupported-request-method - NONE/- text/html
1208860581.118      0 172.16.222.110 NONE/400 1811 NONE error:unsupported-request-method - NONE/- text/html
1209117637.399      0 172.16.222.110 NONE/400 1811 NONE error:unsupported-request-method - NONE/- text/html
1209118289.187      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209118538.990      1 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209118538.990      1 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209119555.290      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209136183.925      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209137971.327      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209138238.777      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209138620.576      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
1209139027.963      0 172.16.222.110 NONE/400 1810 NONE error:unsupported-request-method - NONE/- text/html
是不是qq使用了80端口但使用的非http协议啊?

论坛徽章:
0
6 [报告]
发表于 2008-08-01 16:50 |只看该作者
解决没有啊,是不QQ使用了80端口,但http请求又符合标准,我也遇到了同样的问题。QQ乱开发协议,迟早会垮掉的。

论坛徽章:
0
7 [报告]
发表于 2008-08-07 10:46 |只看该作者
呵呵,,好东西呀,,QQ是想不断地冲出新围墙,可始终还是要走协议的吧...

论坛徽章:
0
8 [报告]
发表于 2013-01-16 15:21 |只看该作者
本帖最后由 netmwd 于 2013-01-16 15:21 编辑

需要加上 never_direct allow all
刚测试成功

论坛徽章:
0
9 [报告]
发表于 2013-01-17 09:23 |只看该作者
所有请求转发至代理..   8楼,这个安全么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP