如图8.10所示,三台路由器R1.R2,R3两两互连,每台路由器上都配置了Loopback地址模拟网络环境。
需要在三台路由器上配置静态路由,以实现各网段之间的互通。
若要实现全网互通,必须明确如下两个问题。
因此,要想实现全网互通,就必须为每台路由器指定所有非直连网段的路由条目。
- R1(config)#interface gigabitEthernet 0/0
- R1(config-if)#ip address 192.168.1.1 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R1(config)#interface gigabitEthernet 0/1
- R1(config-if)#ip address 192.168.2.1 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R1(config)#interface gigabitEthernet 0/2
- R1(config-if)#ip address 192.168.10.254 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R2(config)#interface gigabitEthernet 0/0
- R2(config-if)#ip address 192.168.1.2 255.255.255.0
- R2(config-if)#no shutdown
- R2(config-if)#exit
- R2(config)#interface gigabitEthernet 0/1
- R2(config-if)#ip address 192.168.3.2 255.255.255.0
- R2(config-if)#no shutdown
- R2(config-if)#exit
- R2(config)#interface gigabitEthernet 0/2
- R2(config-if)#ip address 192.168.20.254 255.255.255.0
- R2(config-if)#no shutdown
- R2(config-if)#exit
- R3(config)#interface gigabitEthernet 0/0
- R3(config-if)#ip address 192.168.3.3 255.255.255.0
- R3(config-if)#no shutdown
- R3(config-if)#exit
- R3(config)#interface gigabitEthernet 0/1
- R3(config-if)#ip address 192.168.2.3 255.255.255.0
- R3(config-if)#no shutdown
- R3(config-if)#exit
- R3(config)#interface gigabitEthernet 0/2
- R3(config-if)#ip address 192.168.30.254 255.255.255.0
- R3(config-if)#no shutdown
- R3(config-if)#exit
R1上的配置
- R1(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.2
- //配置去往192.168.20.0网段的路由指定下一跳地址为192.168.1.2
- R1(config)#ip route 192.168.30.0 255.255.255.0 192.168.2.3
- //配置去往192.168.30.0网段的路由指定下一跳地址为192.168.2.3
R2上的配置
- R2(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.1
- //配置去往192.168.10.0网段的路由指定下一跳地址为192.168.1.1
- R2(config)#ip route 192.168.30.0 255.255.255.0 192.168.3.3
- //配置去往192.168.30.0网段的路由指定下一跳地址为192.168.3.3
R3上的配置
- R3(config)#ip route 192.168.10.0 255.255.255.0 192.168.2.1
- //配置去往192.168.10.0网段的路由指定下一跳地址为192.168.2.1
- R3(config)#ip route 192.168.20.0 255.255.255.0 192.168.3.2
- //配置去往192.168.20.0网段的路由指定下一跳地址为192.168.3.2
- R1#show ip route static //查看路由表中的静态路由条目
- S 192.168.20.0/24 [1/0] via 192.168.1.2
- S 192.168.30.0/24 [1/0] via 192.168.2.3
-
- R2#show ip route static
- S 192.168.10.0/24 [1/0] via 192.168.1.1
- S 192.168.30.0/24 [1/0] via 192.168.3.3
-
- R3#show ip route static
- S 192.168.10.0/24 [1/0] via 192.168.2.1
- S 192.168.20.0/24 [1/0] via 192.168.3.2
路由信息解析