ubuntu下的路由实验

这个实验先演示两个client是如何通过路由器进行通信的。

我们至少需要三个虚拟机:clientA、clientB和route。


 

对clientA的网卡进行设置:

#the primary network interface

auto ens33

iface ens33 inet static

address 55.55.55.58

gateway 55.55.55.55

netmask 255.0.0.0


 

对clientB的网卡进行设置:

#the primary network interface

auto ens33

iface ens33 inet static

address 166.66.66.67

gateway 166.66.66.66

netmask 255.255.0.0


对route进行设置:

#The first network interface

auto ens33

iface ens33 inet static

address 55.55.55.55

netmask 255.0.0.0

 

#The second network interface

auto ens38

iface ens38 inet static

address 166.66.66.66

netmask 255.255.0.0 


 

进行如上配置后,结果如下:

client1:

client2:

route:

 

网络状态如下:

注意:路由器的转发功能默认是不开启的,利用“sudo sysctl -w net.ipv4.ip_forward=1”打开,否则不能转发报文。

测试:用clientA去ping clientB,可以ping的通,用clientB去ping clientA也可以ping的通。

 

posted @ 2016-10-16 11:33  zhazhalovecoding  阅读(810)  评论(0编辑  收藏  举报