VLAN配置

 创建VLAN。
 配置Access和Trunk类型接口。
 配置Hybird接口。
 配置接口与VLAN关联。
工作实施
步骤一 环境准备
在S1和S2上创建Eth-Trunk 1并配置该Eth-Trunk为静态LACP模式。然后将G0/0/9和G0/0/10接口加入Eth-Trunk 1。
<Huawei> system-view
[Huawei] sysname S1
[S1] interface Eth-trunk 1
[S1 Eth Trunk1] mode lacp
[S1 Eth Trunk1] quit
[S1] interface GigabitEthernet0/0/9
[S1 GigabitEthernet0/0/9] eth-trunk 1
[S1 GigabitEthernet0/0/9] interface GigabitEthernet0/0/10
[S1 GigabitEthernet0/0/10] eth-trunk 1
<Huawei> system-view
[Huawei] sysname S2
[S2] interface eth-trunk 1
[S2 Eth Trunk1] mode lacp
[S2 Eth Trunk1] trunkport GigabitEthernet 0/0/9
[S2 Eth Trunk1] trunkport GigabitEthernet 0/0/10
步骤二 关闭不相关接口,并配置 Trunk
为了确保测试结果的准确性,需要关闭S3上的E0/0/1和E0/0/7端口以及S4上的E0/0/1和E0/0/14端口。
<Huawei> system view
Enter system view, return user view with Ctrl+Z.
[Huawei] sysname S3
[S3] interface GigabitEthernet 0/0/1
[S3 GigabitEthernet0/0/1] shutdown
[S3 GigabitEthernet0/0/1] quit
[S3] interface GigabitEthernet 0/0/7[S3 GigabitEthernet0/0/7] shutdown
<Huawei> system view
Enter system view, return user view with Ctrl+Z.
[Huawei] sysname S4
[S4] interface GigabitEthernet 0/0/1
[S4 GigabitEthernet0/0/1] shutdown
[S4 GigabitEthernet0/0/1] quit
[S4] interface GigabitEthernet 0/0/14[S4 GigabitEthernet0/0/14] shutdown
交换机端口的类型默认为Hybrid端口。将Eth-Trunk 1的端口类型配置为Trunk,并允许所有VLAN的报文通过该端口。[S1] interface Eth Trunk 1
[S1 Eth Trunk1] port link type trunk
[S1 Eth Trunk1] port trunk allow pass vlan all
[S2] interface Eth Trunk 1
[S2 Eth Trunk1] port link type trunk
[S2 Eth Trunk1] port trunk allow pass vlan all
步骤三 创建 VLAN
本任务中将S3、R1、R3和S4设备作为客户端主机。在S1和S2上分别创建VLAN,并使用两种不同方式将端口加入到已创建VLAN中。将所有连接客户端的端口类型配置为Access。
在S1上,将端口G0/0/13和G0/0/1分别加入到VLAN 3和VLAN 4。在S2上,将端口G0/0/3和G0/0/6分别加入VLAN 4和VLAN 2。
[S1] interface GigabitEthernet0/0/13
[S1 GigabitEthernet0/0/13] port link type access
[S1 GigabitEthernet0/0/13] quit
[S1] interface GigabitEthernet0/0/1
[S1 GigabitEthernet0/0/1] port link type access
[S1 GigabitEthernet0/0/1] quit
[S1] vlan 2
[S1 vlan2] vlan 3
[S1 vlan3] port GigabitEthernet0/0/13
[S1 vlan3] vlan 4
[S1 vlan4] port GigabitEthernet0/0/1
[S2] vlan batch 2 to 4
[S2] interface GigabitEthernet 0/0/3
[S2 GigabitEthernet0/0/3] port link type access
[S2 GigabitEthernet0/0/3] port default vlan 4
[S2 GigabitEthernet0/0/3] quit
[S2] interface GigabitEthernet 0/0/6
[S2 GigabitEthernet0/0/6] port link type access
[S2 GigabitEthernet0/0/6] port default vlan 2
确认S1和S2上已成功创建VLAN,且已将相应端口划分到对应的VLAN中。<S1> display vlan
The total number of vlans is : 4
U: Up; D: Down; TG: Tagged; UT: Untagged;MP: Vlan mapping; ST: Vlan stacking;#: ProtocolTransparent vlan; *: Management vlan;
VID Type Ports 
1 common UT:GE0/0/2(U) GE0/0/3(U) GE0/0/4(U) GE0/0/5(U)  GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/11(D)  GE0/0/12(D) GE0/0/14(U) GE0/0/15(D) GE0/0/16(D)  GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)  GE0/0/21(U) GE0/0/22(U) GE0/0/23(U) GE0/0/24(D)  GE0/0/25(D) GE0/0/26(D) GE0/0/27(D) GE0/0/28(D)  XGE0/0/1(D) XGE0/0/2(D) XGE0/0/3(D) XGE0/0/4(D)   Eth Trunk1(U) 
2 common TG:Eth Trunk1(U) 3 common UT:GE0/0/13(U)  TG:Eth Trunk1(U) 4 common UT:GE0/0/1(U)  TG:Eth Trunk1(U) 
VID Status Property MAC LRN Statistics Description 
1 enable default enable disable VLAN 0001 
2 enable default enable disable VLAN 0002 3 enable default enable disable VLAN 0003 4 enable default enable disable VLAN 0004 
<S2> display vlan
The total number of vlans is : 4
U: Up; D: Down; TG: Tagged; UT: Untagged;MP: Vlan mapping; ST: Vlan stacking;#: ProtocolTransparent vlan; *: Management vlan;
VID Type Ports 
1 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/4(U) GE0/0/5(U)  GE0/0/7(D) GE0/0/8(D) GE0/0/11(U) GE0/0/12(U)  GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) 
 GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)  GE0/0/21(D) GE0/0/22(D) GE0/0/23(U) GE0/0/24(U)  GE0/0/25(D) GE0/0/26(D) GE0/0/27(D) GE0/0/28(D)  XGE0/0/1(D) XGE0/0/2(D) XGE0/0/3(D) XGE0/0/4(D)  Eth Trunk1(U) 
2 common UT:GE0/0/6(D)  TG:Eth Trunk1(U) 3 common TG:Eth Trunk1(U) 4 common UT:GE0/0/3(U)  TG:Eth Trunk1(U) 
VID Status Property MAC LRN Statistics Description 
1 enable default enable disable VLAN 0001 2 enable default enable disable VLAN 0002 3 enable default enable disable VLAN 0003 4 enable default enable disable VLAN 0004
回显信息中灰色阴影标注的部分表明接口已经加入到各个对应VLAN中,并且Eth-Trunk 1端口允许所有VLAN的报文通过。
步骤四 为客户端配置 IP 地址
分别为主机R1、S3、R3和S4配置IP地址。由于无法直接为交换机的物理接口分配IP地址,因此将S3和S4的本地管理接口VLANIF 1作为用户接口,配置IP地址。
<Huawei> system view
[Huawei] sysname R1
[R1] interface GigabitEthernet0/0/1
[R1 GigabitEthernet0/0/1] ip address 10.0.4.1 24
[S3] interface vlanif 1
[S3 vlanif1] ip address 10.0.4.2 24
<Huawei> system view
[Huawei] sysname R3
[R3] interface GigabitEthernet0/0/2
[R3 GigabitEthernet0/0/2] ip address 10.0.4.3 24
[S4] interface vlanif 1
[S4 vlanif1] ip address 10.0.4.4 24
步骤五 检测设备连通性,验证 VLAN 配置结果
执行ping命令。同属VLAN 4中的R1和R3能够相互通信。其他不同VLAN间的设备无法通信。[R1] ping 10.0.4.3
PING 10.0.4.3: 56 data bytes, press CTRL_C to break Reply from 10.0.4.3: bytes=56 Sequence=1 ttl=255 time=6 ms Reply from 10.0.4.3: bytes=56 Sequence=2 ttl=255 time=2 ms Reply from 10.0.4.3: bytes=56 Sequence=3 ttl=255 time=2 ms Reply from 10.0.4.3: bytes=56 Sequence=4 ttl=255 time=2 ms Reply from 10.0.4.3: bytes=56 Sequence=5 ttl=255 time=2 ms 10.0.4.3 ping statistics 
 5 packet(s) transmitted
 5 packet(s) received
 0.00% packet lossround trip min/avg/max = 2/2/6 ms
[R1] ping 10.0.4.4
 PING 10.0.4.4: 56 data bytes, press CTRL_C to break Request time out
 Request time out Request time out Request time out Request time out
 10.0.4.4 ping statistics 
 5 packet(s) transmitted
 0 packet(s) received
100.00% packet loss
同样,还可以检测R1和S3以及R3和S4之间的连通性。此处不再赘述。
步骤六 配置 Hybrid 端口
配置端口的类型为Hybrid,可以实现端口为来自不同VLAN报文打上标签或去除标签的功能。本任务中,需要通过配置Hybrid端口来允许VLAN 2和VLAN 4之间可以互相通信。
将S1上的G0/0/1端口和S2上的G0/0/3和G0/0/6端口的类型配置为Hybrid。同时,配置这些端口发送数据帧时能够去掉VLAN 2和VLAN 4的标签。[S1] interface GigabitEthernet 0/0/1
[S1 GigabitEthernet0/0/1] undo port default vlan
[S1 GigabitEthernet0/0/1] port link type hybrid
[S1 GigabitEthernet0/0/1] port hybrid untagged vlan 2 4
[S1 GigabitEthernet0/0/1] port hybrid pvid vlan 4
[S2] interface GigabitEthernet 0/0/3
[S2 GigabitEthernet0/0/3] undo port default vlan
[S2 GigabitEthernet0/0/3] port link type hybrid
[S2 GigabitEthernet0/0/3] port hybrid untagged vlan 2 4
[S2 GigabitEthernet0/0/3] port hybrid pvid vlan 4
[S2 GigabitEthernet0/0/3] quit
[S2] interface GigabitEthernet 0/0/6
[S2 GigabitEthernet0/0/6] undo port default vlan
[S2 GigabitEthernet0/0/6] port link type hybrid
[S2 GigabitEthernet0/0/6] port hybrid untagged vlan 2 4
[S2 GigabitEthernet0/0/6] port hybrid pvid vlan 2
执行port hybrid pvid vlan命令,可以配置端口收到数据帧时需要给数据帧添加的VLAN标签。同时port hybrid untagged vlan命令可以配置该端口在向主机转发数据帧之前,删除相应的VLAN标签。
执行ping命令。测试VLAN 3中的R1与R3是否还能通信。
<R1> ping 10.0.4.3
 PING 10.0.4.3: 56 data bytes, press CTRL_C to break Reply from 10.0.4.3: bytes=56 Sequence=1 ttl=255 time=1 ms Reply from 10.0.4.3: bytes=56 Sequence=2 ttl=255 time=1 ms Reply from 10.0.4.3: bytes=56 Sequence=3 ttl=255 time=1 ms Reply from 10.0.4.3: bytes=56 Sequence=4 ttl=255 time=10 ms Reply from 10.0.4.3: bytes=56 Sequence=5 ttl=255 time=1 ms 10.0.4.3 ping statistics 
 5 packet(s) transmitted
 5 packet(s) received
 0.00% packet lossround trip min/avg/max = 1/2/10 ms
执行ping命令,测试VLAN 2中的S4能否与VLAN 4中的R1通信。
<R1> ping 10.0.4.4
 PING 10.0.4.4: 56 data bytes, press CTRL_C to break Reply from 10.0.4.4: bytes=56 Sequence=1 ttl=255 time=41 ms Reply from 10.0.4.4: bytes=56 Sequence=2 ttl=254 time=2 ms Reply from 10.0.4.4: bytes=56 Sequence=3 ttl=254 time=3 ms  Reply from 10.0.4.4: bytes=56 Sequence=4 ttl=254 time=2 ms Reply from 10.0.4.4: bytes=56 Sequence=5 ttl=254 time=2 ms 10.0.4.4 ping statistics 
 5 packet(s) transmitted
 5 packet(s) received
 0.00% packet loss
round trip min/avg/max = 2/10/41 ms
通过配置Hybrid端口,使VLAN 2内的主机能够接收来自VLAN 4的报文,反之亦然。而没有配置Hybrid端口的VLAN 3中地址为10.0.4.2的主机仍无法与其他VLAN主机通信。
配置文件
[R1] display current-configuration
[V200R007C00SPC600]
#
sysname R1
#
interface GigabitEthernet0/0/1ip address 10.0.4.1 255.255.255.0 #return 
[S3]display current configuration 
#
!Software Version V100R006C05sysname S3
#
interface Vlanif1
ip address 10.0.4.2 255.255.255.0
#
interface GigabitEthernet0/0/1shutdown
#
interface GigabitEthernet0/0/7shutdown
#
return
[S1]display current configuration 
#
!Software Version V200R008C00SPC500sysname S1
#
vlan batch 2 to 4
#
lacp priority 100
#
interface Eth Trunk1
第 9 页
port link type trunk port trunk allow pass vlan 2 to 4094mode lacp
#
interface GigabitEthernet0/0/1port link type hybridport hybrid pvid vlan 4port hybrid untagged vlan 2 4
#
interface GigabitEthernet0/0/9undo negotiation autospeed 100eth trunk 1lacp priority 100 #interface GigabitEthernet0/0/10undo negotiation autospeed 100eth trunk 1lacp priority 100
#
interface GigabitEthernet0/0/13port link type accessport default vlan 3
#
return
[S2]display current configuration 
#
!Software Version V200R008C00SPC500sysname S2
#
vlan batch 2 to 4
#
interface Eth Trunk1
port link type trunk
port trunk allow pass vlan 2 to 4094mode lacp # interface GigabitEthernet0/0/3port link type hybridport hybrid pvid vlan 4port hybrid untagged vlan 2 4#interface GigabitEthernet0/0/9
undo negotiation autospeed 100eth trunk 1
#
interface GigabitEthernet0/0/10 undo negotiation autospeed 100 eth trunk 1
#
interface GigabitEthernet0/0/6port link type hybridport hybrid pvid vlan 2port hybrid untagged vlan 2 4#
return
[R3]display current configuration 
[V200R007C00SPC600]
#
sysname R3
#
interface GigabitEthernet0/0/2ip address 10.0.4.3 255.255.255.0 #
return
[S4]display current configuration 
#
!Software Version V100R006C05sysname S4
#
interface Vlanif1
ip address 10.0.4.4 255.255.255.0
#
interface GigabitEthernet0/0/1shutdown
#
interface GigabitEthernet0/0/14shutdown
#
return

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

覃先宇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值