路由实验

路由拓扑:
在这里插入图片描述
实验环境:
3台centos 8、一台centos 6 、一台centos 7
centos 6处于vmnet 11网段
router 1:处于vmnet 11和12网段(网络适配器为自定义)
router 2:处于vmnet 12和13网段(网络适配器为自定义)
router 3:处于vmnet 13和14网段(网络适配器为自定义)

centos 6上:

[root@centos6 ~]#cd /etc/sysconfig/network-scripts/
[root@centos6 ~]#vim ifcfg-eth0
DEVICE=eth0
NAME=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.0.100
PREFIX=16
GATEWAY=172.16.0.200

 [root@centos6 ~]#service network restart
 [root@centos6 ~]#ip a

centos 8.1上:

[root@centos8 ~]#cd /etc/sysconfig/network-scripts/
[root@centos8 ~]#vim ifcfg-eth0
DEVICE=eth0
NAME=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.0.200
PREFIX=16

[root@centos8 ~]#cp  ifcfg-eth0 ifcfg-eth1
[root@centos8 ~]#vim ifcfg-eth1
DEVICE=eth1
NAME=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.18.0.200
PREFIX=16

 [root@centos8 ~]#nmcli connection reload
 [root@centos8 ~]#nmcli connection up eth0
  [root@centos8 ~]#nmcli connection up eth1
 [root@centos8 ~]#ip a
  [root@centos8 ~]#iecho 1 > /proc/sys/net/ipv4/ip_forward
  [root@centos8 ~]#route add -net 172.20.0.0/16 gw 172.18.0.201 dev eth1
  [root@centos8 ~]#route add -net 172.22.0.0/16 gw 172.18.0.201 dev eth1
   [root@centos8 ~]#route add default gw 172.18.0.201 dev eth1 

centos 8.2上:

[root@centos8 ~]#cd /etc/sysconfig/network-scripts/
[root@centos8 ~]#vim ifcfg-eth0
DEVICE=eth0
NAME=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.18.0.201
PREFIX=16

[root@centos8 ~]#cp  ifcfg-eth0 ifcfg-eth1
[root@centos8 ~]#vim ifcfg-eth1
DEVICE=eth1
NAME=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.20.0.200
PREFIX=16

 [root@centos8 ~]#nmcli connection reload
 [root@centos8 ~]#nmcli connection up eth0
  [root@centos8 ~]#nmcli connection up eth1
 [root@centos8 ~]#ip a
  [root@centos8 ~]#iecho 1 > /proc/sys/net/ipv4/ip_forward
   [root@centos8 ~]#route add -net 172.16.0.0/16  gw 172.18.0.200 dev eth0
    [root@centos8 ~]#route add -net 172.22.0.0/16 gw 172.20.0.201 dev eth1

centos 8.3上:

[root@centos8 ~]#cd /etc/sysconfig/network-scripts/
[root@centos8 ~]#vim ifcfg-eth0
DEVICE=eth0
NAME=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.20.0.201
PREFIX=16

[root@centos8 ~]#cp  ifcfg-eth0 ifcfg-eth1
[root@centos8 ~]#vim ifcfg-eth1
DEVICE=eth1
NAME=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.22.0.200
PREFIX=16

 [root@centos8 ~]#nmcli connection reload
 [root@centos8 ~]#nmcli connection up eth0
  [root@centos8 ~]#nmcli connection up eth1
 [root@centos8 ~]#ip a
  [root@centos8 ~]#iecho 1 > /proc/sys/net/ipv4/ip_forward
   [root@centos8 ~]#route add  default gw 172.20.0.200 dev eth0

centos 7上:

[root@centos7 ~]#cd /etc/sysconfig/network-scripts/
[root@centos7 ~]#vim ifcfg-eth0
DEVICE=eth0
NAME=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.22.0.100
PREFIX=16
GATEWAY=172.22.0.200

 [root@centos7 ~]#nmcli connection reload
 [root@centos7 ~]#nmcli connection up eth0
 [root@centos7 ~]#ip a

验证结果:
在centos 6上ping centos 7的地址:在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值