配置OSPF虚链路
路由交换笔记(二十)---虚链路_职场
实验如下图并做预配置如下:
 R1(config)#inter s2/1                    
R1(config-if)#ip address 12.0.0.1 255.255.255.0                                            R1(config-if)#no shu
R1(config)#inter lo 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R2(config)#inter s2/1                    
R2(config-if)#ip address 12.0.0.2 255.255.255.0                                            R2(config-if)#no shu
R2(config)#inter  s2/2
R2(config-if)#ip address 23.0.0.1 255.255.255.0
R2(config-if)#no shu
R2(config)#inter lo 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R3(config)#inter s2/1                    
R3(config-if)#ip add 23.0.0.2 255.255.255.0
R3(config-if)#no shu
R3(config)#inter s2/2
R3(config-if)#ip add 34.0.0.1 255.255.255.0
R3(config-if)#no shu
R3(config)#inter lo 0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R4(config)#inter s2/1
R4(config-if)#ip add 34.0.0.2 255.255.255.0
R4(config-if)#no shu
R4(config)#inter lo 0
R4(config-if)#ip add 4.4.4.4 255.255.255.0
实验过程:
//我们在通告OSPF网络时后,在配置虚链路是要指定对方的routerID,所以就有确定routerID的问题
一般routerID确定有如下规则:
1: 最优先的是在OSPF进程中命令"router-id"指定路由器ID,如:router(config-router)#router-id
    1.1.1.1;就指定了次路由器的ID1.1.1.1
2:如果没有指定ID,那么选择IP地址最大的回环接口的IP作为routerID;
3: 如果没有回环接口,就选择最大活动的物理接口的IP地址作为routerID;
   通常我们指定路由器的ID,这样可控制性比较好。
现在通告OSPF网络并指定各自的routerID
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 12.0.0.0 0.255.255.255 area 0
R1(config-router)#network 1.1.1.0 0.255.255.255 area 0
R2(config)#router ospf 1                       
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 2.2.2.0 0.255.255.255 area 1                                      R2(config-router)#network 12.0.0.0 0.255.255.255 area 0
R2(config-router)#network 23.0.0.0 0.255.255.255 area 1
R3(config)#router ospf 1
R3(config-router)#network 23.0.0.0 0.255.255.255 area 1
R3(config-router)#network 3.3.3.0 0.255.255.255 area 1
R3(config-router)#network 34.0.0.0 0.255.255.255 area 0
R3(config-router)#router-id 3.3.3.3                                                                                                                                              
R4(config)#router ospf 1                       
R4(config-router)#router-id 4.4.4.4                                  
R4(config-router)#network 34.0.0.0 0.255.255.255 area 0
R4(config-router)#network 4.4.4.0 0.255.255.255 area 0
此时我们去R1上看路由表如下:
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 not set
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/65] via 12.0.0.2, 00:03:45, Serial2/1
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/129] via 12.0.0.2, 00:02:52, Serial2/1
     23.0.0.0/24 is subnetted, 1 subnets
O IA    23.0.0.0 [110/128] via 12.0.0.2, 00:03:54, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
从上面显示没有到右边区域0的路由。
我们现在做虚链路如下:
//做虚链路是在ABR(区域间路由)上做,上面R2R3ABR.
 
R2(config)#router ospf 1
R2(config-router)#area 1 virtual-link 3.3.3.3
R3(config)#router ospf 1
R3(config-router)#area 1 virtual-link 2.2.2.2
我们在R2上看虚链路建立情况如下:
R2#show ip ospf virtual-links
Virtual Link OSPF_VL0 to router 3.3.3.3 is up
//
建立,其中3.3.3.3为对方的routerID
  Run as demand circuit
  DoNotAge LSA allowed.
  Transit area 1, via interface Serial2/2, Cost of using 64
  Transmit Delay is 1 sec, State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:02
    Adjacency State FULL (Hello suppressed)
    Index 2/3, retransmission queue length 0, number of retransmission 1
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 1, maximum is 1
同样在R3上查看:
R3#show ip ospf virtual-links
Virtual Link OSPF_VL0 to router 2.2.2.2 is up
//
建立,2.2.2.2为对方的routerID
  Run as demand circuit
  DoNotAge LSA allowed.
  Transit area 1, via interface Serial2/1, Cost of using 64
  Transmit Delay is 1 sec, State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:00
    Adjacency State FULL (Hello suppressed)
    Index 2/3, retransmission queue length 0, number of retransmission 1
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 1, maximum is 1
    Last retransmission scan time is 0 msec, maximum is 0 msec
    Last retransmission scan time is 0 msec, maximum is 0 msec
现在到R1上在查看路由表:
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 not set
     34.0.0.0/24 is subnetted, 1 subnets
O       34.0.0.0 [110/192] via 12.0.0.2, 00:09:57, Serial2/1
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/65] via 12.0.0.2, 00:09:57, Serial2/1
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/129] via 12.0.0.2, 00:09:57, Serial2/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/193] via 12.0.0.2, 00:09:57, Serial2/1
     23.0.0.0/24 is subnetted, 1 subnets
O IA    23.0.0.0 [110/128] via 12.0.0.2, 00:09:57, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
现在有了到34.0.0.0和到4.4.4.0的路由。虚链路建立成功。