利用 Ubuntu 架設 NAT,分享給多台PC上網
#-----------------------------------
PC 端網卡設定
192.168.165.xx
255.255.255.0
192.168.165.254
DNS
168.95.1.1
#-----------------------------------
Ubuntu NAT server 架設
1. 安裝 Ubuntu Server
http://www.virtualbox.org/
http://releases.ubuntu.com/lucid/ubuntu-10.04-server-i386.iso
# 用VM安裝的 RAM 192MB 即可,安裝好後把虛擬網卡從 NAT mode 改成 Bridge mode
2. 設定 IP
sudo -i
vim /etc/network/interfaces
#--------------------------------------------------------------
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth0:1
iface eth0:1 inet static
address 192.168.165.254
netmask 255.255.255.0
#--------------------------------------------------------------
/etc/init.d/networking restart
3. 設定 NAT
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.165.0/24 ! -d 192.168.165.0/24 -j MASQUERADE
# 可以把上面兩行放到 /etc/rc.local 開機的時候執行。
#--------------------------------------------------------------
#nat 查看的指令
iptables -t nat -L -n
iptables -t nat -L -nv
完成
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment