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

05-三层技术-IP路由配置举例

目录

07-H3C_OSPF典型配置举例

本章节下载07-H3C_OSPF典型配置举例(221.16 KB)

07-H3C_OSPF典型配置举例

H3C OSPF配置举例

资料版本:6W100-20200330

产品版本:Release 7585P05

Copyright © 2020新华三技术有限公司版权所有,保留一切权利。

非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。

除新华三技术有限公司的商标外,本手册中出现的其它公司的商标、产品标识及商品名称,由各自权利人拥有。

本文档中的信息可能变动,恕不另行通知。



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 配置注意事项

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

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

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

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

3.3 配置步骤

3.3.1 配置各接口的IP地址

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

system-view

[DeviceA] interface vlan-interface 100

[DeviceA-Vlan-interface100] ip address 10.1.1.1 24

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

3.3.2 配置OSPF网络的基本功能

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

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路由功能。

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路由功能。

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路由功能。

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路由功能。

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.3.3 配置RIP网络的基本功能

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

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功能。

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.3.4 将RIP路由和OSPF路由互相引入

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

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 OSPF 10 2 10.4.1.1 Vlan400

10.2.1.0/24 OSPF 10 210.4.1.1 Vlan400

10.3.1.0/24 OSPF 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 OSPF 10 3 10.4.1.1 Vlan400

192.168.2.1/32 OSPF 10 310.4.1.1 Vlan400

192.168.3.1/32 OSPF 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.3.5 配置OSPF的路由过滤功能

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

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。

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。

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.4 验证配置

# 查看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 OSPF 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 OSPF 10 3 10.2.1.1 Vlan200

10.4.1.0/24 OSPF 10 2 10.2.1.1 Vlan200

10.5.1.0/24 OSPF 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 OSPF 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 OSPF 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 OSPF 10 2 10.3.1.1 Vlan300

10.2.1.0/24 OSPF 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 OSPF 10 3 10.3.1.1 Vlan300

10.5.1.0/24 OSPF 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.1Loop1

192.168.3.1/32 OSPF 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.5 配置文件

·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

#

4 相关资料

·H3C S7600系列交换机 三层技术-IP路由配置指导-R758X

·H3C S7600系列交换机 三层技术-IP路由命令参考-R758X

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

新华三官网
联系我们