用squid+iptable做透明代理出现DNS问题

王朝厨房·作者佚名  2007-01-02
宽屏版  字体: |||超大  

配置方法:

[quote:2f931843da]

用squid+iptable实现透明代理

squid和iptable的具体安装我在此不做太多说明,一般看看它们的说明即可。我公司用一台机器作为代理上网。eth0连接外部网,eth1连接内部网。下面把我的配置写下来。

iptable的配置,在/etc/rc.d/目录下用touch命令建立firewall文件,执行chmod u+x firewll以更改文件属性,编辑/etc/rc.d/rc.local文件,在末尾加上/etc/rc.d/firewall以确保开机时能自动执行该脚本。

echo "starting ip forward"

echo 1 >/proc/sys/net/ipv4/ip_forward

echo "starting iptables rules"

modprobe ip_tables

modprobe ip_nat_ftp

/sbin/iptables -F -t nat

iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128 #将所有80端口的包转发到3128端口

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE #对eth0端口进行欺骗

squid的配置

http_port 3128

cache_mem 512 M

cache_swap_low 75

cache_swap_high 95

maximum_object_size 1024 KB

cache_dir ufs /usr/local/squid/cache 60000 16 256

cache_access_log /var/squid/logs/access.log

cache_log /dev/null

cache_store_log none

debug_options ALL,1

icp_access allow all

icp_query_time out 2000

cache_effective_user nobody

cache_effective_group nogroup

httpd_accel_host virtual

httpd_accel_port 80

httpd_accel_with_proxy on

httpd_accel_uses_host_header on

acl all src 0.0.0.0/0

acl localnet src 10.0.0.0/20

http_access allow localnet

http_access deny all

acl QUERY urlpath_regex -i cgi-bin \? \.exe$ \.zip$ \.mp3$ \.mp2$ \.rm$ \.avi$

no_cache deny QUERY

reference_age 3 days

quick_abort_min 16 KB

quick_abort_max 16 KB

quick_abort_pct 95

connect_timeout 60 seconds

read_timeout 3 minutes

request_timeout 30 seconds

client_lifetime 30 seconds

half_closed_clients off

pconn_timeout 60 seconds

ident_timeout 10 seconds

shutdown_lifetime 10 seconds

memory_pools off

memory_pools_limit 0

[/quote:2f931843da]

其中reference_age 3 days,ident_timeout 10 seconds两行出错:

[quote:2f931843da]

2005/03/03 15:09:34| parseConfigFile: line 3379 unrecognized: 'reference_age 3 days'

2005/03/03 15:34:57| parseConfigFile: line 1645 unrecognized: 'ident_timeout 10 seconds'[/quote:2f931843da]

透明代理可以实现,但是DNS有问题,在客户端浏览器输入IP可以访问外网,输入域名就不行,在客户端命令行模式下执行nslookup命令,提示

[code:1:2f931843da]DNS request time out[/code:1:2f931843da]

在squid.conf中加入

[code:1:2f931843da]

acl Safe_ports port 53 # dns[/code:1:2f931843da]故障依旧

请大侠帮助看看如何处理,谢谢!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有