如图8.11所示,三台路由器R1, R2,R3两两互连。R2上配置了Loopback地址192.168.20 .1/24,模拟192.168.20.0/24网段;R3上配置了两个Loopback地址192.168.10.1/24、192.168 .30.1/24.分别用来模拟192.168.10.0/24和192.168.30.0/24网段。
需要实现当192.168.20.0/24访问192.168.30.0/24时,数据从R2到R3,而当192.168.20.0/24访问192.168.10.0/24时,数据从R2经过R1再到R3,返回的路由都从R3到R2,
步骤1:在R2上配置到192.168.30.0/24的静态路由。
步骤2:在R2上配置到192.168.10.0/24的静态路由,在R1上也应该配置到192.168.10.0/24的静态路由。
步骤3:在 R3上配置回程的静态路由。
- R1(config)#interface gigabitEthernet 0/3/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/2/0
- R1(config-if)#ip address 192.168.2.1 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R2(config)#interface gigabitEthernet 0/3/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/2/0
- 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/0
- 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/3/0
- 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/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/0
- R3(config-if)#ip address 192.168.10.254 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.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
- R1(config)#ip route 192.168.10.0 255.255.255.0 192.168.2.3
-
- ##R2上的静态路由配置
- R2(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.1
- R2(config)#ip route 192.168.30.0 255.255.255.0 192.168.3.3
-
- ##R3上的静态路由配置
- R3(config)#ip route 192.168.20.0 255.255.255.0 192.168.3.2
-
- ##R1上的静态路由条目
- R1#show ip route static
- S 192.168.10.0/24 [1/0] via 192.168.2.3
- S 192.168.20.0/24 [1/0] via 192.168.1.2
-
- ##R2上的静态路由条目
- 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上的静态路由条目
- R3#show ip route static
- S 192.168.20.0/24 [1/0] via 192.168.3.2
观察PC1到PC2的流量方向
pc1topc2
观察PC1到PC3的流量方向
pc1topc3