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

H3C 园区盒式交换机典型配置举例-6W100

目录

16-OSPF典型配置举例

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

docurl=/cn/Service/Document_Software/Document_Center/Home/Switches/00-Public/Configure/Typical_Configuration_Example/H3C_CE-B70D022-6W100/202012/1371441_30005_0.htm

16-OSPF典型配置举例


1  简介

本文档介绍了OSPF路由信息过滤的配置举例。

2  配置前提

本文档不严格与具体软、硬件版本对应,如果使用过程中与产品实际情况有差异,请参考相关产品手册,或以设备实际情况为准。

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文档假设您已了解OSPF路由信息过滤的特性。

3  OSPF路由信息过滤配置举例

3.1  组网需求

图1所示,公司A使用OSPF路由协议实现公司设备全网互通,后来公司A扩张兼并了公司B,要求将公司B采用的RIP路由协议与公司A的OSPF协议互相引入,使得各个部门可以实现互通。Device A和Device B作为公司核心设备负责各个部门间的通信。由于业务需要,现要求通过下列措施控制并调整网络中的路由信息:

·            在Device E上对引入的路由信息进行过滤,使得研发二部所在网段无法被引入到OSPF内。

·            在Device C上使用路由信息的过滤功能,使得市场一部所在网段无法访问研发一部。

·            在Device D上使用路由信息的过滤功能,使得研发一部和售后服务部所在网段无法访问市场二部。

图1 OSPF路由信息过滤组网图

设备

接口

IP地址

设备

接口

IP地址

Device A

Vlan-int100

10.1.1.1/24

Device B

Vlan-int100

10.1.1.2/24

 

Vlan-int200

10.2.1.1/24

 

Vlan-int300

10.3.1.1/24

 

Vlan-int400

10.4.1.1/24

 

 

 

Device C

Vlan-int200

10.2.1.2/24

Device D

Vlan-int300

10.3.1.2/24

 

Loop0

192.168.3.1/24

(市场一部所在网段)

 

Loop0

192.168.1.1/24

(售后服务部所在网段)

 

 

 

 

Loop1

192.168.2.1/24

(研发一部所在网段)

Device E

Vlan-int400

10.4.1.2/24

Device F

Vlan-int500

10.5.1.2/24

 

Vlan-int500

10.5.1.1/24

 

Loop0

192.168.4.1/24

(研发二部所在网段)

 

 

 

 

Loop1

192.168.5.1/24

(市场二部所在网段)

 

3.2  适用产品及版本

表1 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

不支持

S5000V3-EI系列

不支持

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

3.3  配置注意事项

·            路由信息过滤功能中对于引入外部路由信息时采用export关键字进行过滤,该参数只能在ASBR上生效。

·            路由信息过滤功能只是对路由表中相关路由信息过滤,并不是过滤掉OSPF中通告的LSA。

·            由于路由通信是双向的,使用路由信息过滤功能将某一目的网段过滤后,该路由器下联的其它网段无法访问这个目的网段的设备,这个目的网段的设备也不能访问源地址网段的设备。

·            使用路由信息过滤功能配合ACL使用时,必须将最后一条规则设置为允许所有源地址通过才能避免将所有网段路由全部过滤掉。

3.4  配置步骤

3.4.1  配置各接口的IP地址

# 配置接口Vlan-int100的IP地址。

<DeviceA> system-view

[DeviceA] interface vlan-interface 100

[DeviceA-Vlan-interface100] ip address 10.1.1.1 24

# 请参考以上方法配置其它相关接口的IP地址,具体配置步骤略。

3.4.2  配置OSPF网络的基本功能

# 在Device A上使能指定网段的OSPF路由功能。

<DeviceA> system-view

[DeviceA] ospf

[DeviceA-ospf-1] area 0

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

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

[DeviceA-ospf-1] area 2

[DeviceA-ospf-1-area-0.0.0.2] network 10.2.1.0 0.0.0.255

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

[DeviceA-ospf-1] area 1

[DeviceA-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255

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

[DeviceA-ospf-1] quit

# 在Device B上使能指定网段的OSPF路由功能。

<DeviceB> system-view

[DeviceB] ospf

[DeviceB-ospf-1] area 0

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

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

[DeviceB-ospf-1] area 3

[DeviceB-ospf-1-area-0.0.0.3] network 10.3.1.0 0.0.0.255

[DeviceB-ospf-1-area-0.0.0.3] quit

[DeviceB-ospf-1] quit

# 在Device C上使能指定网段的OSPF路由功能。

<DeviceC> system-view

[DeviceC] ospf

[DeviceC-ospf-1] area 2

[DeviceC-ospf-1-area-0.0.0.2] network 10.2.1.0 0.0.0.255

[DeviceC-ospf-1-area-0.0.0.2] network 192.168.3.0 0.0.0.255

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

[DeviceC-ospf-1] quit

# 在Device D上使能指定网段的OSPF路由功能。

<DeviceD> system-view

[DeviceD] ospf

[DeviceD-ospf-1] area 3

[DeviceD-ospf-1-area-0.0.0.3] network 10.3.1.0 0.0.0.255

[DeviceD-ospf-1-area-0.0.0.3] network 192.168.1.0 0.0.0.255

[DeviceD-ospf-1-area-0.0.0.3] network 192.168.2.0 0.0.0.255

[DeviceD-ospf-1-area-0.0.0.3] quit

[DeviceD-ospf-1] quit

# 在Device E上使能指定网段的OSPF路由功能。

<DeviceE> system-view

[DeviceE] ospf

[DeviceE-ospf-1] area 1

[DeviceE-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255

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

[DeviceE-ospf-1] quit

3.4.3  配置RIP网络的基本功能

# 在Device E上使能指定网段的RIP功能。

<DeviceE> system-view

[DeviceE] rip

[DeviceE-rip-1] version 2

[DeviceE-rip-1] undo summary

[DeviceE-rip-1] network 10.5.1.0 0.0.0.255

[DeviceE-rip-1] quit

# 在Device F上使能指定网段的RIP功能。

<DeviceF> system-view

[DeviceF] rip

[DeviceF-rip-1] version 2

[DeviceF-rip-1] undo summary

[DeviceF-rip-1] network 10.5.1.0 0.0.0.255

[DeviceF-rip-1] network 192.168.4.0 0.0.0.255

[DeviceF-rip-1] network 192.168.5.0 0.0.0.255

[DeviceF-rip-1] quit

3.4.4  将RIP路由和OSPF路由互相引入

# 在Device E上将直连路由和OSPF路由引入到RIP网络中。

<DeviceE> system-view

[DeviceE] rip

[DeviceE-rip-1] import-route direct

[DeviceE-rip-1] import-route ospf

[DeviceE-rip-1] quit

# 在Device E上将直连路由和RIP路由引入到OSPF网络中。

[DeviceE] ospf

[DeviceE-ospf-1] import-route direct

[DeviceE-ospf-1] import-route rip

[DeviceE-ospf-1] quit

# 查看Device E的路由表信息。

[Device E] display ip routing-table

 

Destinations : 24        Routes : 24

 

Destination/Mask   Proto   Pre Cost        NextHop         Interface

0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0

10.1.1.0/24        O_INTER 10  2           10.4.1.1        Vlan400

10.2.1.0/24        O_INTER 10  2           10.4.1.1        Vlan400

10.3.1.0/24        O_INTER 10  3           10.4.1.1        Vlan400

10.4.1.0/24        Direct  0   0           10.4.1.2        Vlan400

10.4.1.0/32        Direct  0   0           10.4.1.2        Vlan400

10.4.1.2/32        Direct  0   0           127.0.0.1       InLoop0

10.4.1.255/32      Direct  0   0           10.4.1.2        Vlan400

10.5.1.0/24        Direct  0   0           10.5.1.1        Vlan500

10.5.1.0/32        Direct  0   0           10.5.1.1        Vlan500

10.5.1.1/32        Direct  0   0           127.0.0.1       InLoop0

10.5.1.255/32      Direct  0   0           10.5.1.1        Vlan500

127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0

127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0

127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0

127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

192.168.1.1/32     O_INTER 10  3           10.4.1.1        Vlan400

192.168.2.1/32     O_INTER 10  3           10.4.1.1        Vlan400

192.168.3.1/32     O_INTER 10  2           10.4.1.1        Vlan400

192.168.4.0/24     RIP     100 1           10.5.1.2        Vlan500

192.168.5.0/24     RIP     100 1           10.5.1.2        Vlan500

224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0

224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0

255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

以上显示信息表明Device E拥有路由域内所有网段路由,然后依次查看其他所有设备的路由表信息,路由域内所有的网段均可互通。

3.4.5  配置OSPF的路由过滤功能

# 在Device C上创建基本ACL并匹配需要拒绝访问的目的网段192.168.2.0/24。

<DeviceC> system-view

[DeviceC] acl basic 2000

[DeviceC-acl-ipv4-basic-2000] rule 0 deny source 192.168.2.0 0.0.0.255

[DeviceC-acl-ipv4-basic-2000] rule permit source any

[DeviceC-acl-ipv4-basic-2000] quit

# 在Device C上通过指定访问控制列表ACL 2000来对要加入到路由表的路由信息进行过滤。

[DeviceC] ospf

[DeviceC-ospf-1] filter-policy 2000 import

[DeviceC-ospf-1] quit

# 在Device D上创建基本ACL并匹配需要拒绝访问的目的网段192.168.5.0/24。

<DeviceD> system-view

[DeviceD] acl basic 2000

[DeviceD-acl-ipv4-basic-2000] rule 0 deny source 192.168.5.0 0.0.0.255

[DeviceD-acl-ipv4-basic-2000] rule permit source any

[DeviceD-acl-ipv4-basic-2000] quit

# 在Device D上通过指定访问控制列表ACL 2000来对要加入到路由表的路由信息进行过滤。

[DeviceD] ospf

[DeviceD-ospf-1] filter-policy 2000 import

[DeviceD-ospf-1] quit

# 在Device E上创建基本ACL并匹配需要拒绝访问的目的网段192.168.4.0/24。

<DeviceE> system-view

[DeviceE] acl basic 2000

[DeviceE-acl-ipv4-basic-2000] rule 0 deny source 192.168.4.0 0.0.0.255

[DeviceE-acl-ipv4-basic-2000] rule permit source any

[DeviceE-acl-ipv4-basic-2000] quit

# 在Device E上通过指定访问控制列表ACL 2000来对引入OSPF的RIP路由信息进行过滤。

[DeviceE] ospf

[DeviceE-ospf-1] filter-policy 2000 export rip 1

[DeviceE-ospf-1] quit

3.5  验证配置

# 查看Device C的路由表信息。

[DeviceC] display ip routing-table

 

Destinations : 22        Routes : 22

 

Destination/Mask   Proto   Pre Cost        NextHop         Interface

0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0

10.1.1.0/24        O_INTER 10  2           10.2.1.1        Vlan200

10.2.1.0/24        Direct  0   0           10.2.1.2        Vlan200

10.2.1.0/32        Direct  0   0           10.2.1.2        Vlan200

10.2.1.2/32        Direct  0   0           127.0.0.1       InLoop0

10.2.1.255/32      Direct  0   0           10.2.1.2        Vlan200

10.3.1.0/24        O_INTER 10  3           10.2.1.1        Vlan200

10.4.1.0/24        O_INTER 10  2           10.2.1.1        Vlan200

10.5.1.0/24        O_ASE2  150 1           10.2.1.1        Vlan200

127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0

127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0

127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0

127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

192.168.1.1/32     O_INTER 10  3           10.2.1.1        Vlan200

192.168.3.0/24     Direct  0   0           192.168.3.1     Loop0

192.168.3.0/32     Direct  0   0           192.168.3.1     Loop0

192.168.3.1/32     Direct  0   0           127.0.0.1       InLoop0

192.168.3.255/32   Direct  0   0           192.168.3.1     Loop0

192.168.5.0/24     O_ASE2  150 1           10.2.1.1        Vlan200

224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0

224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0

255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

以上显示信息表明Device C的路由表中已经没有192.168.2.0/24网段的路由信息了。

# 在Device C上使用源地址192.168.3.1Ping目标地址192.168.2.1进行验证。

[DeviceC] ping -a 192.168.3.1 192.168.2.1

Ping 192.168.2.1 (192.168.2.1) from 192.168.3.1: 56 data bytes, press CTRL_C to

break

Request time out

Request time out

Request time out

Request time out

Request time out

 

--- Ping statistics for 192.168.2.1 ---

5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss

以上信息表明Device C通过过滤路由表中192.168.2.0/24网段的路由信息,使得市场一部所在网段无法访问研发一部所在网段。

# 查看Device D的路由表信息。

[DeviceD] display ip routing-table

 

Destinations : 25        Routes : 25

 

Destination/Mask   Proto   Pre Cost        NextHop         Interface

0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0

10.1.1.0/24        O_INTER 10  2           10.3.1.1        Vlan300

10.2.1.0/24        O_INTER 10  3           10.3.1.1        Vlan300

10.3.1.0/24        Direct  0   0           10.3.1.2        Vlan300

10.3.1.0/32        Direct  0   0           10.3.1.2        Vlan300

10.3.1.2/32        Direct  0   0           127.0.0.1       InLoop0

10.3.1.255/32      Direct  0   0           10.3.1.2        Vlan300

10.4.1.0/24        O_INTER 10  3           10.3.1.1        Vlan300

10.5.1.0/24        O_ASE2  150 1           10.3.1.1        Vlan300

127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0

127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0

127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0

127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

192.168.1.0/24     Direct  0   0           192.168.1.1     Loop0

192.168.1.0/32     Direct  0   0           192.168.1.1     Loop0

192.168.1.1/32     Direct  0   0           127.0.0.1       InLoop0

192.168.1.255/32   Direct  0   0           192.168.1.1     Loop0

192.168.2.0/24     Direct  0   0           192.168.2.1     Loop1

192.168.2.0/32     Direct  0   0           192.168.2.1     Loop1

192.168.2.1/32     Direct  0   0           127.0.0.1       InLoop0

192.168.2.255/32   Direct  0   0           192.168.2.1     Loop1

192.168.3.1/32     O_INTER 10  3           10.3.1.1        Vlan300

224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0

224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0

255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

以上显示信息表明Device D的路由表中已经没有192.168.5.0/24网段的路由信息了。

# 在Device D上使用源地址192.168.1.1Ping目标地址192.168.5.1进行验证。

[DeviceD] ping -a 192.168.1.1 192.168.5.1

Ping 192.168.5.1 (192.168.5.1) from 192.168.1.1: 56 data bytes, press CTRL_C to

break

Request time out

Request time out

Request time out

Request time out

Request time out

 

--- Ping statistics for 192.168.5.1 ---

5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss

# 在Device D上使用源地址192.168.2.1Ping目标地址192.168.5.1进行验证。

[DeviceD] ping -a 192.168.2.1 192.168.5.1

Ping 192.168.5.1 (192.168.5.1) from 192.168.2.1: 56 data bytes, press CTRL_C to

break

Request time out

Request time out

Request time out

Request time out

Request time out

 

--- Ping statistics for 192.168.5.1 ---

5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss

以上信息表明Device D通过过滤路由表中192.168.5.0/24网段的路由信息,使得研发一部和售后服务部所在网段无法访问市场二部所在网段。

综合Device C和Device D的路由表信息,发现路由表中均没有192.168.4.0/24网段路由信息,说明设备已经将引入OSPF的RIP路由中研发二部所在网段过滤掉。

3.6  配置文件

·            Device A:

#

ospf 1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

 area 0.0.0.1

network 10.4.1.0 0.0.0.255

area 0.0.0.2

  network 10.2.1.0 0.0.0.255

#

vlan 100

#

vlan 200

#

vlan 400

#

interface Vlan-interface100

 ip address 10.1.1.1 255.255.255.0

#

interface Vlan-interface200

 ip address 10.2.1.1 255.255.255.0

#

interface Vlan-interface400

 ip address 10.4.1.1 255.255.255.0

#

·            Device B:

#

ospf 1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

 area 0.0.0.3

  network 10.3.1.0 0.0.0.255

#

vlan 100

#

vlan 300

#

interface Vlan-interface100

 ip address 10.1.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 10.3.1.1 255.255.255.0

#

·            Device C:

#

ospf 1

 filter-policy 2000 import

 area 0.0.0.2

  network 10.2.1.0 0.0.0.255

  network 192.168.3.0 0.0.0.255

#

vlan 200

#

interface LoopBack0

 ip address 192.168.3.1 255.255.255.0

#

interface Vlan-interface200

 ip address 10.2.1.2 255.255.255.0

#

acl basic 2000

 rule 0 deny source 192.168.2.0 0.0.0.255

rule 5 permit

#

·            Device D:

#

ospf 1

 filter-policy 2000 import

 area 0.0.0.3

  network 10.3.1.0 0.0.0.255

  network 192.168.1.0 0.0.0.255

  network 192.168.2.0 0.0.0.255

#

vlan 300

#

interface LoopBack0

 ip address 192.168.1.1 255.255.255.0

#

interface LoopBack1

 ip address 192.168.2.1 255.255.255.0

#

interface Vlan-interface300

 ip address 10.3.1.2 255.255.255.0

#

acl basic 2000

 rule 0 deny source 192.168.5.0 0.0.0.255

rule 5 permit

#

·            Device E:

#

ospf 1

 import-route direct

 import-route rip 1

 filter-policy 2000 export rip 1

 area 0.0.0.1

  network 10.4.1.0 0.0.0.255

#

rip 1

 undo summary

 version 2

 network 10.5.1.0 0.0.0.255

 import-route direct

 import-route ospf 1

#

vlan 400

#

vlan 500

#

interface Vlan-interface400

 ip address 10.4.1.2 255.255.255.0

#

interface Vlan-interface500

 ip address 10.5.1.1 255.255.255.0

#

acl basic 2000

 rule 0 deny source 192.168.4.0 0.0.0.255

rule 5 permit

#

·            Device F:

#

rip 1

 undo summary

 version 2

 network 10.5.1.0 0.0.0.255

 network 192.168.4.0

 network 192.168.5.0

#

vlan 500

#

interface LoopBack0

 ip address 192.168.4.1 255.255.255.0

#

interface LoopBack1

 ip address 192.168.5.1 255.255.255.0

#

interface Vlan-interface500

 ip address 10.5.1.2 255.255.255.0

#

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

新华三官网
联系我们