实验一

搭建拓扑

配置PC IPv4

PC2:192.168.1.2 子网掩码:255.255.255.0

PC3:192.168.1.3 子网掩码:255.255.255.0

PC4:192.168.1.4 子网掩码:255.255.255.0

方案一

1、方案一:用户端口采用Access类型,交换机间连接端口采用Trunk类型

(1)在SwitchA和SwitchB创建VLAN10和VLAN20,并将连接用户的端口类型都设置为Access类型,然后分别加入对应的VLAN中。

对SwitchA创建VLAN

//重命名
<Huawei>system-view
[Huawei]sysname SwitchA

//对SwitchA创建用户侧VLAN10 20
<SwitchA>system-view
[SwitchA]vlan 10
[SwitchA-vlan10]quit
[SwitchA]vlan 20
[SwitchA-vlan20]quit

//对SwitchA配置用户侧接入链路端口类型Access
	//对PC1 0/0/1 VLAN10
[SwitchA]interface Ethernet 0/0/1
[SwitchA-Ethernet0/0/1]port link-type access
[SwitchA-Ethernet0/0/1]port default vlan 10
[SwitchA-Ethernet0/0/1]quit
	//对PC2 0/0/2 VLAN20
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port link-type access
[SwitchA-Ethernet0/0/2]port default vlan 20
[SwitchA-Ethernet0/0/2]quit

对SwitchB创建VLAN

//重命名
<Huawei>system-view
[Huawei]sysname SwitchB

//对SwitchB创建用户侧VLAN10 20
<SwitchB>system-view
[SwitchB]vlan 10
[SwitchB-vlan10]quit
[SwitchB]vlan 20
[SwitchB-vlan20]quit

//对SwitchB配置用户侧接入链路端口类型Access
	//对PC3 0/0/2 VLAN10
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port link-type access
[SwitchB-Ethernet0/0/2]port default vlan 10
[SwitchB-Ethernet0/0/2]quit
	//对PC4 0/0/3 VLAN20
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port link-type access
[SwitchB-Ethernet0/0/3]port default vlan 20
[SwitchB-Ethernet0/0/3]quit

(2)配置SwitchA与SwitchB连接的端口类型为Trunk,同时允许VLAN 10和VLAN 20通过。

对SwitchA干道链路配置

//对SwitchA干道链路配置  VLAN的Trunk端口配置
<SwitchA>system-view 
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port link-type trunk
[SwitchA-Ethernet0/0/3]port trunk allow-pass vlan 10  20 
[SwitchA-Ethernet0/0/3]return

对SwitchB干道链路配置

<SwitchB>system-view 
[SwitchB]interface Ethernet 0/0/1
[SwitchB-Ethernet0/0/1]port link-type trunk
[SwitchB-Ethernet0/0/1]port trunk allow-pass vlan 10  20 
[SwitchB-Ethernet0/0/1]return

(3)任务测试:使用display port vlan查看并确认S1和S2上已成功创建VLAN,且已将相应端口划分到对应的VLAN中。记录查看结果。给PC1、PC2、PC3、PC4设置同网段IP地址,使用Ping命令检查VLAN内和VLAN间的连通性。

查看SwitchA

//SwitchA
<SwitchA>system-view 
[SwitchA]display port vlan

查看SwitchB

//SwitchB
<SwitchB>system-view 
[SwitchB]display port vlan

vmware_FpFhUz6JAu

Ping

PC1对PC3

vmware_BHOrdLmHOl

PC1对PC4

vmware_42XFV2Iv0y

PC3对PC1

vmware_DDz5U9oJDV

PC3对PC2

vmware_ReZeoLQ8Pv

可见,同VLAN可通,不同VLAN被阻

方案二

vmware_KGc1uKZp2O

方案二:用户端口采用Access类型,交换机间连接端口采用带标签的Hybrid类型。

(1)在SwitchA和SwitchB创建VLAN30和VLAN40,并将连接用户的端口类型都设置为Access类型,然后分别加入对应的VLAN中。

对SwitchA创建VLAN

//对SwitchA创建用户侧VLAN30 40
<Huawei>system-view
[Huawei]sysname SwitchA
[SwitchA]vlan 30
[SwitchA-vlan30]quit
[SwitchA]vlan 40
[SwitchA-vlan40]quit
    
//对SwitchA配置用户侧接入链路端口类型Access
	//对PC1 0/0/2 VLAN30
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port link-type access
[SwitchA-Ethernet0/0/2]port default vlan 30
[SwitchA-Ethernet0/0/2]quit
	//对PC2 0/0/3 VLAN40
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port link-type access
[SwitchA-Ethernet0/0/3]port default vlan 40
[SwitchA-Ethernet0/0/3]quit

对SwitchB创建VLAN

//对SwitchB创建用户侧VLAN30 40
<Huawei>system-view
[Huawei]sysname SwitchB
[SwitchB]vlan 30
[SwitchB-vlan10]quit
[SwitchB]vlan 40
[SwitchB-vlan20]quit

//对SwitchB配置用户侧接入链路端口类型Access
	//对PC3 0/0/2 VLAN30
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port link-type access
[SwitchB-Ethernet0/0/2]port default vlan 30
[SwitchB-Ethernet0/0/2]quit
	//对PC4 0/0/3 VLAN40
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port link-type access
[SwitchB-Ethernet0/0/3]port default vlan 40
[SwitchB-Ethernet0/0/3]quit

(2)在SwitchA和SwitchB配置SwitchA与SwitchB连接的端口类型为Hybrid,并以**Tagged(带标签)**方式同时加入VLAN30和VLAN40中。

//对SwitchA配置混合端口
[SwitchA]interface Ethernet 0/0/1
[SwitchA-Ethernet0/0/1]port link-type hybrid 
[SwitchA-Ethernet0/0/1]port hybrid tagged vlan 30 40
[SwitchA-Ethernet0/0/1]quit
//对SwitchB配置混合端口
[SwitchB]interface Ethernet 0/0/1
[SwitchB-Ethernet0/0/1]port link-type hybrid 
[SwitchB-Ethernet0/0/1]port hybrid tagged vlan 30 40
[SwitchB-Ethernet0/0/1]quit

(3)任务测试:使用display port vlan查看并确认S1和S2上已成功创建VLAN,且已将相应端口划分到对应的VLAN中。记录查看结果。给PC1、PC2、PC3、PC4设置同网段IP地址,使用Ping命令检查VLAN内和VLAN间的连通性。

[SwitchA]display port vlan

vmware_sxBRv7iXIo

[SwitchB]display port vlan

Ping

vmware_IAdxs1irN6

由此可得,该方案可行,同VLAN可通,不同VLAN不通。

方案三

vmware_pGQ5aGdx8l

3、方案三:用户端口采用不带标签的Hybrid类型,交换机间连接端口采用Trunk类型。

(1)在SwitchA和SwitchB创建VLAN50和VLAN60,并将连接用户的端口类型都设置为Hybrid类型,然后分别以Untagged方式加入对应的VLAN中,并且把对应的VLAN ID设置这些Hybrid端口的PVID。

在SwitchA和SwitchB创建VLAN50和VLAN60

//对SwitchA创建用户侧VLAN50 60 
<Huawei>system-view
[Huawei]sysname SwitchA
[SwitchA]vlan 50
[SwitchA-vlan50]quit
[SwitchA]vlan 60
[SwitchA-vlan60]quit
    
//对SwitchB创建用户侧VLAN50 60 
<Huawei>system-view
[Huawei]sysname SwitchB
[SwitchB]vlan 50
[SwitchB-vlan50]quit
[SwitchB]vlan 60
[SwitchB-vlan60]quit

将连接用户的端口类型都设置为Hybrid类型

//对SwitchA将连接用户的端口类型都设置为Hybrid类型
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port link-type hybrid 
[SwitchA-Ethernet0/0/2]quit
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port link-type hybrid
[SwitchA-Ethernet0/0/3]quit
    
//对SwitchB将连接用户的端口类型都设置为Hybrid类型
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port link-type hybrid 
[SwitchB-Ethernet0/0/2]quit
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port link-type hybrid
[SwitchB-Ethernet0/0/3]quit

分别以Untagged方式加入对应的VLAN中,并且把对应的VLAN ID设置这些Hybrid端口的PVID。

//对SwitchA PC1
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port hybrid untagged vlan 50
[SwitchA-Ethernet0/0/2]port hybrid pvid vlan 50
[SwitchA-Ethernet0/0/2]quit   
//对SwitchA PC2
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port hybrid untagged vlan 60
[SwitchA-Ethernet0/0/3]port hybrid pvid vlan 60
[SwitchA-Ethernet0/0/3]quit  

//对SwitchB PC3
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port hybrid untagged vlan 50
[SwitchB-Ethernet0/0/2]port hybrid pvid vlan 50
[SwitchB-Ethernet0/0/2]quit   
//对SwitchB PC4
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port hybrid untagged vlan 60
[SwitchB-Ethernet0/0/3]port hybrid pvid vlan 60
[SwitchB-Ethernet0/0/3]quit  

(2)在SwitchA和SwitchB配置SwitchA与SwitchB连接的端口类型为Trunk,同时允许VLAN 50和VLAN 60通过。

//对SwitchA
[SwitchA]interface Ethernet 0/0/1
[SwitchA-Ethernet0/0/1]port link-type trunk
[SwitchA-Ethernet0/0/1]port trunk allow-pass vlan 50  60
[SwitchA-Ethernet0/0/1]quit
//对SwitchB
[SwitchB]interface Ethernet 0/0/1
[SwitchB-Ethernet0/0/1]port link-type trunk
[SwitchB-Ethernet0/0/1]port trunk allow-pass vlan 50  60
[SwitchB-Ethernet0/0/1]quit

(3)任务测试:使用display port vlan查看并确认S1和S2上已成功创建VLAN,且已将相应端口划分到对应的VLAN中。记录查看结果。给PC1、PC2、PC3、PC4设置同网段IP地址,使用Ping命令检查VLAN内和VLAN间的连通性。

ping

vmware_qy0aIhYLg8

由此可得,该方案可行,同VLAN可通,不同VLAN不通。

方案四

vmware_PENjNMh7xf

4、方案四:用户端口采用不带标签的Hybrid类型,交换机间连接端口采用带标签的Hybrid类型。

(1)在SwitchA和SwitchB创建VLAN70和VLAN80,并将连接用户的端口类型都设置为Hybrid类型,然后分别以Untagged方式加入对应的VLAN中,并且把对应的VLAN ID设置这些Hybrid端口的PVID。

在SwitchA和SwitchB创建VLAN70和VLAN80

//对SwitchA创建用户侧VLAN70 80 
<Huawei>system-view
[Huawei]sysname SwitchA
[SwitchA]vlan 70
[SwitchA-vlan70]quit
[SwitchA]vlan 80
[SwitchA-vlan80]quit
    
//对SwitchB创建用户侧VLAN70 80 
<Huawei>system-view
[Huawei]sysname SwitchB
[SwitchB]vlan 70
[SwitchB-vlan70]quit
[SwitchB]vlan 80
[SwitchB-vlan80]quit

将连接用户的端口类型都设置为Hybrid类型

//对SwitchA将连接用户的端口类型都设置为Hybrid类型
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port link-type hybrid 
[SwitchA-Ethernet0/0/2]quit
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port link-type hybrid
[SwitchA-Ethernet0/0/3]quit
    
//对SwitchB将连接用户的端口类型都设置为Hybrid类型
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port link-type hybrid 
[SwitchB-Ethernet0/0/2]quit
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port link-type hybrid
[SwitchB-Ethernet0/0/3]quit

分别以Untagged方式加入对应的VLAN中,并且把对应的VLAN ID设置这些Hybrid端口的PVID。

//对SwitchA PC1
[SwitchA]interface Ethernet 0/0/2
[SwitchA-Ethernet0/0/2]port hybrid untagged vlan 70
[SwitchA-Ethernet0/0/2]port hybrid pvid vlan 70
[SwitchA-Ethernet0/0/2]quit   
//对SwitchA PC2
[SwitchA]interface Ethernet 0/0/3
[SwitchA-Ethernet0/0/3]port hybrid untagged vlan 80
[SwitchA-Ethernet0/0/3]port hybrid pvid vlan 80
[SwitchA-Ethernet0/0/3]quit  

//对SwitchB PC3
[SwitchB]interface Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port hybrid untagged vlan 70
[SwitchB-Ethernet0/0/2]port hybrid pvid vlan 70
[SwitchB-Ethernet0/0/2]quit   
//对SwitchB PC4
[SwitchB]interface Ethernet 0/0/3
[SwitchB-Ethernet0/0/3]port hybrid untagged vlan 80
[SwitchB-Ethernet0/0/3]port hybrid pvid vlan 80
[SwitchB-Ethernet0/0/3]quit  

(2)在SwitchA和SwitchB配置SwitchA与SwitchB连接的端口类型为Hybrid,并以Tagged(带标签)方式同时加入VLAN70和VLAN80中。

//对SwitchA
[SwitchA]interface Ethernet 0/0/1
[SwitchA-Ethernet0/0/1]port link-type hybrid 
[SwitchA-Ethernet0/0/1]port hybrid tagged vlan 70 80
[SwitchA-Ethernet0/0/1]quit
//对SwitchB
[SwitchB]interface Ethernet 0/0/1
[SwitchB-Ethernet0/0/1]port link-type hybrid 
[SwitchB-Ethernet0/0/1]port hybrid tagged vlan 70 80
[SwitchB-Ethernet0/0/1]quit

(3)任务测试:使用display port vlan查看并确认S1和S2上已成功创建VLAN,且已将相应端口划分到对应的VLAN中。记录查看结果。给PC1、PC2、PC3、PC4设置同网段IP地址,使用Ping命令检查VLAN内和VLAN间的连通性。

[SwitchA]display port vlan

vmware_GC5v8riNJ1

[SwitchB]display port vlan

vmware_85vyuOLF03

ping

vmware_UetWUFddJb

由此可得,该方案可行,同VLAN可通,不同VLAN不通。

Q.E.D.


--------------------------------舟清颺的个人博客-------------------------------