华为ensp 二层交换机使用vlan实现不同网段互通
实验拓扑图如下
1.只使用Vlan的trunk接口和access接口实现两个二层交换机上属于不同Vlan的PC互通
备注:需要使用到port trunk pvid vlan xx 等实现该功能。

提前配置好IP地址及端口地址
LSW10配置:
#
sysname LSW10
#
vlan batch 10 20 100
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type access
port default vlan 100
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
#
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20 100
#
LSW11配置:
#
sysname LSW11
#
vlan batch 10 20 100
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type access
port default vlan 100
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
#
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20 100
#
pc17 与 pc20 互通

pc18 与 pc21 互通

pc19 与 pc22 互通

结果:pc17 与 pc20 互通, pc18 与 pc21 互通, pc19 与 pc22 互通,其它相互ping不通。
若想让PC17ping通pc22需在LSW10接口Ethernet0/0/4上添加port trunk pvid vlan 10,
再LSW11接口Ethernet0/0/4上添加port trunk pvid vlan 20 。
同理:PC19ping通pc20需在LSW10接口Ethernet0/0/4上添加port trunk pvid vlan 20,
再LSW11接口Ethernet0/0/4上添加port trunk pvid vlan 10 。
本实验应该应用两交换机,两个pc较为准确。
实验二:
2. 使用hybrid的端口实现两个二层交换机上属于不同Vlan的PC互通

提前配置好ip及端口地址
LSW12配置:
#
sysname LSW12
#
vlan batch 10 20
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1 //华为交换机默认port link-tyep hybrid
port hybrid untagged vlan 10 20
#
interface Ethernet0/0/2
port link-type access
port default vlan 20
#
interface Ethernet0/0/3 //华为交换机默认port link-tyep hybrid
port hybrid pvid vlan 20
port hybrid tagged vlan 10 20
#
LSW13配置:
#
sysname LSW13
#
vlan batch 10 20
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1 //华为交换机默认port link-tyep hybrid
port hybrid untagged vlan 10 20
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3 //华为交换机默认port link-tyep hybrid
port hybrid pvid vlan 20
port hybrid tagged vlan 10 20
#
各pc23,pc24,pc25互ping



结果: pc25可以ping通pc23,24,而pc23不能ping通pc24。
实验三:
3. 使用hybrid的端口实现二层交换机上属于不同Vlan的PC互通

提前配置好端口ip地址
LSW2配置:
[Huawei]vlan batch 10 20 30
[Huawei]interface e0/0/1
[Huawei-Ethernet0/0/1]port link-type hybrid //华为交换机默认配置
[Huawei-Ethernet0/0/1]port hybrid pvid vlan 10
[Huawei-Ethernet0/0/1]port hybrid untagged vlan 10 20 30
[Huawei-Ethernet0/0/1]quit
[Huawei]interface e0/0/2
[Huawei-Ethernet0/0/2]port link-type hybrid //华为交换机默认配置
[Huawei-Ethernet0/0/2]port hybrid pvid vlan 20
[Huawei-Ethernet0/0/2]port hybrid untagged vlan 10 20
[Huawei-Ethernet0/0/1]quit
[Huawei]interface e0/0/3
[Huawei-Ethernet0/0/3]port link-type hybrid //华为交换机默认配置
[Huawei-Ethernet0/0/3]port hybrid pvid vlan 30
[Huawei-Ethernet0/0/3]port hybrid untagged vlan 10 30
[Huawei-Ethernet0/0/3]quit
实验结果:
pc1可以ping通pc2和pc3,pc2和pc3不能互通。



