华为eNSP配置access、trunk、hybrid接口的配置实验

拓扑图如下:

华为eNSP配置access、trunk、hybrid接口的配置实验

(1)sw1的配置:

<Huawei>
<Huawei>system-view            //切换到系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw1             //配置主机名
Oct 25 2019 16:29: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 4, the c
hange loop count is 0, and the maximum number of records is 4095.   
[sw1]vlan batch 10 20            //创建vlan10 、vlan20
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1]display vlan               //查看vlan
Oct 25 2019 16:30:21-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.
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(D)     Eth0/0/4(D)     
                Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(U)      GE0/0/2(U)      

10   common                  //vlan10
20   common                  //vlan20

VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020                         
[sw1]
[sw1]int e0/0/1                    //切换接口
[sw1-Ethernet0/0/1]port hybrid pvid vlan 10            //hybrid口的pvid配置
[sw1-Ethernet0/0/1]
Oct 25 2019 16:30: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 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw1-Ethernet0/0/1]port hybrid untagged vlan 10    //hybrid口的untapped表配置
[sw1-Ethernet0/0/1]
Oct 25 2019 16:32: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 7, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw1-Ethernet0/0/1]
[sw1-Ethernet0/0/1]undo shutdown           //开启接口
Info: Interface Ethernet0/0/1 is not shutdown.
[sw1-Ethernet0/0/1]
[sw1-Ethernet0/0/1]int e0/0/2            //切换接口
[sw1-Ethernet0/0/2]
[sw1-Ethernet0/0/2]port hybrid pvid vlan 20            //hybrid口的pvid配置
[sw1-Ethernet0/0/2]
Oct 25 2019 16:32: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 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw1-Ethernet0/0/2]port hybrid untagged vlan 20    //hybrid口的untapped表配置
[sw1-Ethernet0/0/2]
[sw1-Ethernet0/0/2]undo shutdown           //开启接口
Info: Interface Ethernet0/0/2 is not shutdown.
[sw1-Ethernet0/0/2]
Oct 25 2019 16:33: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 9, the c
hange loop count is 0, and the maximum number of records is 4095.   
[sw1-Ethernet0/0/2]int g0/0/1       //切换接口
[sw1-GigabitEthernet0/0/1]port link-type access               //配置接口类型access
[sw1-GigabitEthernet0/0/1]port default vlan 10                //接口添加到vlan10
[sw1-GigabitEthernet0/0/1]
Oct 25 2019 16:34: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 11, the 
change loop count is 0, and the maximum number of records is 4095.
[sw1-GigabitEthernet0/0/1]undo shutdown                //开启接口
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[sw1-GigabitEthernet0/0/1]int g0/0/2                   //切换接口
[sw1-GigabitEthernet0/0/2]
[sw1-GigabitEthernet0/0/2]port hybrid tagged vlan 10 20      //配置hybrid口的tagged表
[sw1-GigabitEthernet0/0/2]
[sw1-GigabitEthernet0/0/2]
Oct 25 2019 16:35: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 12, the 
change loop count is 0, and the maximum number of records is 4095.
[sw1-GigabitEthernet0/0/2]
[sw1-GigabitEthernet0/0/2]undo shutdown       //开启接口
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[sw1-GigabitEthernet0/0/2]
[sw1-GigabitEthernet0/0/2]
[sw1-GigabitEthernet0/0/2]display this                  //查看当前视图配置信息
#
interface GigabitEthernet0/0/2
 port hybrid tagged vlan 10 20
#
return
[sw1-GigabitEthernet0/0/2]quit       //退出

(2)sw2的配置


<Huawei>system-view             //切换到系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw2                //配置主机名
Oct 25 2019 16:37: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 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw2]vlan batch 10 20                      //创建vlan10、vlan20
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2]dis vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(D)     Eth0/0/4(D)     
                Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(U)      GE0/0/2(U)      

10   common                             //vlan10
20   common                             //vlan20

VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020                         
[sw2]
Oct 25 2019 16:37: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 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw2]int e0/0/1             //切换接口视图
[sw2-Ethernet0/0/1]port link-type access          //配置接口类型为access 
Oct 25 2019 16:38: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 6, the c
hange loop count is 0, and the maximum number of records is 4095.   
[sw2-Ethernet0/0/1]port default vlan 10            //接口加入到vlan10
[sw2-Ethernet0/0/1]undo shutdown                  //开启接口
Info: Interface Ethernet0/0/1 is not shutdown.
Oct 25 2019 16:38: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 7, the c
hange loop count is 0, and the maximum number of records is 4095.   
[sw2-Ethernet0/0/1]int e0/0/2              //切换接口
[sw2-Ethernet0/0/2]
[sw2-Ethernet0/0/2]port link-type access       //配置接口类型为access
[sw2-Ethernet0/0/2]
[sw2-Ethernet0/0/2]port default vlan 20             //接口加入vlan20
Oct 25 2019 16:39: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 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw2-Ethernet0/0/2]undo shutdown                   //开启接口
Info: Interface Ethernet0/0/2 is not shutdown.
Oct 25 2019 16:39: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 9, the c
hange loop count is 0, and the maximum number of records is 4095.
[sw2-Ethernet0/0/2]int g0/0/1                //切换接口
[sw2-GigabitEthernet0/0/1]
[sw2-GigabitEthernet0/0/1]port link-type access        //配置接口类型为access
Oct 25 2019 16:40: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 10, the 
change loop count is 0, and the maximum number of records is 4095.
[sw2-GigabitEthernet0/0/1]port default vlan 20         //接口加入vlan20
[sw2-GigabitEthernet0/0/1]
[sw2-GigabitEthernet0/0/1]undo shutdown             //开启接口
Oct 25 2019 16:40: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 11, the 
change loop count is 0, and the maximum number of records is 4095.
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[sw2-GigabitEthernet0/0/1]
Oct 25 2019 16:41: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 12, the 
change loop count is 0, and the maximum number of records is 4095.
[sw2-GigabitEthernet0/0/2]int g0/0/2                 //切换接口
[sw2-GigabitEthernet0/0/2]
Oct 25 2019 16:45: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 13, the 
change loop count is 0, and the maximum number of records is 4095.
[sw2-GigabitEthernet0/0/2]
[sw2-GigabitEthernet0/0/2]port link-type trunk        //配置接口类型为trunk 
[sw2-GigabitEthernet0/0/2]
Oct 25 2019 16:46: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 14, the 
change loop count is 0, and the maximum number of records is 4095.v     
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20       //允许vlan10、vlan20通过
[sw2-GigabitEthernet0/0/2]
[sw2-GigabitEthernet0/0/2]undo shutdown           //开启接口
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[sw2-GigabitEthernet0/0/2]

(3)R1的配置

<Huawei>system-view      //切换系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1        //配置主机名
[R1]
Oct 25 2019 16:41:21-08:00 R1 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 1, the ch
ange loop count is 0, and the maximum number of records is 4095.
[R1]int g0/0/1               //切换接口
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]ip address 192.168.10.1 24      //配置IP地址
[R1-GigabitEthernet0/0/1]
Oct 25 2019 16:41:46-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state.
Oct 25 2019 16:41:51-08:00 R1 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 2, the ch
ange loop count is 0, and the maximum number of records is 4095.
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]undo shutdown         //开启接口
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]int g0/0/0               //切换接口
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]ip address 12.0.0.1 30       //配置IP地址
[R1-GigabitEthernet0/0/0]
Oct 25 2019 16:42:47-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]
[R1-GigabitEthernet0/0/0]undo shutdown           //开启接口
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]
Oct 25 2019 16:42:51-08:00 R1 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 3, the ch
ange loop count is 0, and the maximum number of records is 4095.
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]quit               //退出
[R1]ip route-static 192.168.20.0 24 12.0.0.2              //配置静态路由

(4)R2的配置

<Huawei>system-view            //切换系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]sysname R2             //配置主机名
[R2]
[R2]int g0/0/0                          // 切换接口
[R2-GigabitEthernet0/0/0]ip 
Oct 25 2019 16:44:04-08:00 R2 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 1, the ch
ange loop count is 0, and the maximum number of records is 4095.add 
[R2-GigabitEthernet0/0/0]ip address 12.0.0.2 30             //配置IP地址
[R2-GigabitEthernet0/0/0]
Oct 25 2019 16:44:13-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.
Oct 25 2019 16:44:14-08:00 R2 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 2, the ch
ange loop count is 0, and the maximum number of records is 4095.
[R2-GigabitEthernet0/0/0]
[R2-GigabitEthernet0/0/0]undo shutdown           //开启接口
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]
[R2-GigabitEthernet0/0/0]int g0/0/1              //切换接口
[R2-GigabitEthernet0/0/1]
[R2-GigabitEthernet0/0/1]ip address 192.168.20.1 24          //配置IP地址
[R2-GigabitEthernet0/0/1]
Oct 25 2019 16:44:41-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-GigabitEthernet0/0/1]
[R2-GigabitEthernet0/0/1]undo shutdown             //开启接口
Oct 25 2019 16:44:44-08:00 R2 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 3, the ch
ange loop count is 0, and the maximum number of records is 4095.
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]quit             //退出
[R2]ip route-static 192.168.10.0 24 12.0.0.1         //配置静态路由

(5)分别给每个PC机,配置IP地址、子网掩码和网关

PC1配置

华为eNSP配置access、trunk、hybrid接口的配置实验

PC2配置

华为eNSP配置access、trunk、hybrid接口的配置实验

PC3配置

华为eNSP配置access、trunk、hybrid接口的配置实验

PC4配置

华为eNSP配置access、trunk、hybrid接口的配置实验

(6)实验测试

用PC1去pingPC3的IP地址,可以互通。用抓包软件在sw2的GE0/0/2接口能够抓到数据包。

华为eNSP配置access、trunk、hybrid接口的配置实验

用PC1去pingPC4的IP地址,可以互通。用抓包软件在R2的GE0/0/0接口能够抓到数据包。

华为eNSP配置access、trunk、hybrid接口的配置实验

相关文章

1.小程序的优缺点优点:不需下载、卸载使用方便缺点:嵌套在...
端口类型-HybridHybrid端口是交换机上既可以连接用户主机,又...
不同vlan同段IP通信LSW1vlan1vlan2vlan3interfaceEthernet0/...
VLAN中access、Trunk和Hybrid三种端口区别:acesss:1、发送...
这系列文章内容包括:STP、RSTP、MSTP、VLAN、LACP、SuperVL...