2、理解OSPF 的E1 与E2 类型的路由。
配置好地址,测试互通,配置基本的动态路由信息。
搞完后查看各个路由器的路由表:
R1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C 172.16.255.0/30 is directly connected, Serial0/0
C 172.16.1.0/24 is directly connected, Loopback0
C 172.16.2.0/24 is directly connected, Loopback1
R2#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C 172.16.255.0/30 is directly connected, Serial0/0
O 172.16.1.1/32 [110/65] via 172.16.255.1, 00:03:11, Serial0/0
O 172.16.2.1/32 [110/65] via 172.16.255.1, 00:03:11, Serial0/0
C 192.168.255.0/24 is directly connected, Serial0/1
R 192.168.1.0/24 [120/1] via 192.168.255.2, 00:00:11, Serial0/1
R 192.168.2.0/24 [120/1] via 192.168.255.2, 00:00:11, Serial0/1
R3#show ip route
Gateway of last resort is not set
C 192.168.255.0/24 is directly connected, Serial0/0
C 192.168.1.0/24 is directly connected, Loopback0
C 192.168.2.0/24 is directly connected, Loopback1
只有R2可以学到整个网络的路由,因为它处于两个自治系统的边界,同时运行了两种不同的动态路由协议。
为了让R1和R3都能学习到完整的路由表,可以在R2上配置路由重分发:
R2(config)#router ospf 1
R2(config-router)#redistribute rip metric 200 subnets ----->subnets命令确保RIP网络中的无类子网路由
R2(config-router)#exit 能被正确发布,重发布路由转型默认为E2
R2(config)#router rip
R2(config-router)#redistribute ospf 1 metric 10 ----->指定度量为10
R2(config-router)#exit
再看R1和R3的路由表:
R1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C 172.16.255.0/30 is directly connected, Serial0/0
C 172.16.1.0/24 is directly connected, Loopback0
C 172.16.2.0/24 is directly connected, Loopback1
O E2 192.168.255.0/24 [110/200] via 172.16.255.2, 00:06:29, Serial0/0
O E2 192.168.1.0/24 [110/200] via 172.16.255.2, 00:06:29, Serial0/0
O E2 192.168.2.0/24 [110/200] via 172.16.255.2, 00:06:29, Serial0/0
R3#show ip route
Gateway of last resort is not set
R 172.16.0.0/16 [120/10] via 192.168.255.1, 00:00:17, Serial0/0 ----->R2是主类网络的边界,所以学到的是汇总路由
C 192.168.255.0/24 is directly connected, Serial0/0
C 192.168.1.0/24 is directly connected, Loopback0
C 192.168.2.0/24 is directly connected, Loopback1
确认有效性:
R3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/40/72 ms
正常。
Everything is OK !