Linux 基礎最後一堂課練習一個網路環境,蠻有趣的,特別記錄下來
其中U-Client2比較特別,與其他台的ip網段不同,用以練習Host Route1.U-NAT:
(1)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 172.29.23.254 netmask 255.255.255.0 |
(2)vim /etc/rc.local | route add -net 172.29.23.0 netmask 255.255.255.192 gw 172.29.23.200 dev eth1 route add -net 172.29.23.64 netmask 255.255.255.192 gw 172.29.23.201 dev eth1 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
(3)vim /etc/sysctl.conf | #net.ipv4.ip_forward=1 將該行註解取消 |
2.U-Router:
(1)vim /etc/network/interfaces | auto eth0 iface eth0 inet static address 172.29.23.200 netmask 255.255.255.192 gateway 172.29.23.254 auto eth1 iface eth1 inet static address 172.29.23.62 netmask 255.255.255.192 |
(2)vim /etc/sysctl.conf | #net.ipv4.ip_forward=1 將該行註解取消 |
3.U-Client1:
(1)vim /etc/network/interfaces | auto eth0 iface eth0 inet static address 172.29.23.5 netmask 255.255.255.192 gateway 172.29.23.62 |
4.U-Client2:
說明 | 由於本機器網段10.1.1.0/24與172.29.23.192/26不同, 所以必須使用Host Route方式來使網路可通 |
(1)vim /etc/network/interfaces | auto eth0 iface eth0 inet static address 10.1.1.5 netmask 255.255.255.0 |
(2)vim /etc/rc.local | route add -host 172.29.23.254 dev eth0 route add default gw 172.29.23.254 dev eth0 |
(3)U-NAT:加入 vim /etc/rc.local | route add -host 10.1.1.5 dev eth1 |
搞定收工
沒有留言:
張貼留言