• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C SOHO交换机 典型配置举例(Comware V5)-6W102

16-OSPF典型配置举例

本章节下载 16-OSPF典型配置举例  (366.06 KB)

docurl=/cn/Service/Document_Software/Document_Center/Switches/Catalog/S5110/S5110/Configure/Typical_Configuration_Example/H3C_SOHO_CE(Comware_V5)-6W102/201809/1107291_30005_0.htm

16-OSPF典型配置举例


1  OSPF路由典型配置举例

1.1  简介

本章介绍了OSPF路由协议的各种典型配置。

1.2  OSPF基本功能典型配置举例

1.2.1  组网需求

图1所示网络,通过配置OSPF基本功能实现网络内所有设备的路由互通,每台设备都能学习到网络中所有网段的路由。配置时将网络划分为3个OSPF区域,Area 1、Area 2均与骨干区域Area 0保持连接。

图1 OSPF基本配置组网图

 

1.2.2  配置注意事项

Router ID用来在一个自治系统中唯一的标识一台路由器,Router ID需要保证在同一个自治系统中不重复。

1.2.3  配置步骤

(1)     配置各接口的IP地址(略)

(2)     配置OSPF基本功能

# 配置Switch A。

<SwitchA> system-view

[SwitchA] router id 192.168.1.1

[SwitchA] ospf

[SwitchA-ospf-1] area 0

[SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.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

# 配置Switch B。

<SwitchB> system-view

[SwitchB] router id 192.168.2.1

[SwitchB] ospf

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

[SwitchB-ospf-1] area 2

[SwitchB-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.2] quit

[SwitchB-ospf-1] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] router id 192.168.1.2

[SwitchC] ospf

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.1] network 172.16.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.1] quit

[SwitchC-ospf-1] quit

# 配置Switch D。

<SwitchD> system-view

[SwitchD] router id 192.168.2.2

[SwitchD] ospf

[SwitchD-ospf-1] area 2

[SwitchD-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.2] network 172.17.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.2] quit

[SwitchD-ospf-1] quit

1.2.4  验证配置

# 查看Switch A的OSPF邻居,可以看到Switch A和Switch B、Switch C都形成了OSPF邻居。

[SwitchA] display ospf peer verbose

 

          OSPF Process 1 with Router ID 192.168.1.1

                  Neighbors

 

 Area 0.0.0.0 interface 192.168.0.1(Vlan-interface 100)'s neighbors

 Router ID: 192.168.2.1      Address: 192.168.0.2      GR State: Normal

   State: Full  Mode:Nbr is  Master  Priority: 1

   DR: 192.168.0.2   BDR: 192.168.0.1   MTU: 0

   Dead timer due in 36  sec

   Neighbor is up for 00:15:04

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 3

 

                  Neighbors

 

 Area 0.0.0.1 interface 192.168.1.1(Vlan-interface 200)'s neighbors

 Router ID: 192.168.1.2       Address: 192.168.1.2      GR State: Normal

   State: Full  Mode:Nbr is  Slave  Priority: 1

   DR: 192.168.1.2   BDR: 192.168.1.1   MTU: 0

   Dead timer due in 39  sec

   Neighbor is up for 00:07:32

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

# 显示Switch A的OSPF路由信息,可以看到网络中所有网段的路由信息。

[SwitchA] display ospf routing

 

          OSPF Process 1 with Router ID 192.168.1.1

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type      NextHop         AdvRouter      Area

 172.16.1.0/24     1563  Stub      192.168.1.2     172.16.1.1     0.0.0.1

 172.17.1.0/24     3125  Inter     192.168.0.2     192.168.2.1    0.0.0.0

 192.168.1.0/24    1562  Transit   192.168.1.1     192.168.0.1    0.0.0.1

 192.168.2.0/24    3124  Inter     192.168.0.2     192.168.2.1    0.0.0.0

 192.168.0.0/24    1562  Transit   192.168.0.1     192.168.0.1    0.0.0.0

 

 Total Nets: 5

 Intra Area: 3  Inter Area: 2  ASE: 0  NSSA: 0

# 查看Switch D的路由表,同样可以看到网络中所有网段的路由信息。

[SwitchD] display ospf routing

          OSPF Process 1 with Router ID 192.168.2.2

                   Routing Tables

 

 Routing for Network

 Destination        Cost  Type       NextHop         AdvRouter       Area

 172.16.1.0/24      4687  Inter      192.168.2.1     192.168.2.1     0.0.0.2

 172.17.1.0/24      1     Stub       172.17.1.1      192.168.2.2     0.0.0.2

 192.168.1.0/24     4686  Inter      192.168.2.1     192.168.2.1     0.0.0.2

 192.168.2.0/24     1562  Transit    192.168.2.2     192.168.2.2     0.0.0.2

 192.168.0.0/24     3124  Inter      192.168.2.1     192.168.2.1     0.0.0.2

 

 Total Nets: 5

 Intra Area: 2  Inter Area: 3  ASE: 0  NSSA: 0

# 在Switch D上使用Ping进行测试连通性,可以成功ping通Switch C。

[SwitchD] ping 172.16.1.1

  PING 172.16.1.1: 56  data bytes, press CTRL_C to break

    Reply from 172.16.1.1: bytes=56 Sequence=1 ttl=253 time=62 ms

    Reply from 172.16.1.1: bytes=56 Sequence=2 ttl=253 time=16 ms

    Reply from 172.16.1.1: bytes=56 Sequence=3 ttl=253 time=62 ms

    Reply from 172.16.1.1: bytes=56 Sequence=4 ttl=253 time=94 ms

    Reply from 172.16.1.1: bytes=56 Sequence=5 ttl=253 time=63 ms

 

  --- 172.16.1.1 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 16/59/94 ms

1.2.5  配置文件

·     Switch A

#

 router id 192.168.1.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

#

·     Switch B

#

 router id 192.168.2.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.2 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.2.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

#

·     Switch C

#

 router id 192.168.1.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

#

·     Switch D

#

 router id 192.168.2.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.2.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.17.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

#

1.3  OSPF的Stub区域典型配置举例

1.3.1  组网需求

图2所示网络,所有设备均运行OSPF基本功能,网络层相互可达。Switch D作为AS边界路由器,在网络中引入了大量外部路由。通过将Area 1配置为Stub区域,屏蔽大量的AS外部路由条目,降低Area 1中路由器的路由表规模及LSA数量。

为了进一步减少Stub区域路由表规模以及路由信息传递的数量,将Area 1配置为Totally Stub区域,Totally Stub区域将区域间的路由信息及LSA信息进一步过滤了。

图2 配置OSPF Stub区域组网图

 

1.3.2  配置注意事项

·     如果要将一个区域配置成Stub区域,则该区域中的所有路由器必须都要配置stub命令。

·     如果要将一个区域配置成Totally Stub区域,该区域中的所有路由器必须配置stub命令,而其中该区域的ABR路由器需要配置stub no-summary 命令。

1.3.3  配置步骤

(1)     配置接口的IP地址(略)

(2)     配置OSPF(同前例1.2 

(3)     配置Switch D引入静态路由(此处仅作验证示例,实际组网中此处可能有大量路由被引入)

[SwitchD] ip route-static 200.0.0.0 8 null 0

[SwitchD] ospf

[SwitchD-ospf-1] import-route static

[SwitchD-ospf-1] quit

# 查看Switch C的OSPF路由表。

[SwitchC] display ospf routing

          OSPF Process 1 with Router ID 192.168.1.2

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type      NextHop         AdvRouter      Area

 172.16.1.0/24     1     Stub      172.16.1.1      172.16.1.1     0.0.0.1

 172.17.1.0/24     4687  Inter     192.168.1.1     192.168.0.1    0.0.0.1

 192.168.1.0/24    1562  Transit   192.168.1.2     172.16.1.1     0.0.0.1

 192.168.2.0/24    4686  Inter     192.168.1.1     192.168.0.1    0.0.0.1

 192.168.0.0/24    3124  Inter     192.168.1.1     192.168.0.1    0.0.0.1

 

 Routing for ASEs

 Destination       Cost     Type      Tag       NextHop        AdvRouter

 200.0.0.0/8       10       Type2     1         192.168.1.1    172.17.1.1

 

 Total Nets: 6

 Intra Area: 2  Inter Area: 3  ASE: 1  NSSA: 0

说明

当Switch C所在区域为普通区域时,可以看到路由表中存在AS外部的路由。

 

(4)     配置Area1为Stub区域

# 配置Switch A。

[SwitchA] ospf

[SwitchA-ospf-1] area 1

[SwitchA-ospf-1-area-0.0.0.1] stub

[SwitchA-ospf-1-area-0.0.0.1] quit

[SwitchA-ospf-1] quit

# 配置Switch C。

[SwitchC] ospf

[SwitchC-ospf-1] stub-router

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] stub

[SwitchC-ospf-1-area-0.0.0.1] quit

[SwitchC-ospf-1] quit

1.3.4  验证配置

# 显示Switch C的OSPF路由表,可以看到当把Switch C所在区域配置为Stub区域时,已经看不到AS外部的路由,取而代之的是一条缺省路由。

[SwitchC] display ospf routing

          OSPF Process 1 with Router ID 192.168.1.2

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type      NextHop         AdvRouter      Area

 0.0.0.0/0         65536 Inter     192.168.1.1     192.168.0.1    0.0.0.1

 172.16.1.0/24     1     Stub      172.16.1.1      172.16.1.1     0.0.0.1

 172.17.1.0/24     68660 Inter     192.168.1.1     192.168.0.1    0.0.0.1

 192.168.1.0/24    1562  Transit   192.168.1.2     172.16.1.1     0.0.0.1

 192.168.2.0/24    68659 Inter     192.168.1.1     192.168.0.1    0.0.0.1

 192.168.0.0/24    67097 Inter     192.168.1.1     192.168.0.1    0.0.0.1

 

 Total Nets: 6

 Intra Area: 2  Inter Area: 4  ASE: 0  NSSA: 0

# 在区域边界路由器Switch  A上配置禁止向Stub区域通告Type3 LSA,将区域配置为Totally Stub区域。

[SwitchA] ospf

[SwitchA-ospf-1] area 1

[SwitchA-ospf-1-area-0.0.0.1] stub no-summary

[SwitchA-ospf-1-area-0.0.0.1] quit

# 再次查看Switch C的OSPF路由表,可以看到禁止向Stub区域通告Summary LSA后,Stub区域路由器的路由表项进一步减少,只保留了一条通往区域外部的缺省路由。

[SwitchC] display ospf routing

          OSPF Process 1 with Router ID 172.16.1.1

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type      NextHop         AdvRouter      Area

 0.0.0.0/0         1563  Inter     192.168.1.1     192.168.0.1    0.0.0.1

 172.16.1.0/24     1     Stub      172.16.1.1      172.16.1.1     0.0.0.1

 192.168.1.0/24    1562  Transit   192.168.1.2     172.16.1.1     0.0.0.1

 

 Total Nets: 3

 Intra Area: 2  Inter Area: 1  ASE: 0  NSSA: 0

1.3.5  配置文件

·     Switch A

#

 router id 192.168.1.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  stub no-summary

#

·     Switch B

#

 router id 192.168.2.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.2 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.2.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

#

·     Switch C

#

 router id 192.168.1.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.1 255.255.255.0

#

ospf 1

 stub-router

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

  stub

#

·     Switch D

#

 router id 192.168.2.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.2.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.17.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

 import-route static

#

 ip route-static 200.0.0.0 255.0.0.0 NULL0

#

1.4  OSPF的NSSA区域典型配置举例

Stub区域不能引入外部路由,为此又产生了NSSA区域的概念。NSSA区域中允许Type7 LSA(NSSA External LSA)的传播。Type7 LSA由NSSA区域的ASBR产生,当它到达NSSA区域的ABR时,可以由ABR转换成Type5 LSA(AS External LSA),并通告到其他区域。

1.4.1  组网需求

图3所示网络,通过将区域1配置为NSSA区域,实现区域1中Switch C所连外部网络的路由能够在OSPF内进行传播,并保持Stub区域的其他过滤功能。

图3 配置OSPF NSSA区域组网图

 

1.4.2  配置注意事项

·     假如已经配置为了stub区域,则需要先通过undo stub命令,取消stub区域配置,才能配置NSSA属性。

·     所有NSSA区域内的路由器必须使用nssa命令将该区域配置成NSSA属性。

·     虚连接不能穿过NSSA区域。

1.4.3  配置步骤

(1)     配置各接口的IP地址(略)

(2)     配置OSPF(同前例1.2 

(3)     配置Switch D引入静态路由(同前例1.3 

(4)     配置Area1区域为NSSA区域

# 配置Switch A。

[SwitchA] ospf

[SwitchA-ospf-1] area 1

[SwitchA-ospf-1-area-0.0.0.1] nssa default-route-advertise no-summary

[SwitchA-ospf-1-area-0.0.0.0] quit

[SwitchA-ospf-1] quit

# 配置Switch C。

[SwitchC] ospf

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] nssa

[SwitchC-ospf-1-area-0.0.0.1] quit

[SwitchC-ospf-1] quit

说明

·     如果NSSA区域内路由器(本例中的Switch C)需要获取通往AS外部的路由,需要在ABR(本例中的Switch A)上配置default-route-advertise参数,这样Switch C可以获取到一条缺省路由,所有到达自治系统外部的报文都交给ABR进行转发。

·     建议在ABR(本例中的Switch A)上配置no-summary参数,这样可以减少NSSA路由器的路由表数量。其他NSSA路由器只需配置nssa命令就可以。

 

# 查看Switch C的OSPF路由表,可以看到NSSA区域内路由器没有区域外部路由,只保留了一条通往区域外部的缺省路由。

[SwitchC] display ospf routing

          OSPF Process 1 with Router ID 172.16.1.1

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type      NextHop        AdvRouter       Area

 0.0.0.0/0         1563  Inter     192.168.1.1    192.168.0.1     0.0.0.1

 172.16.1.0/24     1     Stub      172.16.1.1     172.16.1.1      0.0.0.1

 192.168.1.0/24    1562  Stub      192.168.1.2    172.16.1.1      0.0.0.1

 

 Total Nets: 3

 Intra Area: 2  Inter Area: 1  ASE: 0  NSSA: 0

(5)     配置Switch C引入静态路由

[SwitchC] ip route-static 100.0.0.0 8 null 0

[SwitchC] ospf

[SwitchC-ospf-1] import-route static

[SwitchC-ospf-1] quit

1.4.4  验证配置

# 查看Switch D的OSPF路由表,可以看到NSSA区域引入的AS外部的路由,可以在OSPF区域内传播。

[SwitchD-ospf-1] display ospf routing

          OSPF Process 1 with Router ID 172.17.1.1

                   Routing Tables

 

 Routing for Network

 Destination       Cost  Type       NextHop        AdvRouter      Area

 172.16.1.0/24     4687  Inter      192.168.2.1    192.168.0.2    0.0.0.2

 172.17.1.0/24     1     Transit    172.17.1.1     172.17.1.1     0.0.0.2

 192.168.1.0/24    4686  Inter      192.168.2.1    192.168.0.2    0.0.0.2

 192.168.2.0/24    1562  Transit    192.168.2.2    172.17.1.1     0.0.0.2

 192.168.0.0/24    3124  Inter      192.168.2.1    192.168.0.2    0.0.0.2

 Routing for ASEs

 Destination       Cost     Type      Tag       NextHop       AdvRouter

 100.0.0.0/8       10       Type2     1         192.168.2.1   192.168.0.1

 

 Routing for NSSAs

 Destination        Cost      Type       Tag         NextHop         AdvRouter

 

 Total Nets: 6

 Intra Area: 2  Inter Area: 3  ASE: 1  NSSA: 0

1.4.5  配置文件

·     Switch A

#

 router id 192.168.1.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  nssa default-route-advertise no-summary

#

·     Switch B

#

 router id 192.168.2.1

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 192.168.0.2 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.2.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

#

·     Switch C

#

 router id 192.168.1.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

  nssa

 import-route static

#

 ip route-static 100.0.0.0 255.0.0.0 NULL0

#

·     Switch D

#

 router id 192.168.2.2

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 192.168.2.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.17.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

 import-route static

#

 ip route-static 200.0.0.0 255.0.0.0 NULL0

#

1.5  OSPF应用于分支机构网络的典型配置举例

1.5.1  组网需求

图4所示网络,160.1.0.0/16和160.2.0.0/16两个分支网络分别连接到Switch A、Switch B两台汇聚交换机,两台汇聚交换机双上行(提供冗余备份链路)连接到两台核心交换机Switch C、Switch D,核心交换机负责连接外部网络。通过配置路由功能实现分支网络和外部网络路由互通,并通过在汇聚交换机配置路由聚合降低发布出去的路由表条目数。

图4 OSPF应用于分支机构网络的典型配置举例

设备

接口

IP地址

设备

接口

IP地址

Switch A

Vlan-int100

10.1.1.1/24

Switch C

Vlan-int100

10.1.1.2/24

 

Vlan-int200

10.1.2.1/24

 

Vlan-int300

10.1.3.2/24

Switch B

Vlan-int300

10.1.3.1/24

Switch D

Vlan-int200

10.1.2.2/24

 

Vlan-int400

10.1.4.1/24

 

Vlan-int400

10.1.4.2/24

 

1.5.2  配置思路

可以通过如下配置,实现访问需求:

·     将分支网络中的主机网关地址配置为与之连接的交换机接口地址。

·     在汇聚交换机和核心交换机上配置OSPF路由协议。

·     在汇聚交换机上将去往分支网络的路由引入到OSPF网络,让两台核心层设备能够通过OSPF学习到去往分支网络的路由。

·     在汇聚交换机上配置路由聚合。

·     在核心交换机上通过BGP学习路由,并将BGP学到的路由引入到OSPF网络(目前SMB交换机不支持BGP)。

1.5.3  配置步骤

本配置举例仅列出与OSPF相关内容,有关BGP路由学习和引入的内容请参见BGP配置指导。

(1)     配置接口的IP地址(略)

(2)     配置OSPF

# 配置Switch A。

<SwitchA> system-view

[SwitchA] ospf

[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] network 10.1.2.0 0.0.0.255

[SwitchA-ospf-1-area-0.0.0.0] quit

[SwitchA-ospf-1] quit

# 配置Switch B。

<SwitchB> system-view

[SwitchB] ospf

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 10.1.3.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] network 10.1.4.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] ospf

[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] network 10.1.3.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.0] quit

[SwitchC-ospf-1] quit

# 配置Switch D。

<SwitchD> system-view

[SwitchD] ospf

[SwitchD-ospf-1] area 0

[SwitchD-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.0] network 10.1.4.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.0] quit

[SwitchC-ospf-1] quit

# 查看Switch A的路由表信息(假定Switch A下连三个分支网络)。

[SwitchA] display ip routing-table

Routing Tables: Public

         Destinations : 14       Routes : 14

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

10.1.1.0/24         Direct 0    0            10.1.1.1        Vlan100

10.1.1.1/32         Direct 0    0            127.0.0.1       InLoop0

10.1.2.0/24         Direct 0    0            10.1.2.1        Vlan200

10.1.2.1/32         Direct 0    0            127.0.0.1       InLoop0  

10.1.3.0/24         OSPF   10   2            10.1.1.2        Vlan100

10.1.4.0/24         OSPF   10   2            10.1.2.2        Vlan200

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

160.1.1.0/24        Direct 0    0            160.1.1.1       Vlan1

160.1.1.1/32        Direct 0    0            127.0.0.1       InLoop0

160.1.2.0/24        Direct 0    0            160.1.2.1       Vlan2

160.1.2.1/32        Direct 0    0            127.0.0.1       InLoop0

160.1.3.0/24        Direct 0    0            160.1.3.1       Vlan3

160.1.3.1/32        Direct 0    0            127.0.0.1       InLoop0

(3)     配置路由引入

# 在Switch A上配置OSPF引入直连路由(一部分分支网络与Switch A直连),只发布聚合路由160.1.0.0/16。

[SwitchA] ospf

[SwitchA-ospf-1] import-route direct

[SwitchA-ospf-1] asbr-summary 160.1.0.0 16

# 在Switch B上配置OSPF引入直连路由(另一部分各分支网络与Switch B直连),只发布聚合路由160.2.0.0/16。

[SwitchB] ospf

[SwitchB-ospf-1] import-route direct

[SwitchB-ospf-1] asbr-summary 160.2.0.0 16

# 在Switch C上配置OSPF引入BGP路由。

[SwitchC] ospf

[SwitchC-ospf-1] import-route bgp

# 在Switch D上配置OSPF引入BGP路由。

[SwitchD] ospf

[SwitchD-ospf-1] import-route bgp

1.5.4  配置文件

·     Switch A

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 10.1.1.1 255.255.255.0

#

interface Vlan-interface200

 ip address 10.1.2.1 255.255.255.0

#

ospf 1

 asbr-summary 160.1.0.0 255.255.0.0

 import-route direct

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

  network 10.1.2.0 0.0.0.255

#

·     Switch B

#

vlan 300

#

vlan 400

#

interface Vlan-interface300

 ip address 10.1.3.1 255.255.255.0

#

interface Vlan-interface400

 ip address 10.1.4.1 255.255.255.0

#

ospf 1

 asbr-summary 160.2.0.0 255.255.0.0

 import-route direct

 area 0.0.0.0

  network 10.1.3.0 0.0.0.255

  network 10.1.4.0 0.0.0.255

#

·     Switch C

#

vlan 100

#

vlan 300

#

interface Vlan-interface100

 ip address 10.1.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 10.1.3.2 255.255.255.0

#

ospf 1

 import-route bgp

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

  network 10.1.3.0 0.0.0.255

#

·     Switch D

#

vlan 200

#

vlan 400

#

interface Vlan-interface200

 ip address 10.1.2.2 255.255.255.0

#

interface Vlan-interface400

 ip address 10.1.4.2 255.255.255.0

#

ospf 1

 import-route bgp

 area 0.0.0.0

  network 10.1.2.0 0.0.0.255

  network 10.1.4.0 0.0.0.255

#

1.6  OSPF在AS间发布聚合路由的典型配置举例

1.6.1  组网需求

图5所示网络分为两个AS(Autonomous System,自治系统),在AS之间通过BGP(Border Gateway Protocol,边界网关协议)进行路由协议交换,OSPF作为内部网关路由协议,与BGP结合获取网络间路由信息。通过配置Switch B在引入外部AS的路由时进行聚合,从而减少AS 200内的路由条目数。

图5 OSPF在AS间发布聚合路由的典型配置指导

 

1.6.2  配置注意事项

·     配置asbr-summary命令后,对处于聚合地址范围内的外部路由,本地路由器只向邻居路由器发布一条聚合后的路由;配置undo asbr-summary命令后,原来被聚合的外部路由将重新被发布。

·     配置引入OSPF路由到BGP中时,需要注意被引入的路由必须在OSPF路由表中处于Active状态。

·     目前SMB交换机不支持BGP。

1.6.3  配置步骤

(1)     配置接口的IP地址(略)

(2)     配置OSPF

# 配置Switch A。

<SwitchA> system-view

[SwitchA] ospf

[SwitchA-ospf-1] area 0

[SwitchA-ospf-1-area-0.0.0.0] network 11.2.1.0 0.0.0.255

[SwitchA-ospf-1-area-0.0.0.0] quit

[SwitchA-ospf-1] quit

# 配置Switch B。

<SwitchB> system-view

[SwitchB] ospf

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 11.2.1.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] ospf

[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] network 10.2.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.0] quit

[SwitchC-ospf-1] quit

# 配置Switch D。

<SwitchD> system-view

[SwitchD] ospf

[SwitchD-ospf-1] area 0

[SwitchD-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.0] network 10.3.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.0] quit

# 配置Switch E。

<SwitchE> system-view

[SwitchE] ospf

[SwitchE-ospf-1] area 0

[SwitchE-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255

[SwitchE-ospf-1-area-0.0.0.0] network 10.4.1.0 0.0.0.255

[SwitchE-ospf-1-area-0.0.0.0] quit

[SwitchE-ospf-1] quit

(3)     配置BGP

# 配置Switch B。

<SwitchB> system-view

[SwitchB] bgp 200

[SwitchB-bgp] peer 11.1.1.2 as-number 100

[SwitchB-bgp] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] bgp 100

[SwitchC-bgp] peer 11.1.1.1 as-number 200

(4)     在Switch B、Switch C上配置路由引入

# 在配置Switch C上配置BGP引入OSPF路由。

[SwitchC-bgp] import-route ospf

# 在配置Switch C上配置BGP引入直连路由。

[SwitchC-bgp] import-route direct

# 在Switch C上配置OSPF引入BGP路由。

[SwitchC] ospf

[SwitchC-ospf-1] import-route bgp

# 在配置Switch B上配置BGP引入OSPF路由。

[SwitchB-bgp] import-route ospf

# 在配置Switch B上配置BGP引入直连路由。

[SwitchB] bgp 200

[SwitchB-bgp] import-route direct

# 在Switch B上配置OSPF引入BGP路由。

[SwitchB] ospf

[SwitchB-ospf-1] import-route bgp

# 查看Switch A的路由表信息。

[SwitchA] display ip routing-table

Routing Tables: Public

         Destinations : 8        Routes : 8

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

10.1.1.0/24         O_ASE  150  1            11.2.1.1        Vlan100

10.2.1.0/24         O_ASE  150  1            11.2.1.1        Vlan100

10.3.1.0/24         O_ASE  150  1            11.2.1.1        Vlan100

10.4.1.0/24         O_ASE  150  1            11.2.1.1        Vlan100

11.2.1.0/24         Direct 0    0            11.2.1.2        Vlan100

11.2.1.2/32         Direct 0    0            127.0.0.1       InLoop0

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

(5)     在Switch B上配置ASBR路由聚合,将引入的路由聚合为10.0.0.0/8进行发布。

[SwitchB-ospf-1] asbr-summary 10.0.0.0 8

1.6.4  验证配置

#此时 查看Switch A的路由表信息,可以发现引入的路由已经聚合为一条10.0.0.0/8的路由。

[SwitchA] display ip routing-table

Routing Tables: Public

         Destinations : 5        Routes : 5

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

10.0.0.0/8          O_ASE  150  2            11.2.1.1        Vlan100

11.2.1.0/24         Direct 0    0            11.2.1.2        Vlan100

11.2.1.2/32         Direct 0    0            127.0.0.1       InLoop0

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

1.6.5  配置文件

·     Switch A

#

vlan 100

#

interface Vlan-interface100

 ip address 11.2.1.2 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 11.2.1.0 0.0.0.255

#

·     Switch B

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 11.2.1.1 255.255.255.0

#

interface Vlan-interface200

 ip address 11.1.1.1 255.255.255.0

#

bgp 200

 undo synchronization

 peer 11.1.1.2 as-number 100

 import-route direct

#

ospf 1

 asbr-summary 10.0.0.0 255.0.0.0

 import-route bgp

 area 0.0.0.0

  network 11.2.1.0 0.0.0.255

#

·     Switch C

#

vlan 200

#

vlan 300

#

vlan 400

#

interface Vlan-interface200

 ip address 11.1.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 10.2.1.1 255.255.255.0

#

interface Vlan-interface400

 ip address 10.1.1.2 255.255.255.0

#

bgp 100

 import-route ospf 1

 undo synchronization

 peer 11.1.1.1 as-number 200

 import-route direct

#

ospf 1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

network 10.2.1.0 0.0.0.255

import-route bgp

#

·     Switch D

#

vlan 400

#

vlan 500

#

interface Vlan-interface400

 ip address 10.1.1.1 255.255.255.0

#

interface Vlan-interface500

 ip address 10.3.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

  network 10.3.1.0 0.0.0.255

#

·     Switch E

#

vlan 300

#

vlan 600

#

interface Vlan-interface300

 ip address 10.2.1.2 255.255.255.0

#

interface Vlan-interface600

 ip address 10.4.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 10.2.1.0 0.0.0.255

  network 10.4.1.0 0.0.0.255

#

1.7  OSPF的DR选择典型配置举例

1.7.1  组网需求

图6所示网络,所有交换机在同一网段,运行OSPF协议。通过对设备DR优先级的调整,使Switch A成为DR、Switch C成为BDR。

图6 配置OSPF的DR选择组网图

 

1.7.2  配置注意事项

·     路由器的优先级可以影响DR/BDR的选举过程,但是当DR/BDR已经选举完毕,就算一台具有更高优先级的路由器变为有效,也不会替换该网段中已经存在的DR/BDR成为新的DR/BDR。所以当前DR并不一定就是路由器优先级最高的路由器接口;同理,BDR也并不一定就是路由器优先级次高的路由器接口。

·     DR是某个网段中的概念,是针对路由器的接口而言的。某台路由器在一个接口上可能是DR,在另一个接口上有可能是BDR,或者是DR Other。

1.7.3  配置步骤

(1)     配置各接口的IP地址(略)

(2)     配置OSPF基本功能

# 配置Switch A。

<SwitchA> system-view

[SwitchA] router id 1.1.1.1

[SwitchA] ospf

[SwitchA-ospf-1] area 0

[SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[SwitchA-ospf-1-area-0.0.0.0] quit

[SwitchA-ospf-1] quit

# 配置Switch B。

<SwitchB> system-view

[SwitchB] router id 2.2.2.2

[SwitchB] ospf

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

[SwitchB-ospf-1] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] router id 3.3.3.3

[SwitchC] ospf

[SwitchC-ospf-1] area 0

[SwitchC-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.0] quit

[SwitchC-ospf-1] quit

# 配置Switch D。

<SwitchD> system-view

[SwitchD] router id 4.4.4.4

[SwitchD] ospf

[SwitchD-ospf-1] area 0

[SwitchD-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.0] quit

[SwitchD-ospf-1] quit

# 查看Switch A的邻居信息。

[SwitchA] display ospf peer verbose

 

          OSPF Process 1 with Router ID 1.1.1.1

                  Neighbors

 

 Area 0.0.0.0 interface 192.168.1.1(Vlan-interface1)'s neighbors

 Router ID: 2.2.2.2          Address: 192.168.1.2      GR State: Normal

   State: 2-Way  Mode: None  Priority: 1

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 38  sec

   Neighbor is up for 00:01:31

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 3.3.3.3          Address: 192.168.1.3      GR State: Normal

   State: Full  Mode: Nbr is Master  Priority: 1

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 31  sec

   Neighbor is up for 00:01:28

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 4.4.4.4          Address: 192.168.1.4      GR State: Normal

   State: Full  Mode: Nbr is Master  Priority: 1

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 31  sec

   Neighbor is up for 00:01:28

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

可以看到Switch D为DR,Switch C为BDR。

(3)     配置接口的DR优先级

# 配置Switch A。

[SwitchA] interface vlan-interface 1

[SwitchA-Vlan-interface1] ospf dr-priority 3

[SwitchA-Vlan-interface1] quit

# 配置Switch C。

[SwitchC] interface vlan-interface 1

[SwitchC-Vlan-interface1] ospf dr-priority 2

[SwitchC-Vlan-interface] quit

# 配置Switch D。

[SwitchD] interface vlan-interface 1

[SwitchD-Vlan-interface1] ospf dr-priority 1

[SwitchD-Vlan-interface] quit

# 配置Switch B。

[SwitchB] interface vlan-interface 1

[SwitchB-Vlan-interface1] ospf dr-priority 0

[SwitchB-Vlan-interface1] quit

# 查看Switch D的邻居信息。

[SwitchD] display ospf peer verbose

 

          OSPF Process 1 with Router ID 4.4.4.4

                  Neighbors

 

 Area 0.0.0.0 interface 192.168.1.4(Vlan-interface1)'s neighbors

 Router ID: 1.1.1.1      Address: 192.168.1.1      GR State: Normal

   State: Full  Mode:Nbr is  Slave  Priority: 3

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 31  sec

   Neighbor is up for 00:11:17

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 3

 

 Router ID: 2.2.2.2      Address: 192.168.1.2      GR State: Normal

   State: Full  Mode:Nbr is  Slave  Priority: 0

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 35  sec

   Neighbor is up for 00:11:19

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 3

 

 Router ID: 3.3.3.3      Address: 192.168.1.3      GR State: Normal

   State: Full  Mode:Nbr is  Slave  Priority: 2

   DR: 192.168.1.4  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 33  sec

   Neighbor is up for 00:11:15

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 3

可以看到,网络中DR/BDR并没有改变。

说明

网络中DR/BDR已经存在的情况下,接口上的路由器优先级的配置并不会立即生效。

 

1.7.4  验证配置

# 重启当前DR Switch D的进程。

<SwitchD> reset ospf 1 process

Warning : Reset OSPF process? [Y/N]:y

# 待网络稳定后,查看Switch D的邻居信息,可以看到原BDR Switch C成为DR,其余交换机中优先级最高的Switch A选举为BDR。

[SwitchD] display ospf peer verbose

 

          OSPF Process 1 with Router ID 4.4.4.4

                  Neighbors

 

 Area 0.0.0.0 interface 192.168.1.4(Vlan-interface1)'s neighbors

 Router ID: 1.1.1.1          Address: 192.168.1.1      GR State: Normal

   State: Full  Mode: Nbr is Slave  Priority: 3

   DR: 192.168.1.3  BDR: 192.168.1.1  MTU: 0

   Dead timer due in 39  sec

   Neighbor is up for 00:01:40

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 2.2.2.2          Address: 192.168.1.2      GR State: Normal

   State: 2-Way  Mode: None  Priority: 0

   DR: 192.168.1.3  BDR: 192.168.1.1  MTU: 0

   Dead timer due in 35  sec

   Neighbor is up for 00:01:44

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 3.3.3.3          Address: 192.168.1.3      GR State: Normal

   State: Full  Mode: Nbr is Slave  Priority: 2

   DR: 192.168.1.3  BDR: 192.168.1.1  MTU: 0

   Dead timer due in 39  sec

   Neighbor is up for 00:01:41

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

# 重启当前DR Switch C的进程。

<SwitchC> reset ospf 1 process

Warning : Reset OSPF process? [Y/N]:y

# 待网络稳定后,查看Switch D的邻居信息,可以看到原BDR Switch A成为DR,其余交换机中优先级最高的Switch C选举为BDR。

[SwitchD] display ospf peer verbose

 

          OSPF Process 1 with Router ID 4.4.4.4

                  Neighbors

 

 Area 0.0.0.0 interface 192.168.1.4(Vlan-interface1)'s neighbors

 Router ID: 1.1.1.1          Address: 192.168.1.1      GR State: Normal

   State: Full  Mode: Nbr is Slave  Priority: 3

   DR: 192.168.1.1  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 39  sec

   Neighbor is up for 00:01:40

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 2.2.2.2          Address: 192.168.1.2      GR State: Normal

   State: 2-Way  Mode: None  Priority: 0

   DR: 192.168.1.1  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 35  sec

   Neighbor is up for 00:01:44

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

 

 Router ID: 3.3.3.3          Address: 192.168.1.3      GR State: Normal

   State: Full  Mode: Nbr is Slave  Priority: 2

   DR: 192.168.1.1  BDR: 192.168.1.3  MTU: 0

   Dead timer due in 39  sec

   Neighbor is up for 00:01:41

   Authentication Sequence: [ 0 ]

   Neighbor state change count: 2

说明

·     如果邻居的状态是Full,这说明它和邻居之间形成了邻接关系;

·     如果邻居的状态是2-Way,则说明它们都不是DR或BDR,两者之间不需要交换LSA。

 

# 查看OSPF接口的状态。

[SwitchA] display ospf interface

 

          OSPF Process 1 with Router ID 1.1.1.1

                  Interfaces

 

 Area: 0.0.0.0

 IP Address      Type      State   Cost  Pri   DR             BDR

 192.168.1.1     Broadcast DR      1     100   192.168.1.1    192.168.1.3

 

[SwitchB] display ospf interface

 

          OSPF Process 1 with Router ID 2.2.2.2

                  Interfaces

 

 Area: 0.0.0.0

 IP Address      Type      State    Cost  Pri   DR            BDR

 192.168.1.2     Broadcast DROther  1     0     192.168.1.1   192.168.1.3

说明

如果OSPF接口的状态是DROther,则说明它既不是DR,也不是BDR。

 

1.7.5  配置文件

·     Switch A

#

 router id 1.1.1.1

#

interface Vlan-interface1

 ip address 192.168.1.1 255.255.255.0

 ospf dr-priority 3

#

ospf 1

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

·     Switch B

#

 router id 2.2.2.2

#

interface Vlan-interface1

 ip address 192.168.1.2 255.255.255.0

 ospf dr-priority 0

#

ospf 1

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

·     Switch C

#

 router id 3.3.3.3

#

interface Vlan-interface1

 ip address 192.168.1.3 255.255.255.0

 ospf dr-priority 2

#

ospf 1

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

·     Switch D

#

 router id 4.4.4.4

#

interface Vlan-interface1

 ip address 192.168.1.4 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

1.8  OSPF虚连接典型配置举例

1.8.1  组网需求   

图7所示网络,Area 2与Area 0没有直接相连。Area 2区域中路由器无法获得其他区域路由,其他区域内路由器也无法获取Area 2内相关网络的路由信息。通过在Area 1配置虚连接将整个网络连通,实现路由信息全网交换。

图7 配置OSPF虚连接组网图

 

1.8.2  配置注意事项

·     为使虚连接生效,在虚连接的两端都需配置vlink-peer命令,并且两端配置的hellodead等参数必须一致。

·     vlink-peer命令采用指定对端Router ID来创建虚连接,创建前注意查看对端Router ID,这并不一定是对端相连接口的地址。

·     虚连接不能穿过Stub区域和NSSA区域。

1.8.3  配置步骤

(1)     配置各接口的IP地址(略)

(2)     配置OSPF基本功能

# 配置Switch A。

<SwitchA> system-view

[SwitchA] ospf 1 router-id 1.1.1.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

# 配置Switch B。

<SwitchB> system-view

[SwitchB] ospf 1 router-id 2.2.2.2

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

[SwitchB-ospf-1] area 1

[SwitchB–ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[SwitchB–ospf-1-area-0.0.0.1] quit

# 配置Switch C。

<SwitchC> system-view

[SwitchC] ospf 1 router-id 3.3.3.3

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.1] quit

[SwitchC-ospf-1] area 2

[SwitchC–ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[SwitchC–ospf-1-area-0.0.0.2] quit

# 配置Switch D。

<SwitchD> system-view

[SwitchD] ospf 1 router-id 4.4.4.4

[SwitchD-ospf-1] area 2

[SwitchD-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.2] quit

# 查看Switch B的OSPF路由表。

[SwitchB] display ospf routing

          OSPF Process 1 with Router ID 2.2.2.2

                   Routing Tables

 Routing for Network

 Destination        Cost     Type    NextHop         AdvRouter       Area

 10.2.1.0/24        2        Transit 10.2.1.1        3.3.3.3         0.0.0.1

 10.1.1.0/24        2        Transit 10.1.1.2        2.2.2.2         0.0.0.0

 Total Nets: 2

 Intra Area: 2  Inter Area: 0  ASE: 0  NSSA: 0

说明

由于Area 0没有与Area 2直接相连,所以Switch B的路由表中没有Area 2的路由。

 

(3)     配置虚连接

# 配置Switch B,通过Area 1与对端Switch C建立虚连接。

[SwitchB] ospf

[SwitchB-ospf-1] area 1

[SwitchB-ospf-1-area-0.0.0.1] vlink-peer 3.3.3.3

[SwitchB-ospf-1-area-0.0.0.1] quit

[SwitchB-ospf-1] quit

# 配置Switch C,通过Area 1与对端Switch B建立虚连接。

[SwitchC] ospf 1

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] vlink-peer 2.2.2.2

[SwitchC-ospf-1-area-0.0.0.1] quit

1.8.4  验证配置

#配置完成后查看Switch B的OSPF路由表。

[SwitchB] display ospf routing

          OSPF Process 1 with Router ID 2.2.2.2

                   Routing Tables

 Routing for Network

 Destination        Cost     Type    NextHop         AdvRouter       Area

 10.2.1.0/24        2        Transit 10.2.1.1        3.3.3.3         0.0.0.1

 10.3.1.0/24        5        Inter   10.2.1.2        3.3.3.3         0.0.0.0

 10.1.1.0/24        2        Transit 10.1.1.2        2.2.2.2         0.0.0.0

 Total Nets: 3

 Intra Area: 2  Inter Area: 1  ASE: 0  NSSA: 0

可以看到,Switch B已经学到了Area2的路由10.3.1.0/24。

1.8.5  配置文件

·     Switch A

#

vlan 300

#

interface Vlan-interface300

 ip address 10.1.1.1 255.255.255.0

#

ospf 1 router-id 1.1.1.1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

#

·     Switch B

#

vlan 200

#

vlan 300

#

interface Vlan-interface200

 ip address 10.2.1.1 255.255.255.0

#

interface Vlan-interface300

 ip address 10.1.1.2 255.255.255.0

#

ospf 1 router-id 2.2.2.2

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

 area 0.0.0.1

  network 10.2.1.0 0.0.0.255

  vlink-peer 3.3.3.3

#

·     Switch C

#

vlan 100

#

vlan 200

#

interface Vlan-interface100

 ip address 10.3.1.2 255.255.255.0

#

interface Vlan-interface200

 ip address 10.2.1.2 255.255.255.0

#

ospf 1 router-id 3.3.3.3

 area 0.0.0.1

  network 10.2.1.0 0.0.0.255

  vlink-peer 2.2.2.2

 area 0.0.0.2

  network 10.3.1.0 0.0.0.255

#

·     Switch D

#

vlan 100

#

interface Vlan-interface100

 ip address 10.3.1.1 255.255.255.0

#

ospf 1 router-id 4.4.4.4

 area 0.0.0.2

  network 10.3.1.0 0.0.0.255

#

 

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们