- 论坛徽章:
- 4
|
20可用积分
外网地址:172.19.3.2 eth0
内网地址:192.168.1.1 eth1
系统:centos 5.2
做了SNAT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j SNAT --to-source 172.19.3.2
其它机器填写网关为192.168.1.1 都可以上网
我将squid监听的端口写为 http_port 192.168.1.1:3128
然后在浏览器里将IE的代理地址写为192.168.1.1 端口为3128,无法上网。于是添加规则
/sbin/iptables -A INPUT -s 192.168.1.0/24 --dport 3128 -j ACCEP这段也就是对内网用户开放3128端口,客户机在IE浏览器里更改代理服务器地址改端口为192.168.1.1:3128 ,结果还是无法上网,于是关闭防火墙,代理服务器就可以上网了!
当前防火墙的规则
[root@www etc]# /sbin/iptables -t nat -F
[root@www etc]# /sbin/iptables -t filter -F
[root@www etc]# /sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j SNAT --to-source 172.19.3.2
[root@www etc]# /sbin/iptables -A INPUT -i eth1 -p tcp -m tcp --dport 3128 -j ACCEPT
[root@www etc]# /sbin/iptables -A OUTPUT -p tcp -m tcp -d 0/0 -j ACCEPT
[root@www etc]# /etc/init.d/iptables save
将当前规则保存到 /etc/sysconfig/iptables: [确定]
[root@www etc]# /etc/init.d/iptables restart
客户机使用网关可以上网,但使用代理就不可以上网了!这说明还是防火墙的问题!麻烦squid佬大您给帮帮忙。要解决的问题: squid监听的IP地址及端口是在内网的那块网卡上. 现在我要允许所有来自192.168.1.0/24网络的用户使用SQUID上网,其它用户禁止! iptables规则如何设置.或者弄成透明代理也行的!关闭防火墙的情况下,Squid可以正常使用.麻烦您将以下的文件改成透明代理
我的squid.conf配置文件:
#Squid Ver 2.7
http_port 192.168.1.1:3128
cache_mem 200 MB
maximum_object_size 8000 KB
maximum_object_size_in_memory 8128 KB
dns_nameservers 61.128.114.133
cache_dir ufs /var/squid/cache 8000 16 256
error_directory /usr/local/squid/share/errors/Simplify_Chinese
acl nocache urlpath_regex cookie.*\.php *\.jsp *\.asp
no_cache deny nocache
acl btfile urlpath_regex -i .torrent$
http_access deny btfile
acl notbt url_regex -i btn
http_access deny notbt
cache_access_log /var/squid/access.log
cache_log /var/squid/cache.log
cache_store_log /var/squid/store.log
acl localhost src 172.19.3.0/24
http_access allow localhost
acl local src 192.168.1.0/24
http_access allow local
acl all src 0.0.0.0/0.0.0.0
http_access deny all
acl safe port 80 21 443 3128
http_access allow safe
cache_effective_user squid
cache_effective_group squid
cache_mgr wubifans_huaxing@yahoo.com.cnvisible_hostname ProxyServer
icon_directory /usr/local/squid/share/icons
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024 |
|