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
选项的差别!