CCNP-16 OSPF试验12
试验拓扑:
试验要求:R2 R3起OSPF,R1配置静态路由,在R2上配置缺省路由。
试验目的:掌握OSPF缺省路由的配置方法。
试验配置:
R1:
R1(config)#int s1/0
R1(config-if)#ip add 199.99.1.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int loop0
R1(config-if)#ip add 100.100.100.100 255.255.255.0
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 199.99.1.2
R1(config)#end
R2:
R2(config)#int s1/0
R2(config-if)#ip add 199.99.1.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int s1/1
R2(config-if)#ip add 199.99.2.1 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int loop0
R2(config-if)#ip add 1.1.1.1 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#router-id 1.1.1.1
R2(config-router)#network 199.99.2.0 0.0.0.255 area 0
R2(config-router)#exit
R3:
R3(config)#int s1/0
R3(config-if)#ip add 199.99.2.2 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int loop0
R3(config-if)#ip add 2.2.2.2 255.255.255.0
R3(config-if)#exit
R3(config)#router ospf 100
R3(config-router)#router-id 2.2.2.2
R3(config-router)#network 199.99.2.0 0.0.0.255 area 0
R3(config-router)#exit
基本配置完成,下面查看路由表:
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 199.99.1.2 to network 0.0.0.0
C 199.99.1.0/24 is directly connected, Serial1/0
C 100.100.100.0/24 is directly connected, Loopback0
S* 0.0.0.0/0 [1/0] via 199.99.1.2
R1上配置了一条缺省路由,R2和R3都没有到达100.100.100.0/24的路由,如果想让R3能够ping通R1的loopback接口,应该怎么办?有一种解决方法是在R2上配置一条静态路由,然后再把这条静态路由作为缺省路由向区域内洪泛。例如:
R2(config)#router ospf 100
R2(config-router)#default-information originate
R2(config-router)#exit
R2(config)#ip route 0.0.0.0 0.0.0.0 199.99.1.1
好了,特别注意:如果配置default-information originate时没有带always选项,那么路由表里必须有一条静态路由与之相对!下面在R3上查看路由表:
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 199.99.2.1 to network 0.0.0.0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
C 199.99.2.0/24 is directly connected, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 199.99.2.1, 00:00:00, Serial1/0
看到了最后有一条O*E2缺省路由,外部路由的缺省路由一般是以O*E2的形势泛洪的。Ping测试一下:
R3#ping 100.100.100.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 100.100.100.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 144/164/192 ms
通了,测试成功!
下面介绍缺省路由中带always选项的配置,带不带always选项的区别就是需不需要路由表里有与之相对应的路由:
R2(config)#router ospf 100
R2(config-router)#default-information originate always
R2(config-router)#exit
这样配置完成后,在R3上查看路由表:
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 199.99.2.1 to network 0.0.0.0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
C 199.99.2.0/24 is directly connected, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 199.99.2.1, 00:00:01, Serial1/0
发现同样学到了O*E2路由,ping测试一下:
R3#ping 100.100.100.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 100.100.100.100, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
出现了不可达提示,为什么呢? 因为我把到100.100.100.100的数据包交给我的缺省网关199.99.2.1后,但是缺省网关并不知道怎么到达100.100.100.100,所以返回不可达提示,我们在R2上配置一跳到100.100.100.100的静态路由就可以了:
R2(config)#ip route 100.100.100.0 255.255.255.0 199.99.1.1
好了,再在R3上进行ping测试:
R3#ping 100.100.100.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 100.100.100.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 240/277/308 ms
通了!
实验总结:掌握OSPF缺省路由的配置方法,并且掌握不带always选项和带always选项的差别!
本文转自loveme2351CTO博客,原文链接:http://blog.51cto.com/loveme23/47278 ,如需转载请自行联系原作者