VLAN实验1

实验拓扑

实验需求

1、PC1和PC3所在接口为access接口,属于VLAN 2

2、PC2/4/5/6处于同一网段 其中PC2可以访问PC4/5/6 PC4可以访问PC5不能访问PC6

      PC5不能访问PC6

3、PC1/3和PC2/4/5/6不在一个网段,且可以正常通讯

4、所有PC通过DHCP获取IP地址,且PC1/3可以正常访问PC2/4/5/6

实验步骤

配置

SW1命令
<Huawei>sys
Mar 23 2025 01:43:30-08:00 Huawei %%01PHY/1/PHY(l)[0]:    GigabitEthernet0/0/1: 
change status to up
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn SW1
[SW1]
Mar 23 2025 01:43:41-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1]vlan batch 2 to 6
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]
Mar 23 2025 01:44:01-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1]int g 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]
Mar 23 2025 01:44:31-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/2]port default vlan 2
[SW1-GigabitEthernet0/0/2]
Mar 23 2025 01:44:51-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 7, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/2]int g 0/0/3
[SW1-GigabitEthernet0/0/3]po
Mar 23 2025 01:45:07-08:00 SW1 %%01PHY/1/PHY(l)[1]:    GigabitEthernet0/0/2: cha
nge status to downrt 
Mar 23 2025 01:45:08-08:00 SW1 %%01PHY/1/PHY(l)[2]:    GigabitEthernet0/0/2: cha
nge status to up
                               ^
Error:Incomplete command found at '^' position.
[SW1-GigabitEthernet0/0/3]port link-type hybrid
[SW1-GigabitEthernet0/0/3]port hybrid pvid vlan 3
[SW1-GigabitEthernet0/0/3]
Mar 23 2025 01:46:01-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/3]p
Mar 23 2025 01:46:07-08:00 SW1 %%01PHY/1/PHY(l)[3]:    GigabitEthernet0/0/2: cha
nge status to downort
Mar 23 2025 01:46:08-08:00 SW1 %%01PHY/1/PHY(l)[4]:    GigabitEthernet0/0/2: cha
nge status to up 
                               ^
Error:Incomplete command found at '^' position.
[SW1-GigabitEthernet0/0/3]port hybrid untagged vlan 2 to 6
[SW1-GigabitEthernet0/0/3]
Mar 23 2025 01:46:51-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/3]int g 0/0/4
[SW1-GigabitEthernet0/0/4]port link-type trunk
[SW1-GigabitEthernet0/0/4]
Mar 23 2025 01:47:41-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 10, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[SW1-GigabitEthernet0/0/4]
Mar 23 2025 01:48:11-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 11, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/4]int g 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type hybrid
[SW1-GigabitEthernet0/0/1]port hybrid untagged vlan 3 4 5 6
[SW1-GigabitEthernet0/0/1]
Mar 23 2025 01:49:11-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 12, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/1]port hybrid tagged vlan 2
[SW1-GigabitEthernet0/0/1]
Mar 23 2025 01:49:51-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 13, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-GigabitEthernet0/0/1]dis th
#
interface GigabitEthernet0/0/1
 port hybrid tagged vlan 2
 port hybrid untagged vlan 3 to 6
#
return
[SW1-GigabitEthernet0/0/1]int g 0/0/2
[SW1-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 2
#
return
[SW1-GigabitEthernet0/0/2]int g 0/0/3
[SW1-GigabitEthernet0/0/3]dis th
#
interface GigabitEthernet0/0/3
 port hybrid pvid vlan 3
 port hybrid untagged vlan 2 to 6
#
return
[SW1-GigabitEthernet0/0/3]int g 0/0/4
[SW1-GigabitEthernet0/0/4]dis th
#
interface GigabitEthernet0/0/4
 port link-type trunk
 port trunk allow-pass vlan 2 to 6
#
return
[SW1-GigabitEthernet0/0/4]quit
SW2命令
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn SW2
[SW2]
Mar 23 2025 01:52:12-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2]int g 0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]
Mar 23 2025 01:52:42-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
[SW2-GigabitEthernet0/0/1]
Mar 23 2025 01:53:12-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/1]int g 0/0/3
[SW2-GigabitEthernet0/0/3]q
[SW2]vlan batch 2 to 6
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]
Mar 23 2025 01:54:22-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 7, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2]int g 0/0/3
[SW2-GigabitEthernet0/0/3]port default vlan 2
                               ^
Error: Unrecognized command found at '^' position.
[SW2-GigabitEthernet0/0/3]port default vlan 2
                               ^
Error: Unrecognized command found at '^' position.
[SW2-GigabitEthernet0/0/3]
Mar 23 2025 02:00:13-08:00 SW2 %%01PHY/1/PHY(l)[0]:    GigabitEthernet0/0/2: cha
nge status to down
Mar 23 2025 02:00:14-08:00 SW2 %%01PHY/1/PHY(l)[1]:    GigabitEthernet0/0/2: cha
nge status to up
[SW2-GigabitEthernet0/0/3]port default vlan 2
                               ^
Error: Unrecognized command found at '^' position.
[SW2-GigabitEthernet0/0/3]dis th
#
interface GigabitEthernet0/0/3
#
return
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]
Mar 23 2025 02:02:32-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/3]port default vlan 2
[SW2-GigabitEthernet0/0/3]
Mar 23 2025 02:02:52-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/3]int g 0/0/4
[SW2-GigabitEthernet0/0/4]port link-type hybrid
[SW2-GigabitEthernet0/0/4]port hybrid pvid vlan 4
[SW2-GigabitEthernet0/0/4]
Mar 23 2025 02:03:42-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 10, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/4]dis th
#
interface GigabitEthernet0/0/4
 port hybrid pvid vlan 4
#
return
[SW2-GigabitEthernet0/0/4]port hybrid untagged vlan 2 to 5
[SW2-GigabitEthernet0/0/4]
Mar 23 2025 02:04:22-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 11, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/4]dis th
#
interface GigabitEthernet0/0/4
 port hybrid pvid vlan 4
 port hybrid untagged vlan 2 to 5
#
return
[SW2-GigabitEthernet0/0/4]int g 0/0
Mar 23 2025 02:04:35-08:00 SW2 %%01PHY/1/PHY(l)[2]:    GigabitEthernet0/0/2: cha
nge status to down/
Mar 23 2025 02:04:36-08:00 SW2 %%01PHY/1/PHY(l)[3]:    GigabitEthernet0/0/2: cha
nge status to up
                          ^
Error: Unrecognized command found at '^' position.
[SW2-GigabitEthernet0/0/4]
[SW2-GigabitEthernet0/0/4]int g 0/0/2
[SW2-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
#
return
[SW2-GigabitEthernet0/0/2]port link-type trunk
[SW2-GigabitEthernet0/0/2]port trunk
Mar 23 2025 02:05:22-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 12, the 
change loop count is 0, and the maximum number of records is 4095
[SW2-port-group-trun]q
[SW2]
Mar 23 2025 02:05:32-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 13, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2]int g 0/0/2
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 6
[SW2-GigabitEthernet0/0/2]
Mar 23 2025 02:05:58-08:00 SW2 %%01PHY/1/PHY(l)[4]:    GigabitEthernet0/0/2: cha
nge status to down
Mar 23 2025 02:05:59-08:00 SW2 %%01PHY/1/PHY(l)[5]:    GigabitEthernet0/0/2: cha
nge status to up
Mar 23 2025 02:06:02-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 14, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
 port link-type trunk
 port trunk allow-pass vlan 2 to 6
#
return
[SW2-GigabitEthernet0/0/2]
Mar 23 2025 02:08:09-08:00 SW2 %%01PHY/1/PHY(l)[6]:    GigabitEthernet0/0/3: cha
nge status to up User interface con0 is available



Please Press ENTER.
SW3命令
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn SW3
[SW3]
Mar 23 2025 02:07:34-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3]vlan batch 2 to 6
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW3]
Mar 23 2025 02:07:54-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3]int g 0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]
Mar 23 2025 02:08:14-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
[SW3-GigabitEthernet0/0/1]
Mar 23 2025 02:08:44-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 7, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/1]dis th
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 2 to 6
#
return
[SW3-GigabitEthernet0/0/1]int g 0/0/2
[SW3-GigabitEthernet0/0/2]port link-type hybrid
[SW3-GigabitEthernet0/0/2]port hybrid pvid vlan 5
[SW3-GigabitEthernet0/0/2]
Mar 23 2025 02:09:34-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
 port hybrid pvid vlan 5
#
return
[SW3-GigabitEthernet0/0/2]port hybrid untagged vlan 2 to 5
[SW3-GigabitEthernet0/0/2]
Mar 23 2025 02:10:24-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
 port hybrid pvid vlan 5
 port hybrid untagged vlan 2 to 5
#
return
[SW3-GigabitEthernet0/0/2]int g 0/0/3
[SW3-GigabitEthernet0/0/3]port link-type hybrid
[SW3-GigabitEthernet0/0/3]port hybrid pvid vlan 6
[SW3-GigabitEthernet0/0/3]
Mar 23 2025 02:11:24-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 10, the 
change loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/3]port hybrid untagged vlan 2 to 3 6
[SW3-GigabitEthernet0/0/3]
Mar 23 2025 02:11:54-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 11, the 
change loop count is 0, and the maximum number of records is 4095.
[SW3-GigabitEthernet0/0/3]dis th
#
interface GigabitEthernet0/0/3
 port hybrid pvid vlan 6
 port hybrid untagged vlan 2 to 3 6
#
return
[SW3-GigabitEthernet0/0/3] User interface con0 is available



Please Press ENTER.
R1命令
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn R1
[R1]ip pool bp
Info: It's successful to create an IP address pool.
[R1-ip-pool-bp]network 192.168.1.0 mask 24
[R1-ip-pool-bp]gateway-list 192.168.1.100
[R1-ip-pool-bp]qu
[R1]ip pool pk
Info: It's successful to create an IP address pool.
[R1-ip-pool-pk]network 192.168.2.0 mask 24
[R1-ip-pool-pk]gateway-list 192.168.2.100
[R1-ip-pool-pk]qu
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip add 192.168.1.100.24
                                  ^
Error: Wrong parameter found at '^' position.
[R1-GigabitEthernet0/0/0.1]ip address 192.168.1.100 24
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
Mar 23 2025 02:17:15-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0.1 has entered the UP state. 
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1-GigabitEthernet0/0/0.1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.2.100 24
Mar 23 2025 02:18:33-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R1-GigabitEthernet0/0/0]dhcp select global
[R1-GigabitEthernet0/0/0]qu
[R1]dis ip int bri
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              192.168.2.100/24     up         up        
GigabitEthernet0/0/0.1            192.168.1.100/24     up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     
[R1]

  Please check whether system data has been changed, and save data in time

  Configuration console time out, please press any key to log on

配置结果在命令中所示

结果验证

IP获取
连通性测试

PC1-可以正常访问PC3/PC6(PC245)

PC4可以访问PC5不能访问PC6

PC2可以访问PC4/5/6

PC5不能访问PC6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值