这个实验先演示两个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:

ubuntu下的路由实验

client2:

ubuntu下的路由实验

route:

ubuntu下的路由实验

 

网络状态如下:

ubuntu下的路由实验

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

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

 

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2021-06-29
  • 2021-06-13
  • 2022-01-17
  • 2021-07-23
猜你喜欢
  • 2021-12-05
  • 2022-02-26
  • 2021-08-29
  • 2021-07-28
  • 2021-07-18
  • 2021-05-21
  • 2021-08-09
相关资源
相似解决方案