Example for Configuring an OSPF Virtual Link
Networking Requirements
In Figure 5-74, the original OSPF network is divided into Area0 and Area1. Due to limitations of the existing network, Area2 needs to be planned and added to the entire OSPF network using SwitchB as an ABR.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on each switch to implement reachable internal routes among Area0, Area1, and Area2.
Configure a virtual link between SwitchA and SwitchB to implement reachable routes between Area2 and other areas.
Procedure
- Configure VLANs for interfaces.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar to the configuration of SwitchA.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 20 [SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type trunk [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 [SwitchA-GigabitEthernet1/0/1] quit [SwitchA] interface gigabitethernet 1/0/2 [SwitchA-GigabitEthernet1/0/2] port link-type trunk [SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 20 [SwitchA-GigabitEthernet1/0/2] quit
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar to the configuration of SwitchA.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 20 [SwitchA-Vlanif20] ip address 192.168.1.1 24 [SwitchA-Vlanif20] quit
- Configure basic OSPF functions.
# Configure SwitchA.
[SwitchA] ospf 1 router-id 10.10.10.1 [SwitchA-ospf-1] area 0 [SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] ospf 1 router-id 10.10.10.2 [SwitchB-ospf-1] area 1 [SwitchB-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.1] quit [SwitchB-ospf-1] area 2 [SwitchB-ospf-1-area-0.0.0.2] network 172.16.0.0 0.0.255.255 [SwitchB-ospf-1-area-0.0.0.2] quit [SwitchB-ospf-1] quit
# Configure SwitchC.
[SwitchC] ospf 1 router-id 10.10.10.3 [SwitchC-ospf-1] area 0 [SwitchC-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] quit [SwitchC-ospf-1] quit
# Configure SwitchD.
[SwitchD] ospf 1 router-id 10.10.10.4 [SwitchD-ospf-1] area 2 [SwitchD-ospf-1-area-0.0.0.2] network 172.16.0.0 0.0.255.255 [SwitchD-ospf-1-area-0.0.0.2] quit [SwitchD-ospf-1] quit
# Check the OSPF routing table on SwitchA.
[SwitchA] display ospf routing OSPF Process 1 with Router ID 10.10.10.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 10.1.1.0/24 1 Transit 10.1.1.1 10.10.10.1 0.0.0.0 192.168.1.0/24 1 Transit 192.168.1.1 10.10.10.1 0.0.0.1 Total Nets: 2 Intra Area: 2 Inter Area: 0 ASE: 0 NSSA: 0
The preceding command output shows that the Area2 route information does not exist on SwitchA. OSPF requires that all non-backbone areas maintain the connectivity with the backbone area. Area2 is not directly connected to Area0; therefore, the routing table of SwitchA does not contain the routes in Area2.
- Configure a virtual link.
# Configure SwitchA.
[SwitchA] ospf 1 [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] vlink-peer 10.10.10.2 [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] ospf 1 [SwitchB-ospf-1] area 1 [SwitchB-ospf-1-area-0.0.0.1] vlink-peer 10.10.10.1 [SwitchB-ospf-1-area-0.0.0.1] quit [SwitchB-ospf-1] quit
- Verify the configuration.
# Check the OSPF routing table on SwitchA.
[SwitchA] display ospf routing OSPF Process 1 with Router ID 10.10.10.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 10.1.1.0/24 1 Transit 10.1.1.1 10.10.10.1 0.0.0.0 192.168.1.0/24 1 Transit 192.168.1.1 10.10.10.1 0.0.0.1 172.16.0.0/16 2 Inter-area 192.168.1.2 10.10.10.2 0.0.0.0 Total Nets: 3 Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0
The preceding command output shows that the OSPF routing table of SwitchA contains the routes in Area2 after the virtual link is configured between SwitchA and SwitchB.
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 20 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 # interface Vlanif20 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.10.10.1 area 0.0.0.0 network 10.1.1.0 0.0.0.255 area 0.0.0.1 network 192.168.1.0 0.0.0.255 vlink-peer 10.10.10.2 # return
SwitchB configuration file
# sysname SwitchB # vlan batch 20 30 # interface Vlanif20 ip address 192.168.1.2 255.255.255.0 # interface Vlanif30 ip address 172.16.1.1 255.255.0.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 router-id 10.10.10.2 area 0.0.0.1 network 192.168.1.0 0.0.0.255 vlink-peer 10.10.10.1 area 0.0.0.2 network 172.16.0.0 0.0.255.255 # return
SwitchC configuration file
# sysname SwitchC # vlan batch 10 # interface Vlanif10 ip address 10.1.1.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 router-id 10.10.10.3 area 0.0.0.0 network 10.1.1.0 0.0.0.255 # return
SwitchD configuration file
# sysname SwitchD # vlan batch 30 # interface Vlanif30 ip address 172.16.1.2 255.255.0.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 router-id 10.10.10.4 area 0.0.0.2 network 172.16.0.0 0.0.255.255 # return