1.在/etc/rc.d/rc.local中加入如下

(1).如果是DHCP直接上網
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j MASQUERADE

(2).如果是ADSL撥號上網
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.1.0/24 -j MASQUERADE

(3).如果是固定IP

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT –to-source 10.4.40.13(固定IP)

2./etc/network/interfaces文件配置
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth1 up # line maintained by pppoeconf
provider dsl-provider

auto eth1
iface eth1 inet manual

auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0

3.配置客戶機網卡
iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.1

如果在上面的服務器下再接一個服務器,配置於上面基本相同,例如:

1.同上(略)

2.配置外網的網卡
iface eth0 inet static
address 192.168.1.133
netmask 255.255.255.0
gateway 192.168.1.1 //指定上一台服務器IP

3.配置內網的網卡
iface eth1 inet static
address 192.168.1.134
netmask 255.255.255.0

4.配置其它客戶機網卡
iface eth0 inet static
address 192.168.1.135
netmask 255.255.255.0
gateway 192.168.1.133 //網關



轉貼內容來源: 用Debian的Iptables作簡單路由
評論(0) | 引用(0) | 閱讀(150912)
發表評論
暱稱 [註冊]
密碼 訪客無需密碼
網址
電郵
開啟HTML 開啟UBB 開啟表情 隱藏 記住我