11. Configuring OSPF Default Route With Metric

掌握如何修改度量值控制OSPF的默认路由选择。

 

TOP图:

image.png

配置好各个路由器的基本信息,再配置好各个路由器的动态路由协议基本信息,测试各互连接口连通性。

 

查看R2的路由表:

R2#show ip route
Gateway of last resort is not set

     192.168.1.0/30 is subnetted, 2 subnets
C       192.168.1.0 is directly connected, Serial0/0
C       192.168.1.4 is directly connected, Serial0/1
R2#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

 

为了能保证网络通讯,在R1和R3上配置不同协议的路由重分发,和OSPF的默认路由:

R1(config)#router rip
R1(config-router)#redistribute ospf 1 metric 10
R1(config-router)#exit
R1(config)#router ospf 1                      (起源)
R1(config-router)#default-information originate always 
向OSPF网络通告默认路由,使用always的目的是:在没有配置静态默认路由的情况下始终向OSPF网络通告默认路由。

 

R3(config)#router rip 
R3(config-router)#redistribute ospf 1 metric 10
R3(config-router)#exit
R3(config)#router ospf 1
R3(config-router)#default-information originate always
R3(config-router)#exit

 

再次查看R2路由表并测试:

R2#show ip route
Gateway of last resort is 192.168.1.6 to network 0.0.0.0

     192.168.1.0/30 is subnetted, 2 subnets
C       192.168.1.0 is directly connected, Serial0/0
C       192.168.1.4 is directly connected, Serial0/1
O*E2 0.0.0.0/0 [110/1] via 192.168.1.6, 00:01:28, Serial0/1
               [110/1] via 192.168.1.1, 00:01:28, Serial0/0
R2#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/52/80 ms

 

跟踪一下:

R2#traceroute 10.1.1.1

Type escape sequence to abort.
Tracing the route to 10.1.1.1

  1 192.168.1.6 52 msec
    192.168.1.1 16 msec
    192.168.1.6 36 msec
  2 172.16.1.2 40 msec
    172.16.1.5 48 msec *

受负载均衡的影响,结果比较奇怪。

 

R2选择到达非OSPF网络的路由下一跳是R1和R3,并且是均衡负载。而在本实验中,从R1到达非OSPF网络是使用帧中继的网络。从R3到达非OSPF网络是使用更高速的链路。 因此选择从R3到达外网远比从R1到达非OSPF网络要好。

 
为了解决这个问题,在通告默认路由时可以采用定制度量的参数,来影响路由器选择最佳路由。

在R1和R3上进行如下配置:

R1(config)#router ospf 1
R1(config-router)#default-information originate always metric 100(度量值)
R1(config-router)#exit

 

R3(config)#router ospf 1
R3(config-router)#default-information originate always metric 50
R3(config-router)#exit

 

再查看R2的路由表:

R2#show ip route
Gateway of last resort is 192.168.1.6 to network 0.0.0.0

     192.168.1.0/30 is subnetted, 2 subnets
C       192.168.1.0 is directly connected, Serial0/0
C       192.168.1.4 is directly connected, Serial0/1
O*E2 0.0.0.0/0 [110/50] via 192.168.1.6, 00:01:24, Serial0/1

去往外部网络不再走R1,而是走速度快的R3。

 

跟踪结果:

R2#traceroute 10.1.1.1

Type escape sequence to abort.
Tracing the route to 10.1.1.1

  1 192.168.1.6 36 msec 40 msec 48 msec
  2 172.16.1.5 84 msec *  24 msec

正常。

 

最佳路由的问题已经解决,更准确地讲是通过控制OSPF的默认路由的度量值来影响OSPF选路。


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

桂ICP备19000498号-3