ospf的虚连接配置

作者:邓聪聪

配置OSPF虚连接

组网需求

图1中,Area2没有与骨干区域直接相连。Area1被用作传输区域(Transit Area)来连接Area2和Area0。SwitchA、SwitchB之间配置一条虚连接。

图1 配置OSPF虚连接的组网图 
 

Switch

接口

对应的VLANIF

IP地址

SwitchA

GigabitEthernet1/0/1

VLANIF 10

192.168.1.1/24

SwitchA

GigabitEthernet1/0/2

VLANIF 20

10.1.1.1/8

SwitchB

GigabitEthernet1/0/1

VLANIF 10

192.168.1.2/24

SwitchB

GigabitEthernet1/0/2

VLANIF 30

172.16.1.1/16

SwitchC

GigabitEthernet1/0/1

VLANIF 20

10.1.1.2/8

SwitchD

GigabitEthernet1/0/1

VLANIF 30

172.16.1.2/16

配置思路

采用如下的思路配置OSPF虚连接:

  1. 在各Switch上使能OSPF,配置OSPF基本功能。

  2. SwitchA、SwitchB上配置虚连接,使非骨干区域与骨干区域连通。

数据准备

为完成此配置例,需准备如下的数据:

  • 各接口所属的VLAN ID,具体数据如图1所示。
  • 各VLANIF接口的IP地址,具体数据如图1所示。
  • Switch设备的Router ID,OSPF进程号以及各接口所属的区域。

    • SwitchA的Router ID 1.1.1.1,运行的OSPF进程号1,区域1的网段192.168.1.0/24,区域0的网段10.0.0.0/8。
    • SwitchB的Router ID 2.2.2.2,运行的OSPF进程号1,区域1的网段192.168.1.0/24,区域2的网段172.16.0.0/16。
    • SwitchC的Router ID 3.3.3.3,运行的OSPF进程号1,区域0的网段10.0.0.0/8。
    • SwitchD的Router ID 4.4.4.4,运行的OSPF进程号1,区域2的网段172.16.0.0/16。

操作步骤

  1. 配置各接口所属VLAN
    <Quidway> system-view
    [Quidway] sysname SwitchA
    [SwitchA] vlan batch 10 20
    [SwitchA] interface gigabitethernet 1/0/1
    [SwitchA-GigabitEthernet1/0/1]port hybrid pvid vlan 10
    [SwitchA-GigabitEthernet1/0/1]port hybrid untagged vlan 10
    [SwitchA-GigabitEthernet1/0/1] quit
    [SwitchA] interface gigabitethernet 1/0/2
    [SwitchA-GigabitEthernet1/0/2] port hybrid pvid vlan 20
    [SwitchA-GigabitEthernet1/0/2] port hybrid untagged vlan 20
    [SwitchA-GigabitEthernet1/0/2] quit
    

    SwitchB、SwitchC、SwitchD的配置同SwitchA(略)

  2. 配置各VLANIF接口的IP地址
    [SwitchA] interface vlanif 10
    [SwitchA-Vlanif10] ip address 192.168.1.1 24
    [SwitchA-Vlanif10] quit
    [SwitchA] interface vlanif 20
    [SwitchA-Vlanif20] ip address 10.1.1.1 8
    [SwitchA-Vlanif20] quit

    SwitchB、SwitchC、SwitchD的配置同SwitchA(略)

  3. 配置OSPF基本功能

    # 配置SwitchA。

    [SwitchA] ospf 1 router-id 1.1.1.1 
    [SwitchA-ospf-1] area 0
    [SwitchA-ospf-1-area-0.0.0.0] network 10.0.0.0 0.255.255.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

    # 配置SwitchB。

    [SwitchB] ospf 1 router-id 2.2.2.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

    # 配置SwitchC。

    [SwitchC] ospf 1 router-id 3.3.3.3 
    [SwitchC-ospf-1] area 0
    [SwitchC-ospf-1-area-0.0.0.0] network 10.0.0.0 0.255.255.255 
    [SwitchC-ospf-1-area-0.0.0.0] quit
    [SwitchC-ospf-1] quit

    # 配置SwitchD。

    [SwitchD] ospf 1 router-id 4.4.4.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

    # 查看SwitchA的OSPF路由表。

    [SwitchA] display ospf routing
     
              OSPF Process 1 with Router ID 1.1.1.1
                       Routing Tables
     
     Routing for Network
     Destination        Cost  Type         NextHop         AdvRouter       Area
     10.0.0.0/8          1     Transit     10.1.1.1        3.3.3.3         0.0.0.0
     192.168.1.0/24      1     Transit     192.168.1.1     2.2.2.2         0.0.0.1 
     Total Nets: 2
     Intra Area: 2  Inter Area: 0  ASE: 0  NSSA: 0

    由于Area2没有与Area0直接相连,所以SwitchA路由表中没有Area2中的路由。

  4. 配置虚连接

    # 配置SwitchA。

    [SwitchA] ospf 
    [SwitchA-ospf-1] area 1
    [SwitchA-ospf-1-area-0.0.0.1] vlink-peer 2.2.2.2
    [SwitchA-ospf-1-area-0.0.0.1] quit
    [SwitchA-ospf-1] quit

    # 配置SwitchB。

    [SwitchB] ospf 1
    [SwitchB-ospf-1] area 1
    [SwitchB-ospf-1-area-0.0.0.1] vlink-peer 1.1.1.1 
    [SwitchB-ospf-1-area-0.0.0.1] quit
    [SwitchB-ospf-1] quit
  5. 验证配置结果

    # 查看SwitchA的OSPF路由表。

    [SwitchA] display ospf routing
     
              OSPF Process 1 with Router ID 1.1.1.1
                       Routing Tables
     
     Routing for Network
     Destination        Cost  Type           NextHop         AdvRouter       Area
     172.16.0.0/16      2     Inter-area    192.168.1.2     2.2.2.2         0.0.0.0
     10.0.0.0/8         1     Transit       10.1.1.1        1.1.1.1         0.0.0.0
     192.168.1.0/24     1     Transit       192.168.1.1     2.2.2.2         0.0.0.1
     
     Total Nets: 3
     Intra Area: 2  Inter Area: 1  ASE: 0  NSSA: 0

配置文件

  • SwitchA的配置文件

    #
     sysname SwitchA
    #
     vlan batch 10 20
    #
    interface Vlanif10
     ip address 192.168.1.1 255.255.255.0
    #
    interface Vlanif20
     ip address 10.1.1.1 255.0.0.0
    #
    interface GigabitEthernet1/0/1
     port hybrid pvid vlan 10
     port hybrid untagged vlan 10 
    #
    interface GigabitEthernet1/0/2
     port hybrid pvid vlan 20
     port hybrid untagged vlan 20 
    #
    ospf 1 router-id 1.1.1.1
     area 0.0.0.0
      network 10.0.0.0 0.255.255.255
     area 0.0.0.1
      network 192.168.1.0 0.0.0.255
      vlink-peer 2.2.2.2
    #
    return
  • SwitchB的配置文件

    #
     sysname SwitchB
    #
     vlan batch 10 30
    #
    interface Vlanif10
     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 hybrid pvid vlan 10
     port hybrid untagged vlan 10 
    #
    interface GigabitEthernet1/0/2
     port hybrid pvid vlan 30
     port hybrid untagged vlan 30 
    #
    ospf 1 router-id 2.2.2.2
     area 0.0.0.1
      network 192.168.1.0 0.0.0.255
      vlink-peer 1.1.1.1
     area 0.0.0.2
      network 172.16.0.0 0.0.255.255
    #
    return
  • SwitchC的配置文件

    #
     sysname SwitchC
    #
     vlan 20
    #
    interface Vlanif20
     ip address 10.1.1.2 255.0.0.0
    #
    interface GigabitEthernet1/0/1
     port hybrid pvid vlan 20
     port hybrid untagged vlan 20 
    #
    ospf 1 router-id 3.3.3.3
     area 0.0.0.0
      network 10.0.0.0 0.255.255.255
    #
    return
  • SwitchD的配置文件

    #
     sysname SwitchD
    #
     vlan 30
    #
    interface Vlanif30
     ip address 172.16.1.2 255.255.0.0
    #
    interface GigabitEthernet1/0/1
     port hybrid pvid vlan 30
     port hybrid untagged vlan 30 
    #
    ospf 1 router-id 4.4.4.4
     area 0.0.0.2
      network 172.16.0.0 0.0.255.255
    #
    return
 
原文地址:https://www.cnblogs.com/dengcongcong/p/10234152.html