单位通过共享ADSL上网,为提升上网速度,所以开启了squid透明代理。
拔号机器192.168.3.254上/etc/sysconfig/iptables配置如下:
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3128 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
*nat
-A POSTROUTING -o ppp0 -j MASQUERADE
-A PREROUTING -p tcp -d 192.168.3.254 --dport 80 -j REDIRECT --to-port 3128
COMMIT
另在/etc/rc.d/rc.local中开启了ip_forward
echo 0>/proc/sys/net/ipv4/ip_forward
最终目的: (1)想让内网的WEB请求直接转发到squid(3128)上,在squid上来进行权限控制(web权限)。
(2)内网用户web(80)以外的请求,通过网络地址转换(NAT)来实现,通过iptables来控制相应的用户权限。
上述配置的最终结果如下:内网用户不用在IE上设置代理即可上网,但通过在网关上用iptables -t nat -vnL观察数据流并没有通过squid.而是直接通过NAT(-A PREROUTING -p tcp -d 192.168.3.254 --dport 80 -j REDIRECT --to-port 3128这一句没有起作用)
期待哪位高人能帮忙指点,感激不尽。
--------------------next---------------------
阅读(513) | 评论(0) | 转发(0) |