天天看點

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