LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1581|回复: 5

使用Squid的透明代理,QQ总是掉线

[复制链接]
发表于 2006-3-18 17:57:04 | 显示全部楼层 |阅读模式
家里的一台ubuntu breezy机器做NAT服务器,用Squid+iptables又设置了一个透明代理
其他程序都使用正常,而QQ却每过几分钟掉线一次,总要自动重新连接
如果把iptables里面redirect取消掉,直接连,就没有这个问题

现在我只好在前面加几句,让QQ总是直接连,变成:
iptables -t nat -A PREROUTING -d 218.17.209.23 -p tcp -j RETURN
iptables -t nat -A PREROUTING -d 219.133.48.0/24 -p tcp -j RETURN
iptables -t nat -A PREROUTING -d 219.133.49.0/24 -p tcp -j RETURN
iptables -t nat -A PREROUTING -p tcp --dport www -j REDIRECT --to-port 3128
其中那几个ip是从QQ登录时选择的服务器得到的
这样就又正常了

另外,如果QQ登录时选择使用http代理,设为Squid的那台机器的ip,也不会有掉线的个问题

有人知道是怎么回事么?


后面附上我的squid.conf

http_port 3128

cache_mem 110 MB
cache_swap_low 90
cache_swap_high 95

cache_dir ufs /var/spool/squid 3000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log

maximum_object_size 40960 KB
maximum_object_size_in_memory 1024 KB
emulate_httpd_log on
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024
forwarded_for off

httpd_accel_port 80
httpd_accel_host virtual
httpd_accel_with_proxy on
httpd_accel_single_host off
httpd_accel_uses_host_header on


# ACCESS CONTROLS
# -----------------------------------------------------------------------------
acl all                 src     0.0.0.0/0
acl homenet             src     10.0.0.0/24
acl manager             proto   cache_object
acl localhost           src     127.0.0.1/32
acl to_localhost        dst     127.0.0.0/8
acl SSL_ports           port    443 563                 # https, snews
acl SSL_ports           port    873                     # rsync
acl Safe_ports          port    80                      # http
acl Safe_ports          port    21                      # ftp
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 Safe_ports          port    631                     # cups
acl Safe_ports          port    873                     # rsync
acl Safe_ports          port    901                     # SWAT
acl purge               method  PURGE
acl CONNECT             method  CONNECT

http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny to_localhost
http_access allow homenet
http_access deny all

http_reply_access allow all
icp_access allow all

cache_effective_user proxy
cache_effective_group proxy
visible_hostname SquidProxy

error_directory /usr/share/squid/errors/Simplify_Chinese
发表于 2006-3-18 20:38:50 | 显示全部楼层
最好能够看看你的防火墙脚本!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-3-18 21:29:11 | 显示全部楼层
#!/bin/bash

LOCALHOST='192.168.44.113'
INNERNET='10.0.0.0/24'
SEDNET='192.168.15.0/24'
ADMIP='192.168.15.22'

HOME_MAC1='00:0B:6A:27:4B:CB'
HOME_MAC2='00:0C:6E:AC:BD:22'

TENCENT1='218.17.209.23'
TENCENT2='219.133.48.0/24'
TENCENT3='219.133.49.0/24'

modprobe ip_conntrack_ftp
modprobe ip_nat_ftp


iptables -F
iptables -F -t nat
iptables -F -t mangle
iptables -X
iptables -X -t nat
iptables -X -t mangle
iptables -Z
iptables -Z -t nat
iptables -Z -t mangle

iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m mac --mac-source $HOME_MAC1 -j ACCEPT
iptables -A INPUT -m mac --mac-source $HOME_MAC2 -j ACCEPT
iptables -A INPUT -s $ADMIP -j ACCEPT

iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --sport domain -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
iptables -A INPUT -s $SEDNET -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT

iptables -A INPUT -p udp -m multiport --dport netbios-ns,netbios-dgm -j ACCEPT
iptables -A INPUT -p tcp --dport netbios-ssn -j ACCEPT
iptables -A INPUT -p tcp --dport microsoft-ds -j ACCEPT
iptables -A INPUT -p tcp -s $SEDNET -m multiport --dport ftp,ftp-data -j ACCEPT

iptables -t nat -A POSTROUTING -s $INNERNET -j MASQUERADE

iptables -t nat -A PREROUTING  -d $TENCENT1 -p tcp -j RETURN
iptables -t nat -A PREROUTING  -d $TENCENT2 -p tcp -j RETURN
iptables -t nat -A PREROUTING  -d $TENCENT3 -p tcp -j RETURN

iptables -t nat -A PREROUTING  -s $INNERNET -p tcp --dport www -j REDIRECT --to-port 3128
回复 支持 反对

使用道具 举报

发表于 2006-3-20 16:12:20 | 显示全部楼层
Post by solarix


iptables -A INPUT -p udp -m multiport --dport netbios-ns,netbios-dgm -j ACCEPT
iptables -A INPUT -p tcp --dport netbios-ssn -j ACCEPT
iptables -A INPUT -p tcp --dport microsoft-ds -j ACCEPT
iptables -A INPUT -p tcp -s $SEDNET -m multiport --dport ftp,ftp-data -j ACCEPT

iptables -t nat -A POSTROUTING -s $INNERNET -j MASQUERADE

iptables -t nat -A PREROUTING  -d $TENCENT1 -p tcp -j RETURN
iptables -t nat -A PREROUTING  -d $TENCENT2 -p tcp -j RETURN
iptables -t nat -A PREROUTING  -d $TENCENT3 -p tcp -j RETURN

iptables -t nat -A PREROUTING  -s $INNERNET -p tcp --dport www -j REDIRECT --to-port 3128


偷偷的问下均几句作什么用的
回复 支持 反对

使用道具 举报

发表于 2006-8-25 21:47:48 | 显示全部楼层
我也遇到这样的问题
回复 支持 反对

使用道具 举报

发表于 2006-8-27 23:14:59 | 显示全部楼层
你得添加一句:

iptables -A INPUT -s 你的内网IP段 -p tcp --dport 3128 -j ACCEPT

然后再去掉
iptables -t nat -A PREROUTING -d $TENCENT1 -p tcp -j RETURN
iptables -t nat -A PREROUTING -d $TENCENT2 -p tcp -j RETURN
iptables -t nat -A PREROUTING -d $TENCENT3 -p tcp -j RETURN
这三行,再试试


还有,按照你上面的脚本分析,你就是将客户端设置成使用你的代理机的IP作为代理,也是不能访问的,因为你不允许3128端口的数据包进入。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表