2010年9月6日 星期一

用VMware+Ubuntu-server做網路NAT與ROUTE lab



1>NAT
(1)$sudo vim /etc/network/interfaces ;加入
auto eth0
iface eth0 inet static
address 192.168.213.5
netmask 255.255.255.0
gateway 192.168.213.2

auto eth1
iface eth1 inet static
address 192.168.120.254
netmask 255.255.255.0

(2)$sudo vim /etc/sysctl.conf
#net.ipv4.ip_forward=1
將上面那行的註解拿掉變:
net.ipv4.ip_forward=1

(3)$sudo vim /etc/rc.local
route add -net 192.168.87.0 netmask 255.255.255.0 gw 192.168.120.5 dev eth1
route add -net 192.168.160.0 netmask 255.255.255.0 gw 192.168.120.7 dev eth1
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

(4)$sudo rm /etc/udev/rules.d/70-persistent-net.rules
避免網路設備有異常,可將上列檔案刪除

(5)$ sudo reboot #重開機,NAT設定完畢

(6)顯示文字如果有問題可以做下面修正:
$sudo locale-gen 'en_US.UTF-8'
$vim .bashrc ;在最後面加入底下幾行,表示用SSH方式還是使用zh_TW

2>Router
(1)sudo vim /etc/network/interfaces ;加入
auto eth0
iface eth0 inet static
address 192.168.120.5
netmask 255.255.255.0
gateway 192.168.120.254

auto eth1
iface eth1 inet static
address 192.168.87.254
netmask 255.255.255.0

(2))$sudo vim /etc/sysctl.conf
#net.ipv4.ip_forward=1
將上面那行的註解拿掉變:
net.ipv4.ip_forward=1

(3)$sudo rm /etc/udev/rules.d/70-persistent-net.rules
避免網路設備有異常,可將上列檔案刪除

(4)$ sudo reboot #重開機,Router設定完畢

R2同樣設定方式只是IP不同

3>NS
(1)sudo vim /etc/network/interfaces ;加入
auto eth0
iface eth0 inet static
address 192.168.87.10
netmask 255.255.255.0
gateway 192.168.87.254

(2)$sudo rm /etc/udev/rules.d/70-persistent-net.rules
避免網路設備有異常,可將上列檔案刪除

NS2與NS1一樣設定方式,修改ip即可

(3)$ sudo reboot #重開機,Router設定完畢

沒有留言:

張貼留言