ubuntu做路由器

解决方法:
1,设定eth0做lan,
sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.10.1
netmask 255.255.255.0

2,设定eth1做wan,dhcp.
auto eth1
iface eth1 inet dhcp

3,设定一条NAT rule,加入到/etc/rc.local文件中.
iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth1 -j SNAT MASQUERADE


4,开启IP转发
修改/etc/sysctl.conf,取消这一行的注释: 
net.ipv4.ip_forward= 1
然后使之立即生效
sudo sysctl -p
posted @ 2012-06-22 20:41  feiling  阅读(1179)  评论(0编辑  收藏  举报