TELENT远程管理
- R1
- 配置接口 IP 确保和 R2 处于同一网段
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R1 [R1]interface GigabitEthernet 0/0/0 //进入 R1 GE0 接口 [R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24 //GE0 接口配置 IP Apr 22 2018 14:46:49-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
- 配置接口 IP 确保和 R2 处于同一网段
- R2
- 配置接口 IP 确保和 R1 处于同一网段
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R2 [R2]interface GigabitEthernet 0/0/0 //进入 R2 GE0 接口 [R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24 //GE0 接口配置 IP Apr 22 2018 14:54:19-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
- 配置 telnet 远程登陆
[R2]user-interface vty 0 4 //进入远程线路 vty 0 4 [R2-ui-vty0-4]authentication-mode aaa //使用 aaa 认证模式 [R2-ui-vty0-4]quit [R2]aaa //进入 aaa 配置 [R2-aaa]local-user user-r1 password cipher huawei123 //创建账号及对应密码 [R2-aaa]local-user user-r1 privilege level 2 //给该账号分配 2 级权限 [R2-aaa]local-user user-r1 service-type telnet //定义用户的服务类别(启动 telnet 服务) [R2-aaa]quit
- 进入 R1 验证
通过 telnet 登录 R2: <R1>telnet 12.1.1.2 Username:user-r1 Password: <R2>system-view [R2]sysname R22 [R22] (进入 R2,对 R2 的主机名做修改,telnet 远程管理实现)
- 配置接口 IP 确保和 R1 处于同一网段
SSH远程管理
R1
配置接口 IP 确保和 R2 处于同一网段 <Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R1 [R1]interface GigabitEthernet 0/0/0 //进入 R1 GE0 接口 [R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24 //GE0 接口配置 IP Apr 22 2018 14:46:49-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
R2
- 配置接口 IP 确保和 R1 处于同一网段
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R2 [R2]interface GigabitEthernet 0/0/0 //进入 R2 GE0 接口 [R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24 //GE0 接口配置 IP Apr 22 2018 14:54:19-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
配置 ssh 远程登陆
[R2]stelnet server enable //开启 SSH 协议 [R2]rsa local-key-pair create //创建加密报文的密钥对 Input the bits in the modulus[default = 512]:1024 //密钥长度 [R2]aaa //使用 aaa 认证模式 [R2-aaa]local-user user-ssh password cipher huawei123 //创建账号及对应密码 [R2-aaa]local-user user-ssh privilege level 2 //给该账号分配 2 级权限 [R2-aaa]local-user user-ssh service-type ssh 创建 ssh 用户 [R2-aaa]quit [R2]user-interface vty 0 4 //进入 vty 线路 [R2-ui-vty0-4]authentication-mode aaa [R2-ui-vty0-4]protocol inbound ssh //开启 vty 线路的 ssh 访问功能 [R2-ui-vty0-4]quit [R2]ssh user user-ssh authentication-type all //定义 ssh 用户的认证模式
进入 R1 验证
通过 ssh 登录 R2: [R1]ssh client first-time enable [R1]stelnet 12.1.1.2 Please input the username:user-ssh Continue to access it? (y/n)[n]:y Save the server's public key? (y/n)[n]:y Enter password: <R2> (ssh 远程登录成功)
- 配置接口 IP 确保和 R1 处于同一网段
接口隔离配置
配置接口
GE0/0/1
和GE0/0/2
的接口隔离功能,实现两个接口之间的二层数据隔离,三层数据互通
<Switch1>system-view
Enter system view, return user view with Ctrl+Z.
[Switch1]port-isolate mode L2 //端口隔离模式选择 L2
[Switch1]interface GigabitEthernet 0/0/1 //进入 GE0 接口
[Switch1-GigabitEthernet0/0/1]port-isolate enable group 1 //接口隔离选择默认组 1
[Switch1-GigabitEthernet0/0/1]quit
[Switch1]interface GigabitEthernet 0/0/2 //进入 GE2 接口
[Switch1-GigabitEthernet0/0/2]port-isolate enable group 1 //接口隔离选择默认组 1
[Switch1-GigabitEthernet0/0/2]quit
[Switch1]
端口隔离实验成功
接口速率设置
配置以太网接口 GE0/0/1 在自协商模式下协商速率为 100Mb/s
<Switch1>system-view
Enter system view, return user view with Ctrl+Z.
[Switch1]interface GigabitEthernet 0/0/1 //进入 GE1 端口
[Switch1-GigabitEthernet0/0/1]negotiation auto //自动协商
[Switch1-GigabitEthernet0/0/1]auto speed 100 //协商速率
接口模式设置
配置以太网接口 GE0/0/1 在自协商模式下双工模式为全双工模式
<Switch1>system-view
Enter system view, return user view with Ctrl+Z.
[Switch1]interface GigabitEthernet 0/0/1 //进入 GE1 端口
[Switch1-GigabitEthernet0/0/1]negotiation auto //自动协商
[Switch1-GigabitEthernet0/0/1] auto duplex full //全双工模式
基于接口划分VLAN
[SW1]vlan 10
[SW1-vlan10]quit
[SW1]vlan 20
[SW1-vlan20]quit //创建 vlan10、vlan20(快速创建多个 vlan 使用 vlan batch 10 20 命令)
[SW1]display vlan summary //查看设备的 vlan 信息
[SW1]int Ethernet0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 10 //将接口 e0/0/1 划入对应的 vlan10
[SW1-Ethernet0/0/1]quit
[SW1]int e0/0/2
[SW1-Ethernet0/0/2]port default vlan 20 //将接口 e0/0/2 划入对应的 vlan20
[SW1-Ethernet0/0/2]quit
[SW1]int Ethernet0/0/3
[SW1-Ethernet0/0/3]port link-type trunk
[SW1-Ethernet0/0/3]port trunk allow-pass vlan 30 //将接口 e0/0/3 划入对应的 vlan30
[SW1-Ethernet0/0/3]quit
[SW1]display port vlan active //查看接口对应的 vlan 信息
[SW1]quit
基于MAC地址划分VLAN
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SwitchA
[SwitchA]vlan batch 2
Info: This operation may take a few seconds. Please wait for a moment...done.
[SwitchA]interface gigabitethernet 0/0/1 //在接口视图配置上联接口
[SwitchA-GigabitEthernet0/0/1]port link-type hybrid //配置上联接口类型
[SwitchA-GigabitEthernet0/0/1]port hybrid tagged vlan 2 //通过 VLAN2
[SwitchA-GigabitEthernet0/0/1]quit
[SwitchA]interface gigabitethernet 0/0/2 //进入交换机接口视图
[SwitchA-GigabitEthernet0/0/2]port link-type hybrid //配置接口类型
[SwitchA-GigabitEthernet0/0/2]port hybrid untagged vlan 2 //将接口加入 VLAN2
[SwitchA-GigabitEthernet0/0/2]quit
[SwitchA]vlan 2 //进入 vlan2 配置
[SwitchA-vlan2]mac-vlan mac-address 22-22-22-22 //PC 的 MAC 地址与 VLAN2 关联
[SwitchA-vlan2]quit
[SwitchA]interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2]mac-vlan enable //基于 MAC 地址启用接口
Info: This operation may take a few seconds. Please wait for a moment...done.
[SwitchA-GigabitEthernet0/0/2]quit
配置GVRP协议
- GARP (
Generic Attribute Registration Protocol
)是通用属性注册协议的应用,提供 802.1Q 兼容的VLAN 裁剪 VLAN pruning 功能和在 802.1Q 干线端口 trunk port 上建立动态 VLAN 的功能。 - GARP 作为一个属性注册协议的载体,可以用来传播属性,将 GARP 协议报文的内容映射成不同的属性即可支持不同上层协议应用。
- GVRP(
GARP VLAN Registration Protocol
)是 GARP 的一种应用,用于注册和注销 VLAN 属性。 - GARP 协议通过目的 MAC 地址区分不同的应用。在 IEEE Std 802.1Q 中将 01-80-C2-00-00-21 分配给 VLAN 应用,即 GVRP。
配置 GVRP 示例
组网需求
- 如图所示,公司 A、公司 A 的分公司以及公司 B 之间有较多的交换设备相连,需要通过 GVRP 功能,实现 VLAN 的动态注册。公司 A 的分公司与总部通过 SwitchA 和 SwitchB 互通;公司 B 通过 SwitchB和 SwitchC 与公司 A 互通,但只允许公司 B 配置的 VLAN 通过。
- 配置思路
- 使能 GVRP 功能,实现 VLAN 的动态注册。
- 公司 A 的所有交换机配置 GVRP 功能并配置接口注册模式为 Normal,以简化配置。
- 公司 B 的所有交换机配置 GVRP 功能并将与公司 A 相连的接口的注册模式配置为 Fixed,以控制只允许公司 B 配置的 VLAN 通过。
说明:
使能 GVRP 之前,必须先设置 VCMP 的角色为 Transparent 或 Silent。
- 配置步骤
- 配置交换机SwitchA
//全局使能 GVRP 功能 <Huawei> <Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname SwitchA [SwitchA]vcmp role silent //配置接口为 Trunk 类型,并允许所有 VLAN 通过 [SwitchA]interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1]port link-type trunk [SwitchA-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SwitchA-GigabitEthernet0/0/1]quit [SwitchA]interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2]port link-type trunk [SwitchA-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SwitchA-GigabitEthernet0/0/2]quit //使能接口的 GVRP 功能,并配置接口注册模式 [SwitchA]interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1]gvrp [SwitchA-GigabitEthernet0/0/1]gvrp registration normal [SwitchA-GigabitEthernet0/0/1]quit [SwitchA]interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2]gvrp [SwitchA-GigabitEthernet0/0/2]gvrp registration normal [SwitchA-GigabitEthernet0/0/2]quit
- 配置交换机SwitchB
//全局使能 GVRP 功能 <Huawei> <Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname SwitchB [SwitchB]vcmp role silent //配置接口为 Trunk 类型,并允许所有 VLAN 通过 [SwitchB]interface gigabitethernet 0/0/1 [SwitchB-GigabitEthernet0/0/1]port link-type trunk [SwitchB-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SwitchB-GigabitEthernet0/0/1]quit [SwitchB]interface gigabitethernet 0/0/2 [SwitchB-GigabitEthernet0/0/2]port link-type trunk [SwitchB-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SwitchB-GigabitEthernet0/0/2]quit //使能接口的 GVRP 功能,并配置接口注册模式 [SwitchB]interface gigabitethernet 0/0/1 [SwitchB-GigabitEthernet0/0/1]gvrp [SwitchB-GigabitEthernet0/0/1]gvrp registration normal [SwitchB-GigabitEthernet0/0/1]quit [SwitchB]interface gigabitethernet 0/0/2 [SwitchB-GigabitEthernet0/0/2]gvrp [SwitchB-GigabitEthernet0/0/2]gvrp registration normal [SwitchB-GigabitEthernet0/0/2]quit
- 配置交换机SwitchC
//创建 VLAN101~VLAN200 <HUAWEI>system-view [HUAWEI]sysname SwitchC [SwitchC]vlan batch 101 to 200 //全局使能 GVRP 功能 [SwitchC]vcmp role silent [SwitchC]gvrp //配置接口为 Trunk 类型,并允许所有 VLAN 通过 [SwitchC]interface gigabitethernet 0/0/1 [SwitchC-GigabitEthernet0/0/1]port link-type trunk [SwitchC-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SwitchC-GigabitEthernet0/0/1]quit [SwitchC]interface gigabitethernet 0/0/2 [SwitchC-GigabitEthernet0/0/2]port link-type trunk [SwitchC-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SwitchC-GigabitEthernet0/0/2]quit //使能接口的 GVRP 功能,并配置接口注册模式 [SwitchC]interface gigabitethernet 0/0/1 [SwitchC-GigabitEthernet0/0/1]gvrp [SwitchC-GigabitEthernet0/0/1]gvrp registration fixed [SwitchC-GigabitEthernet0/0/1]quit [SwitchC]interface gigabitethernet 0/0/2 [SwitchC-GigabitEthernet0/0/2]gvrp [SwitchC-GigabitEthernet0/0/2]gvrp registration normal [SwitchC-GigabitEthernet0/0/2]quit
- 验证配置结果
- 配置完成后,公司 A 的分公司用户可以与总部互通,公司 A 属于 VLAN101~VLAN200 的用户可以与公司 B 用户互通。
- 在 SwitchA 上使用命令 display gvrp statistics,查看接口的 GVRP 统计信息,
其中包括:
GVRP 状态、GVRP 注册失败次数、上一个 GVRP 数据单元源 MAC 地址和接口 GVRP 注册类型,
结果如下:
- 配置交换机SwitchA
switch B、C和switch A类似
配置 STP 协议
- 以太网交换网络中为了进行链路备份,提高网络可靠性,通常会使用冗余链路。但是使用冗余链路会在交换网络上产生环路,引发广播风暴以及 MAC 地址表不稳定等故障现象,从而导致用户通信质量较差,甚至通信中断。
- 为解决交换网络中的环路问题,提出了生成树协议 STP(Spanning Tree Protocol)。运行 STP 协议的设备通过彼此交互信息发现网络中的环路,并有选择的对某个端口进行阻塞,最终将环形网络结构修剪成无环路的树形网络结构,从而防止报文在环形网络中不断循环,避免设备由于重复接收相同的报文造成处理能力下降。
- 生成树协议也是随着网络的发展而不断更新的,从最初的 IEEE 802.1D 中定义的 STP 到 IEEE 802.1W中定义的快速生成树协议 RSTP(Rapid Spanning Tree Protocol),再到最新的 IEEE 802.1S 中定义的多生成树协议 MSTP(Multiple Spanning Tree Protocol)。
- 生成树协议中,MSTP 兼容 RSTP、STP,RSTP 兼容 STP。三种生成树协议的比较如下图所示:
配置 STP 示例
配之前注意事项
本举例适用于 S 系列交换机所有产品的所有版本。
与终端相连的端口不用参与 STP 计算,建议将其设置为边缘端口或去使能 STP。
- 组网需求
- 当前网络中存在环路,SwitchA、SwitchB、SwitchC 和 SwitchD 都运行 STP,通过彼此交互信息发现网络中的环路,并有选择的对某个端口进行阻塞,最终将环形网络结构修剪成无环路的树形网络结构,从而防止报文在环形网络中不断循环,避免设备由于重复接收相同的报文造成处理能力下降。
- 配置思路
- 在处于环形网络中的交换设备上配置 STP 基本功能,包括:
- 配置环网中的设备生成树协议工作在 STP 模式。
- 配置根桥和备份根桥设备。
- 配置端口的路径开销值,实现将该端口阻塞。
- 使能 STP,实现破除环路。
- 在处于环形网络中的交换设备上配置 STP 基本功能,包括:
配置步骤
配置 STP 基本功能
- 配置环网中的设备生成树协议工作在 STP 模式
//配置交换设备 SwitchA 的 STP 工作模式。 <HUAWEI>system-view [HUAWEI]sysname SwitchA [SwitchA]stp mode stp //配置交换设备 SwitchB 的 STP 工作模式。 <HUAWEI>system-view [HUAWEI]sysname SwitchB [SwitchB]stp mode stp //配置交换设备 SwitchC 的 STP 工作模式。 <HUAWEI>system-view [HUAWEI]sysname SwitchC [SwitchC]stp mode stp //配置交换设备 SwitchD 的 STP 工作模式。 <HUAWEI>system-view [HUAWEI]sysname SwitchD [SwitchD]stp mode stp
- 配置根桥和备份根桥设备
//配置 SwitchA 为根桥。 [SwitchA] stp root primary //配置 SwitchD 为备份根桥。 [SwitchD] stp root secondary
- 配置端口的路径开销值,实现将该端口阻塞
说明:
端口路径开销值取值范围由路径开销计算方法决定,这里选择使用华为计算方法为例,配置将被阻塞端口的路径开销值为 20000。
同一网络内所有交换设备的端口路径开销应使用相同的计算方法。//配置 SwitchA 的端口路径开销计算方法为华为计算方法。 [SwitchA]stp pathcost-standard legacy //配置 SwitchB 的端口路径开销计算方法为华为计算方法。 [SwitchB]stp pathcost-standard legacy //配置 SwitchC 的端口路径开销计算方法为华为计算方法。 [SwitchC]stp pathcost-standard legacy //配置 SwitchC 端口 GigabitEthernet0/0/1 端口路径开销值为 20000。 [SwitchC]interface gigabitethernet 0/0/1 [SwitchC-GigabitEthernet0/0/1]stp cost 20000 [SwitchC-GigabitEthernet0/0/1]quit //配置 SwitchD 的端口路径开销计算方法为华为计算方法。 [SwitchD]stp pathcost-standard legacy
- 配置环网中的设备生成树协议工作在 STP 模式
使能 STP,实现破除环路
- 将与 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
- 设备全局使能STP
//设备 SwitchA 全局使能 STP。 [SwitchA]stp enable //设备 SwitchB 全局使能 STP。 [SwitchB]stp enable //设备 SwitchC 全局使能 STP。 [SwitchC]stp enable //设备 SwitchD 全局使能 STP。 [SwitchD]stp enable
- 将与 PC 机相连的端口设置为边缘端口并使能端口的 BPDU 报文过滤功能
- 验证配置
经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。
//在 SwitchA 上执行display stp brief
命令,查看端口状态和端口的保护类型,结果如下:
- 将
SwitchA
配置为根桥后,与SwitchB
、SwitchD
相连的端口GigabitEthernet0/0/2
和GigabitEthernet0/0/1
在生成树计算中被选举为指定端口。
//在 SwitchD 上执行 display stp brief 命令,查看端口状态和端口的保护类型,结果如下:
- 将
SwitchD
配置为备根桥后,与SwitchA
、SwitchC
相连的端口GigabitEthernet0/0/1
被选举为根端口、GigabitEthernet0/0/2
在生成树计算中被选举为指定端口。//在 SwitchB 上执行
display stp interface gigabitethernet 0/0/1 brief
命令,查看端口GigabitEthernet0/0/1 状态,结果如下:
- 端口
GigabitEthernet0/0/1
在生成树选举中成为指定端口,处于FORWARDING
状态。//在 SwitchC 上执行 display stp brief 命令,查看端口状态,结果如下:
端口 GigabitEthernet0/0/3 在生成树选举中成为根端口,处于 FORWARDING 状态。
端口 GigabitEthernet0/0/1 在生成树选举中成为 Alternate 端口,处于 DISCARDING 状态。