华为ensp_华为ensp基础配置文档(四)

十九、生成树STP、RSTP、MSTP配置

STP组网需求

在一个复杂的网络中,网络规划者由于冗余备份的需要,一般都倾向于在设备之间部署

多条物理链路,其中一条作主用链路,其他链路作备份。这样就难免会形成环形网络,

若网络中存在环路,可能会引起广播风暴和MAC表项被破坏。

网络规划者规划好网络后,可以在网络中部署STP协议预防环路。当网络中存在环路,

STP通过阻塞某个端口以达到破除环路的目的。如图3-36所示,当前网络中存在环路,

SwitchA、SwitchB、SwitchC和SwitchD都运行STP,通过彼此交互信息发现网络中的环

路,并有选择的对某个端口进行阻塞,最终将环形网络结构修剪成无环路的树形网络结

构,从而防止报文在环形网络中不断循环,避免设备由于重复接收相同的报文造成处理

能力下降。

5b3402f2928ac2b1da773acbb42a3fdb.png

配置思路

采用以下思路配置STP功能:

1. 在处于环形网络中的交换设备上配置STP基本功能,包括:

a. 配置环网中的设备生成树协议工作在STP模式。

b. 配置根桥和备份根桥设备。

c. 配置端口的路径开销值,实现将该端口阻塞。

d. 使能STP,实现破除环路。

说明

与PC机相连的端口不用参与STP计算,建议将其去使能STP。

操作步骤

步骤1 配置STP基本功能

1. 配置环网中的设备生成树协议工作在STP模式

# 配置交换设备SwitchA的STP工作模式。

system-view

[HUAWEI] sysname SwitchA

[SwitchA] stp mode stp

# 配置交换设备SwitchB的STP工作模式。

system-view

[HUAWEI] sysname SwitchB

[SwitchB] stp mode stp

# 配置交换设备SwitchC的STP工作模式。

system-view

[HUAWEI] sysname SwitchC

[SwitchC] stp mode stp

# 配置交换设备SwitchD的STP工作模式。

system-view

[HUAWEI] sysname SwitchD

[SwitchD] stp mode stp

2. 配置根桥和备份根桥设备

# 配置SwitchA为根桥。

[SwitchA] stp root primary

# 配置SwitchD为备份根桥。

[SwitchD] stp root secondary

4. 使能STP,实现破除环路

l 将与PC机相连的端口去使能STP

# 配置SwitchB端口GigabitEthernet0/0/2的STP去使能。

[SwitchB] interface gigabitethernet 0/0/2

[SwitchB-GigabitEthernet0/0/2] stp disable

[SwitchB-GigabitEthernet0/0/2] quit

# 配置SwitchC端口GigabitEthernet0/0/2的STP去使能。

[SwitchC] interface gigabitethernet 0/0/2

[SwitchC-GigabitEthernet0/0/2] stp disable

[SwitchC-GigabitEthernet0/0/2] quit

l 设备全局使能STP

# 设备SwitchA全局使能STP。

[SwitchA] stp enable

# 设备SwitchB全局使能STP。

[SwitchB] stp enable

# 设备SwitchC全局使能STP。

[SwitchC] stp enable

# 设备SwitchD全局使能STP。

[SwitchD] stp enable

步骤2 验证配置结果

经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。

# 在SwitchA上执行display stp brief命令,查看端口状态和端口的保护类型,结果如下:

[SwitchA] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESIFORWARDING NONE

0 GigabitEthernet0/0/2 DESIFORWARDING NONE

将SwitchA配置为根桥后,与SwitchB、SwitchD相连的端口GigabitEthernet0/0/2和

GigabitEthernet0/0/1在生成树计算中被选举为指定端口。

# 在SwitchB上执行display stp interface gigabitethernet 0/0/1brief命令,查看端口

GigabitEthernet0/0/1状态,结果如下:

[SwitchB] display stp interface gigabitethernet 0/0/1 brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESIFORWARDING NONE

端口GigabitEthernet0/0/1在生成树选举中成为指定端口,处于Forwarding状态。

# 在SwitchC上执行display stp brief命令,查看端口状态,结果如下:

[SwitchC] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 ALTEDISCARDING NONE

0 GigabitEthernet0/0/3 ROOTFORWARDING NONE

端口GigabitEthernet0/0/3在生成树选举中成为根端口,处于FORWARDING状态。

端口GigabitEthernet0/0/1在生成树选举中成为Alternate端口,处于DISCARDING状态。

----结束

RSTP

配置 RSTP 功能示例

组网需求

在一个复杂的网络中,网络规划者由于冗余备份的需要,一般都倾向于在设备之间部署

多条物理链路,其中一条作主用链路,其他链路作备份。这样就难免会形成环形网络,

若网络中存在环路,可能会引起广播风暴和MAC表项被破坏。

网络规划者规划好网络后,可以在网络中部署RSTP协议预防环路。当网络中存在环

路,RSTP通过阻塞某个端口以达到破除环路的目的。如图3-37所示,当前网络中存在环

路,SwitchA、SwitchB、SwitchC和SwitchD都运行RSTP,通过彼此交互信息发现网络中

的环路,并有选择的对某个端口进行阻塞,最终将环形网络结构修剪成无环路的树形网

络结构,从而防止报文在环形网络中不断循环,避免设备由于重复接收相同的报文造成

处理能力下降。

44fb9cffcfd6c39d3055d88a63f9509e.png

配置思路

采用以下思路配置RSTP功能:

1. 在处于环形网络中的交换设备上配置RSTP基本功能,包括:

a. 配置环网中的设备生成树协议工作在RSTP模式。

b. 配置根桥和备份根桥设备。

c. 配置端口的路径开销值,实现将该端口阻塞。

d. 使能RSTP,实现破除环路。

说明

与PC机相连的端口不用参与RSTP计算,配置为边缘端口,并配置BPDU过滤。

2. 配置保护功能,实现对设备或链路的保护。例如:在根桥设备的指定端口配置根保

护功能。

操作步骤

步骤1 配置RSTP基本功能

1. 配置环网中的设备生成树协议工作在RSTP模式

# 配置SwitchA的RSTP工作模式。

system-view

[HUAWEI] sysname SwitchA

[SwitchA] stp mode rstp

# 配置交换设备SwitchB的RSTP工作模式。

system-view

[HUAWEI] sysname SwitchB

[SwitchB] stp mode rstp

# 配置交换设备SwitchC的RSTP工作模式。

system-view

[HUAWEI] sysname SwitchC

[SwitchC] stp mode rstp

# 配置交换设备SwitchD的RSTP工作模式。

system-view

[HUAWEI] sysname SwitchD

[SwitchD] stp mode rstp

2. 配置根桥和备份根桥设备

# 配置SwitchA为根桥。

[SwitchA] stp root primary

# 配置SwitchD为备份根桥。

[SwitchD] stp root secondary

4. 使能RSTP,实现破除环路

l 将与PC机相连的端口配置为边缘端口并配置BPDU过滤

# 配置SwitchB端口GigabitEthernet0/0/2为边缘端口并配置BPDU过滤。

[SwitchB] interface gigabitethernet 0/0/2

[SwitchB-GigabitEthernet0/0/2] stp edged-port enable

[SwitchB-GigabitEthernet0/0/2] stp bpdu-filter enable

[SwitchB-GigabitEthernet0/0/2] quit

# 配置SwitchC端口GigabitEthernet0/0/2为边缘端口并配置BPDU过滤。

[SwitchC] interface gigabitethernet 0/0/2

[SwitchC-GigabitEthernet0/0/2] stp edged-port enable

[SwitchC-GigabitEthernet0/0/2] stp bpdu-filter enable

[SwitchC-GigabitEthernet0/0/2] quit

l 设备全局使能RSTP

# 设备SwitchA全局使能RSTP。

[SwitchA] stp enable

# 设备SwitchB全局使能RSTP。

[SwitchB] stp enable

# 设备SwitchC全局使能RSTP。

[SwitchC] stp enable

# 设备SwitchD全局使能RSTP。

[SwitchD] stp enable

步骤2 配置保护功能,如在根桥设备的指定端口配置根保护功能

# 在SwitchA端口GigabitEthernet0/0/1上配置根保护功能。

[SwitchA] interface gigabitethernet 0/0/1

[SwitchA-GigabitEthernet0/0/1] stp root-protection

[SwitchA-GigabitEthernet0/0/1] quit

# 在SwitchA端口GigabitEthernet0/0/2上配置根保护功能。

[SwitchA] interface gigabitethernet 0/0/2

[SwitchA-GigabitEthernet0/0/2] stp root-protection

[SwitchA-GigabitEthernet0/0/2] quit

步骤3 验证配置结果

经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。

# 在SwitchA上执行display stp brief命令,查看端口状态和端口的保护类型,结果如下:

[SwitchA] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESIFORWARDING ROOT

0 GigabitEthernet0/0/2 DESIFORWARDING ROOT

将SwitchA配置为根桥后,与SwitchB、SwitchD相连的端口GigabitEthernet0/0/2和

GigabitEthernet0/0/1在生成树计算中被选举为指定端口,并在指定端口上配置根保护功

能。

# 在SwitchB上执行display stp interface gigabitethernet 0/0/1brief命令,查看端口

GigabitEthernet0/0/1状态,结果如下:

[SwitchB] display stp interface gigabitethernet 0/0/1 brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESIFORWARDING NONE

端口GigabitEthernet0/0/1在生成树选举中成为指定端口,处于Forwarding状态。

# 在SwitchC上执行display stp brief命令,查看端口状态,结果如下:

[SwitchC] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 ALTEDISCARDING NONE

0 GigabitEthernet0/0/3 ROOTFORWARDING NONE

端口GE0/0/1在生成树选举中成为Alternate端口,处于DISCARDING状态。

端口GE0/0/3在生成树选举中成为根端口,处于FORWARDING状态。

----结束

MSTP

组网需求

在一个复杂的网络中,网络规划者由于冗余备份的需要,一般都倾向于在设备之间部署

多条物理链路,其中一条作主用链路,其他链路作备份。这样就难免会形成环形网络,

若网络中存在环路,可能会引起广播风暴和MAC表项被破坏。网络规划者规划好网络

后,可以在网络中部署MSTP协议预防环路。MSTP可阻塞二层网络中的冗余链路,将网

络修剪成树状,达到消除环路的目的。

如图3-38所示,SwitchA、SwitchB、SwitchC和SwitchD都运行MSTP。为实现VLAN2~

VLAN10和VLAN11~VLAN20的流量负载分担,MSTP引入了多实例。MSTP可设置

VLAN映射表,把VLAN和生成树实例相关联。

0e99a7cd29e5f2ceb82b67990e819f94.png
3bf2d3a0dc43460139b87369a84476ef.png

配置思路

采用以下思路配置MSTP功能:

1. 在处于环形网络中的交换设备上配置MSTP基本功能。

2. 配置保护功能,实现对设备或链路的保护。例如:在各实例的根桥设备指定端口配

置根保护功能。

操作步骤

步骤1 配置MSTP基本功能

1. 配置SwitchA、SwitchB、SwitchC和SwitchD到域名为RG1的域内,创建实例MSTI1

和实例MSTI2

说明

当两台交换设备的以下配置都相同时,这两台交换设备属于同一个MST域。

l MST域的域名。

l 多生成树实例和VLAN的映射关系。

l MST域的修订级别。

# 配置SwitchA的MST域。

system-view

[HUAWEI] sysname SwitchA

[SwitchA] stp region-configuration

[SwitchA-mst-region] region-name RG1

[SwitchA-mst-region] instance 1 vlan 2 to 10

[SwitchA-mst-region] instance 2 vlan 11 to 20

[SwitchA-mst-region] active region-configuration

[SwitchA-mst-region] quit

# 配置SwitchB的MST域。

system-view

[HUAWEI] sysname SwitchB

[SwitchB] stp region-configuration

[SwitchB-mst-region] region-name RG1

[SwitchB-mst-region] instance 1 vlan 2 to 10

[SwitchB-mst-region] instance 2 vlan 11 to 20

[SwitchB-mst-region] active region-configuration

[SwitchB-mst-region] quit

# 配置SwitchC的MST域。

system-view

[HUAWEI] sysname SwitchC

[SwitchC] stp region-configuration

[SwitchC-mst-region] region-name RG1

[SwitchC-mst-region] instance 1 vlan 2 to 10

[SwitchC-mst-region] instance 2 vlan 11 to 20

[SwitchC-mst-region] active region-configuration

[SwitchC-mst-region] quit

# 配置SwitchD的MST域。

system-view

[HUAWEI] sysname SwitchD

[SwitchD] stp region-configuration

[SwitchD-mst-region] region-name RG1

[SwitchD-mst-region] instance 1 vlan 2 to 10

[SwitchD-mst-region] instance 2 vlan 11 to 20

[SwitchD-mst-region] active region-configuration

[SwitchD-mst-region] quit

2. 在域RG1内,配置MSTI1与MSTI2的根桥与备份根桥

l 配置MSTI1的根桥与备份根桥

# 配置SwitchA为MSTI1的根桥。

[SwitchA] stp instance 1 root primary

# 配置SwitchB为MSTI1的备份根桥。

[SwitchB] stp instance 1 root secondary

l 配置MSTI2的根桥与备份根桥

# 配置SwitchB为MSTI2的根桥。

[SwitchB] stp instance 2 root primary

# 配置SwitchA为MSTI2的备份根桥。

[SwitchA] stp instance 2 root secondary

3. 配置实例MSTI1和MSTI2中将要被阻塞端口的路径开销值大于缺省值

说明

l 端口路径开销值取值范围由路径开销计算方法决定,这里选择使用华为私有计算方法为

例,配置实例MSTI1和MSTI2中将被阻塞端口的路径开销值为20000。

l 同一网络内所有交换设备的端口路径开销应使用相同的计算方法。

# 配置SwitchA的端口路径开销值的计算方法为华为私有计算方法。

[SwitchA] stp pathcost-standard legacy

# 配置SwitchB的端口路径开销缺省值的计算方法为华为的私有计算方法。

[SwitchB] stp pathcost-standard legacy

# 配置SwitchC的端口路径开销缺省值的计算方法为华为的私有计算方法,将端口

GE0/0/2在实例MSTI2中的路径开销值配置为20000。

[SwitchC] stp pathcost-standard legacy

[SwitchC] interface gigabitethernet 0/0/2

[SwitchC-GigabitEthernet0/0/2] stp instance 2 cost 20000

[SwitchC-GigabitEthernet0/0/2] quit

# 配置SwitchD的端口路径开销缺省值的计算方法为华为的私有计算方法,将端口

GE0/0/2在实例MSTI1中的路径开销值配置为20000。

[SwitchD] stp pathcost-standard legacy

[SwitchD] interface gigabitethernet 0/0/2

[SwitchD-GigabitEthernet0/0/2] stp instance 1 cost 20000

[SwitchD-GigabitEthernet0/0/2] quit

4. 使能MSTP,实现破除环路

l 设备全局使能MSTP

# 在SwitchA上启动MSTP。

[SwitchA] stp enable

# 在SwitchB上启动MSTP。

[SwitchB] stp enable

# 在SwitchC上启动MSTP。

[SwitchC] stp enable

# 在SwitchD上启动MSTP。

[SwitchD] stp enable

l 将与终端相连的端口去使能MSTP

# 配置SwitchC端口GE0/0/1的STP去使能。

[SwitchC] interface gigabitethernet 0/0/1

[SwitchC-GigabitEthernet0/0/1] stp disable

[SwitchC-GigabitEthernet0/0/1] quit

# 配置SwitchD端口GE0/0/1的STP去使能。

[SwitchD] interface gigabitethernet 0/0/1

[SwitchD-GigabitEthernet0/0/1] stp disable

[SwitchD-GigabitEthernet0/0/1] quit

步骤2 配置保护功能,如在各实例的根桥设备的指定端口配置根保护功能

# 在SwitchA端口GE0/0/1上启动根保护。

[SwitchA] interface gigabitethernet 0/0/1

[SwitchA-GigabitEthernet0/0/1] stp root-protection

[SwitchA-GigabitEthernet0/0/1] quit

# 在SwitchB端口GE0/0/1上启动根保护。

[SwitchB] interface gigabitethernet 0/0/1

[SwitchB-GigabitEthernet0/0/1] stp root-protection

[SwitchB-GigabitEthernet0/0/1] quit

步骤3 配置处于环网中的设备的二层转发功能

l 在交换设备SwitchA、SwitchB、SwitchC和SwitchD上创建VLAN2~20

# 在SwitchA上创建VLAN2~20。

[SwitchA] vlan batch 2 to 20

# 在SwitchB上创建VLAN2~20。

[SwitchB] vlan batch 2 to 20

# 在SwitchC上创建VLAN2~20。

[SwitchC] vlan batch 2 to 20

# 在SwitchD上创建VLAN2~20。

[SwitchD] vlan batch 2 to 20

l 将交换设备上接入环路中的端口加入VLAN

# 将SwitchA端口GE0/0/1加入VLAN。

[SwitchA] interface gigabitethernet 0/0/1

[SwitchA-GigabitEthernet0/0/1] port link-type trunk

[SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 20

[SwitchA-GigabitEthernet0/0/1] quit

# 将SwitchA端口GE0/0/2加入VLAN。

[SwitchA] interface gigabitethernet 0/0/2

[SwitchA-GigabitEthernet0/0/2] port link-type trunk

[SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 20

[SwitchA-GigabitEthernet0/0/2] quit

# 将SwitchB端口GE0/0/1加入VLAN。

[SwitchB] interface gigabitethernet 0/0/1

[SwitchB-GigabitEthernet0/0/1] port link-type trunk

[SwitchB-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 20

[SwitchB-GigabitEthernet0/0/1] quit

# 将SwitchB端口GE0/0/2加入VLAN。

[SwitchB] interface gigabitethernet 0/0/2

[SwitchB-GigabitEthernet0/0/2] port link-type trunk

[SwitchB-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 20

[SwitchB-GigabitEthernet0/0/2] quit

# 将SwitchC端口GE0/0/1加入VLAN。

[SwitchC] interface gigabitethernet 0/0/1

[SwitchC-GigabitEthernet0/0/1] port link-type access

[SwitchC-GigabitEthernet0/0/1] port default vlan 2

[SwitchC-GigabitEthernet0/0/1] quit

# 将SwitchC端口GE0/0/2加入VLAN。

[SwitchC] interface gigabitethernet 0/0/2

[SwitchC-GigabitEthernet0/0/2] port link-type trunk

[SwitchC-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 20

[SwitchC-GigabitEthernet0/0/2] quit

# 将SwitchC端口GE0/0/3加入VLAN。

[SwitchC] interface gigabitethernet 0/0/3

[SwitchC-GigabitEthernet0/0/3] port link-type trunk

[SwitchC-GigabitEthernet0/0/3] port trunk allow-pass vlan 2 to 20

[SwitchC-GigabitEthernet0/0/3] quit

# 将SwitchD端口GE0/0/1加入VLAN。

[SwitchD] interface gigabitethernet 0/0/1

[SwitchD-GigabitEthernet0/0/1] port link-type access

[SwitchD-GigabitEthernet0/0/1] port default vlan 11

[SwitchD-GigabitEthernet0/0/1] quit

# 将SwitchD端口GE0/0/2加入VLAN。

[SwitchD] interface gigabitethernet 0/0/2

[SwitchD-GigabitEthernet0/0/2] port link-type trunk

[SwitchD-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 20

[SwitchD-GigabitEthernet0/0/2] quit

# 将SwitchD端口GE0/0/3加入VLAN。

[SwitchD] interface gigabitethernet 0/0/3

[SwitchD-GigabitEthernet0/0/3] port link-type trunk

[SwitchD-GigabitEthernet0/0/3] port trunk allow-pass vlan 2 to 20

[SwitchD-GigabitEthernet0/0/3] quit

步骤4 验证配置结果

经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。

# 在SwitchA上执行display stp brief命令,查看端口状态和端口的保护类型,结果如下:

[SwitchA] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESI FORWARDING ROOT

0 GigabitEthernet0/0/2 DESI FORWARDING NONE

1 GigabitEthernet0/0/1 DESI FORWARDING ROOT

1 GigabitEthernet0/0/2 DESI FORWARDING NONE

2 GigabitEthernet0/0/1 DESI FORWARDING ROOT

2 GigabitEthernet0/0/2 ROOT FORWARDING NONE

在MSTI1中,由于SwitchA是根桥,SwitchA的端口GE0/0/2和GE0/0/1成为指定端口。在

MSTI2中,SwitchA的端口GE0/0/1成为指定端口,端口GE0/0/2成为根端口。

# 在SwitchB上执行display stp brief命令,结果如下:

[SwitchB] display stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/1 DESI FORWARDING ROOT

0 GigabitEthernet0/0/2 ROOT FORWARDING NONE

1 GigabitEthernet0/0/1 DESI FORWARDING ROOT

1 GigabitEthernet0/0/2 ROOT FORWARDING NONE

2 GigabitEthernet0/0/1 DESI FORWARDING ROOT

2 GigabitEthernet0/0/2 DESI FORWARDING NONE

在MSTI2中,由于SwitchB是根桥,端口GE0/0/1和GE0/0/2在MSTI2中成为指定端口。在

MSTI1中,SwitchB的端口GE0/0/1成为指定端口,端口GE0/0/2成为根端口。

# 在SwitchC上执行display stp interface brief命令,结果如下:

[SwitchC] display stp interface gigabitethernet 0/0/3 brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/3 ROOT FORWARDING NONE

1 GigabitEthernet0/0/3 ROOT FORWARDING NONE

2 GigabitEthernet0/0/3 ROOT FORWARDING NONE

二十、配置MPLS本地会话

MPSL(多协议标签交换 )组网需求

如图1所示,LSRA、LSRB、LSRC是MPLS网络的核心设备。数据流量从PE设备进入MPLS网络。要实现数据流在MPLS域内的转发,则需要在LSRA、LSRB、LSRC之间配置LDP本地会话,从而进行标签交换,建立LDP LSP。按照图1所示,对LSRA、LSRB、LSRC进行地址规划。

2b72d700355032a10a9e1b3d08a83972.png

操作步骤

LSRA的配置

#

sysname LSRA

#

mpls lsr-id 1.1.1.9 //配置Loopback1接口的地址做为LSR ID

mpls //全局使能MPLS

#

mpls ldp //全局使能MPLS LDP

#

interface GigabitEthernet1/0/0

ip address 10.1.1.1 255.255.255.252

mpls //接口使能MPLS

mpls ldp //接口使能MPLS LDP

#

interface LoopBack1

ip address 1.1.1.9 255.255.255.255

#

ospf 1 //OSPF保证全网互通

area 0.0.0.0

network 1.1.1.9 0.0.0.0

network 10.1.1.0 0.0.0.3

#

LSRB的配置

#

sysname LSRB

#

mpls lsr-id 2.2.2.9 //配置Loopback1接口的地址做为LSR ID

mpls //全局使能MPLS

#

mpls ldp //全局使能MPLS LDP

#

interface GigabitEthernet1/0/0

ip address 10.1.1.2 255.255.255.252

mpls //接口使能MPLS

mpls ldp //接口使能MPLS LDP

#

interface GigabitEthernet2/0/0

ip address 10.2.1.1 255.255.255.252

mpls //接口使能MPLS

mpls ldp //接口使能MPLS LDP

#

interface LoopBack1

ip address 2.2.2.9 255.255.255.255

#

ospf 1 //OSPF保证全网互通

area 0.0.0.0

network 2.2.2.9 0.0.0.0

network 10.1.1.0 0.0.0.3

network 10.2.1.0 0.0.0.3

#

LSRC的配置

#

sysname LSRC

#

mpls lsr-id 3.3.3.9 //配置Loopback1接口的地址做为LSR ID

mpls //全局使能MPLS

#

mpls ldp //全局使能MPLS LDP

#

interface GigabitEthernet1/0/0

ip address 10.2.1.2 255.255.255.252

mpls //接口使能MPLS

mpls ldp //接口使能MPLS LDP

#

interface LoopBack1

ip address 3.3.3.9 255.255.255.255

#

ospf 1 //OSPF保证全网互通

area 0.0.0.0

network 3.3.3.9 0.0.0.0

network 10.2.1.0 0.0.0.3

#

检查配置结果

配置完成后,在节点上执行display mpls ldp session命令,可以看到LSRA和LSRB、LSRB和LSRC之间的LDP本地会话状态为“Operational”。

配置注意事项

· 配置LSR ID是配置其它MPLS命令的前提。

二十一、路由策略配置

e4a071ce04a97a12180ff7e4905e604e.png

如图所示,运行OSPF协议的网络中,SwitchA从Internet网络接收路由,并为OSPF网

络提供了Internet路由。用户希望OSPF网络中只能访问172.1.17.0/24、172.1.18.0/24和

172.1.19.0/24三个网段的网络,其中SwitchC连接的网络只能访问172.1.18.0/24网段的网

络。

SwitchA GE0/0/1 VLANIF10 192.168.1.1/24

SwitchB GE0/0/1 VLANIF10 192.168.1.2/24

SwitchB GE0/0/2 VLANIF20 192.168.2.1/24

SwitchC GE0/0/1 VLANIF20 192.168.2.2/24

配置思路

采用如下的思路配置对路由进行过滤:

1. 在SwitchA上配置路由策略,在路由发布时运用路由策略,使SwitchA仅提供路由

172.1.17.0/24、172.1.18.0/24、172.1.19.0/24给SwitchB,实现OSPF网络中只能访问

172.1.17.0/24、172.1.18.0/24和172.1.19.0/24三个网段的网络。

2. 在SwitchC上配置路由策略,在路由引入时运用路由策略,使SwitchC仅接收路由

172.1.18.0/24,实现SwitchC连接的网络只能访问172.1.18.0/24网段的网络。

操作步骤

步骤1 配置各接口所属的VLAN

system-view

[HUAWEI]sysname SwitchA

[SwitchA]vlan batch 10

[SwitchA]interface gigabitethernet 0/0/1

[SwitchA-GigabitEthernet0/0/1]port link-type trunk

[SwitchA-GigabitEthernet0/0/1]port trunk allow-pass vlan 10

[SwitchA-GigabitEthernet0/0/1]quit

SwitchB和SwitchC的配置同SwitchA(略)

步骤2 配置各VLANIF接口的IP地址

[SwitchA]interface vlanif 10

[SwitchA-Vlanif10]ip address 192.168.1.1 24

[SwitchA-Vlanif10]quit

SwitchB和SwitchC的配置同SwitchA(略)

步骤3 配置OSPF基本功能

# SwitchA的配置

[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

# SwitchB的配置

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

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

[SwitchB-ospf-1]quit

# SwitchC的配置

[SwitchC]ospf

[SwitchC-ospf-1]area 0

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

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

[SwitchC-ospf-1]quit

步骤4 在SwitchA配置5条静态路由,并在将这些静态路由引入到OSPF协议中。

[SwitchA] ip route-static 172.1.16.0 24 NULL 0

[SwitchA] ip route-static 172.1.17.0 24 NULL 0

[SwitchA] ip route-static 172.1.18.0 24 NULL 0

[SwitchA] ip route-static 172.1.19.0 24 NULL 0

[SwitchA] ip route-static 172.1.20.0 24 NULL 0

[SwitchA]ospf

[SwitchA-ospf-1]import-route static

[SwitchA-ospf-1]quit

# 在SwitchB查看IP路由表,可以看到OSPF引入的5条静态路由。

[SwitchB] display ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------Routing Tables: Public

Destinations : 11 Routes : 11

Destination/Mask Proto Pre Cost Flags NextHop Interface

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0

127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

172.1.16.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.17.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.18.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.19.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.20.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

192.168.1.0/24 Direct 0 0 D 192.168.1.2 Vlanif10

192.168.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif10

192.168.2.0/24 Direct 0 0 D 192.168.2.1 Vlanif20

192.168.2.1/32 Direct 0 0 D 127.0.0.1 Vlanif20

步骤5 配置路由发布策略

# 在SwitchA配置地址前缀列表a2b。

[SwitchA] ip ip-prefix a2b index 10 permit 172.1.17.0 24

[SwitchA] ip ip-prefix a2b index 20 permit 172.1.18.0 24

[SwitchA]ip ip-prefix a2b index 30 permit 172.1.19.0 24

# 在SwitchA配置发布策略,引用地址前缀列表a2b进行过滤。

[SwitchA]ospf

[SwitchA-ospf-1]filter-policy ip-prefix a2b export static

# 在SwitchB查看IP路由表,可以看到SwitchB仅接收到列表a2b中定义的3条路由。

[SwitchB] display ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------Routing Tables: Public

Destinations : 9 Routes : 9

Destination/Mask Proto Pre Cost Flags NextHop Interface

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0

127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

172.1.17.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.18.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

172.1.19.0/24 O_ASE 150 1 D 192.168.1.1 Vlanif10

192.168.1.0/24 Direct 0 0 D 192.168.1.2 Vlanif10

192.168.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif10

192.168.2.0/24 Direct 0 0 D 192.168.2.1 Vlanif20

192.168.2.1/32 Direct 0 0 D 127.0.0.1 Vlanif20

步骤6 配置路由接收策略

# 在SwitchC配置地址前缀列表in。

[SwitchC]ip ip-prefix in index 10 permit 172.1.18.0 24

# 在SwitchC配置接收策略,引用地址前缀列表in进行过滤。

[SwitchC]ospf

[SwitchC-ospf-1]filter-policy ip-prefix in import

# 查看SwitchC的IP路由表,可以看到SwitchC的本地路由表中,仅接收了列表in定义的1

条路由。

[SwitchC] display ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------Routing Tables: Public

Destinations : 5 Routes : 5

Destination/Mask Proto Pre Cost Flags NextHop Interface

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0

127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

172.1.18.0/24 O_ASE 150 1 D 192.168.2.1 Vlanif20

192.168.2.0/24 Direct 0 0 D 192.168.2.2 Vlanif20

192.168.2.2/32 Direct 0 0 D 127.0.0.1 Vlanif20

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值