站长论坛

标题: 在ubuntu下配置代理服务器(iptables) [打印本页]

作者: superadmin    时间: 2007-12-4 13:52
标题: 在ubuntu下配置代理服务器(iptables)
# !/ bin / sh
echo " 1 " >/ proc / sys / net / ipv4 / ip_forward
/ sbin / modprobe ip_tables
/ sbin / modprobe ip_nat_ftp
EXTIF = ppp +
ANY = 0.0 . 0.0 / 0
LAN = 192.168 . 0.0 / 24

/ sbin / iptables - F INPUT
/ sbin / iptables - F OUTPUT
/ sbin / iptables - F FORWARD
/ sbin / iptables - F - t nat

/ sbin / iptables - P INPUT ACCEPT
/ sbin / iptables - P OUTPUT ACCEPT
/ sbin / iptables - P FORWARD ACCEPT

/ sbin / iptables - t nat - A POSTROUTING - s $LAN - o $EXTIF - j MASQUERADE

把这段shell copy到一个文件中,执行一下就能将本机作为代理服务器使用,(也可以写到/etc/init.d/rc.local中,每次开机执行)

要注意的是:客户机还需要把服务器加到路由网关中,并自己设置DNS。

命令如下:
设置路由:sudo route add gw 192.168.0.1

修改DNS:sudo gedit /etc/resolv.conf,在其中增加 nameserver xxx.xxx.x.x作为DNS服务器。




欢迎光临 站长论坛 (https://tzlink.com/bbs/) Powered by Discuz! X3.2