天天看点

OSPF N1路由莫名其妙的加1的原因

OSPF N1路由莫名其妙的加1的原因

R1

interface Loopback0

 ip address 1.1.1.1 255.255.255.0

!

interface FastEthernet1/0

 ip address 12.1.1.1 255.255.255.0

 duplex auto

 speed auto

router rip

 version 2

 network 1.0.0.0

 network 12.0.0.0

 no auto-summary

R2

 ip address 2.2.2.2 255.255.255.0

interface FastEthernet0/0

 ip address 12.1.1.2 255.255.255.0

 ip address 23.1.1.2 255.255.255.0

router ospf 10

 router-id 2.2.2.2

 log-adjacency-changes

 area 1 nssa

 redistribute rip metric-type 1 subnets

 network 2.2.2.2 0.0.0.0 area 1

 network 23.1.1.2 0.0.0.0 area 1

 redistribute ospf 10 metric 1

R3

 ip address 3.3.3.3 255.255.255.0

 ip address 23.1.1.3 255.255.255.0

 ip address 34.1.1.3 255.255.255.0

 router-id 3.3.3.3

 network 3.3.3.3 0.0.0.0 area 0

 network 23.1.1.3 0.0.0.0 area 1

 network 34.1.1.3 0.0.0.0 area 0

因其他路由器对该试验的讨论分析没有影响,所以配置信息未列出

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 not set

     34.0.0.0/24 is subnetted, 1 subnets

C       34.1.1.0 is directly connected, FastEthernet1/0

     1.0.0.0/24 is subnetted, 1 subnets

O N1    1.1.1.0 [110/22] via 23.1.1.2, 00:02:44, FastEthernet0/0

     2.0.0.0/32 is subnetted, 1 subnets

O       2.2.2.2 [110/2] via 23.1.1.2, 00:03:16, FastEthernet0/0

     5.0.0.0/32 is subnetted, 1 subnets

O IA    5.5.5.5 [110/3] via 34.1.1.4, 00:03:16, FastEthernet1/0

     23.0.0.0/24 is subnetted, 1 subnets

C       23.1.1.0 is directly connected, FastEthernet0/0

     12.0.0.0/24 is subnetted, 1 subnets

O N1    12.1.1.0 [110/22] via 23.1.1.2, 00:02:46, FastEthernet0/0

     45.0.0.0/24 is subnetted, 1 subnets

O IA    45.1.1.0 [110/2] via 34.1.1.4, 00:03:19, FastEthernet1/0

R2(config)#int lo 0

R2(config-if)#ip ospf cost 10

O N1    1.1.1.0 [110/31] via 23.1.1.2, 00:00:19, FastEthernet0/0

O       2.2.2.2 [110/11] via 23.1.1.2, 00:00:19, FastEthernet0/0

O IA    5.5.5.5 [110/3] via 34.1.1.4, 00:00:19, FastEthernet1/0

O N1    12.1.1.0 [110/31] via 23.1.1.2, 00:00:22, FastEthernet0/0

O IA    45.1.1.0 [110/2] via 34.1.1.4, 00:00:22, FastEthernet1/0

Loopback接口的cost值改变后,N1路由的metric值也随之改变。

Loopback 0的IP地址和OSPF的router-id是相一致的,但是OSPF的router-id是手工指定的,路由器并不知道采用的那个loopback接口的IP地址。

所以猜想如果有其他loopback接口,是否会影响到N1路由的metric值

当然其他loopback接口也需要宣告到OSPF区域,不然的话怎么改OSPF的接口COST值

R2(config)#int lo 10

R2(config-if)#ip add 20.1.1.1 255.255.255.0

R2(config-if)#ip ospf cost 9

R2(config)#router ospf 10

R2(config-router)#net 20.1.1.1 0.0.0.0 a 1

O N1    1.1.1.0 [110/30] via 23.1.1.2, 00:00:02, FastEthernet0/0

O       2.2.2.2 [110/11] via 23.1.1.2, 00:00:02, FastEthernet0/0

     20.0.0.0/32 is subnetted, 1 subnets

O       20.1.1.1 [110/10] via 23.1.1.2, 00:00:02, FastEthernet0/0

O IA    5.5.5.5 [110/3] via 34.1.1.4, 00:00:02, FastEthernet1/0

O N1    12.1.1.0 [110/30] via 23.1.1.2, 00:00:05, FastEthernet0/0

O IA    45.1.1.0 [110/2] via 34.1.1.4, 00:00:05, FastEthernet1/0

因此可以得出结论,N1路由的metric莫名其妙加1的原因决定于NSSA区域ASBR的拥有最大IP地址的loopback接口(该接口需要宣告到OSPF区域)的Cost值,默认情况下Loopback接口的COST值是1,所以N1路由的metric会加1,假如没有loopback接口宣告到OSPF区域,N1路由的metric不会加1的

R2(config-router)#

R2(config-router)#no net 2.2.2.2 0.0.0.0 a 1

R2(config-router)#no net 20.1.1.1 0.0.0.0 a 1

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

O N1    1.1.1.0 [110/21] via 23.1.1.2, 00:00:02, FastEthernet0/0

O N1    12.1.1.0 [110/21] via 23.1.1.2, 00:00:02, FastEthernet0/0

O IA    45.1.1.0 [110/2] via 34.1.1.4, 00:00:04, FastEthernet1/0