Squid 和 SNAT 上网

方法1 , squid (具体配置如之前的记录)

代理机上安装squid软件

apt-get install squid

service squid3 start

在被代理机上配置代理环境

vi /etc/profie
http_proxy=http://172.168.61.197:3128
https_proxy=http://172.168.61.197:3128
ftp_proxy=http://172.168.61.197:3128
no_proxy=172.168.61.*
export http_proxy https_proxy ftp_proxy no_proxy

source /etc/profie 让代理环境生效

 

方法2 iptables SNAT ,

在代理机上开启IP转发:

在代理机上配置伪转换:iptables -t nat -A POSTROUTING -s 172.168.173.0/26 -j MASQUERADE

在代理机上开启转换:iptables -A FORWARD -s 172.168.173.0/24 -j ACCEPT

在被代理机上改变默认路由: 指向代理机的IP

route add -net 0.0.0.0 gw xxxx

route del -net 0.0.0.0 gw xxxxold

 

posted on 2016-07-18 15:00  baxk2001  阅读(255)  评论(0编辑  收藏  举报

导航