实验-华为VLAN的三种模式-(Access、Trunk、hybrid)

实验拓扑

实验要求

实验规划

实验配置

实验测试

实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第1张图片

实验要求

  • PC1和PC3接口都为 Access模式,VLAN2
  • PC2-PC4-PC5-PC6都为同一个网段
  • PC2可以访问PC4/5/6
  • PC4可以访问PC5,但不能访问PC6
  • PC5不能访问PC6

实验规划

实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第2张图片

  • 首先我们通过DHCP自动下放IP地址,可以在路由器上配置DHCP地址池,然后做DHCP中继
  • SW1连接PC1和PC3的接口成正常的Access模式,创建并划入VLAN2
  • PC2-PC4-PC5-PC6都在同一个网段,在同一个网段的话,通常情况下属于同一个VLAN,但是如果是同一个VLAN的话,难以实现PC4不能访问PC6,PC5不能访问PC6,那么此时需要多个VLAN来达成此要求,我们此时可以将PC2划入VLAN3,PC4划入VLAN2,PC5划入VLAN2,PC6划入VLAN3
  • PC2:此时需定义SW1连接PC2的接口定义为Hybrid,Pvid改为VLAN 3,但是对于VLAN 2&3流量不打标记 untagged vlan 2 3,通过DHCP下放IP地址
  • PC4:定义SW2连接PC4的接口定义为Hybrid,Pvid改为vlan 2,对于VLAN 2 & 3流量不打标记 untagged vlan 2 3,而PC4手动配置IP地址,虽然为VLAN 2,但是我们可以手动配置同VLAN 3同网段的IP地址
  • PC5:定义SW3连接PC5的接口为定义为Hybrid,Pvid改为vlan 2,对于VLAN 2&3 流量不打标记 untagged vlan 2 3,PC5手动配置IP地址,配置同VLAN3同网段的IP地址
  • PC6:定义SW3连接PC6的接口定义为Hybrid,Pvid为vlan 2,但是只对于VLAN 3的流量不打标记,untagged vlan 3,通过DHCP下IP地址

那么此时,这样规划之后
根据实验要求

  • PC2-PC4-PC5-PC6处于同一个网段,达成
  • PC2/4/5所在交换机接口模式都为Hybrid且都这对于VLAN 2/3流量都不打标记,此时可以正常通信,PC 6所在交换机接口为Hybrid,针对于VLAN 3流量不打标记,PC 2所在接口Pvid为vlan 3,此时PC2与PC6可以正常通信,达成
  • PC4可以访问PC5,PC 4和PC 6不能通信,达成
  • PC5和PC6不能通信,达成

实验配置

R1
<Huawei>system-view
[Huawei]sysname R1
[R1]interface e0/0/0
[R1-Ethernet0/0/0]ip address 12.1.1.1 255.255.255.0
[R1-Ethernet0/0/0]quit

[R1]ip pool 1
[R1-ip-pool-1]network 172.16.1.0 mask 255.255.255.0
[R1-ip-pool-1]gateway-list 172.16.1.1
[R1-ip-pool-1]excluded-ip-address 172.16.1.2
[R1-ip-pool-1]excluded-ip-address 172.16.1.3
[R1-ip-pool-1]quit

[R1]ip pool 2
[R1-ip-pool-2]network 172.16.2.0 mask 255.255.255.0
[R1-ip-pool-2]gateway-list 172.16.2.1
[R1-ip-pool-2]excluded-ip-address 172.16.2.2
[R1-ip-pool-2]excluded-ip-address 172.16.2.3

[R1]dhcp enable 
[R1]interface e0/0/0
[R1-Ethernet0/0/0]dhcp select global 
[R1-Ethernet0/0/0]quit 

[R1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2

SW1
<Huawei>system-view
[Huawei]sysname SW1
[SW1]interface Vlanif 1
[SW1-Vlanif1]ip address 12.1.1.2 255.255.255.0
[SW1-Vlanif1]quit 
[SW1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.1

[SW1]dhcp enable
[SW1]vlan 2
[SW1-vlan2]quit 
[SW1]vlan 3
[SW1-vlan3]quit 
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip address 172.16.1.1 255.255.255.0	
[SW1-Vlanif2]dhcp select relay 	
[SW1-Vlanif2]dhcp relay server-ip 12.1.1.1	
[SW1-Vlanif2]quit 

[SW1]interface Vlanif 3
[SW1-Vlanif3]ip address 172.16.2.1 255.255.255.0	
[SW1-Vlanif3]dhcp select relay 	
[SW1-Vlanif3]dhcp relay server-ip 12.1.1.1	
[SW1-Vlanif3]quit 

	
[SW1]interface g0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access 
[SW1-GigabitEthernet0/0/3]port default vlan	
[SW1-GigabitEthernet0/0/3]port default vlan 2
[SW1-GigabitEthernet0/0/3]quit 
[SW1]interface g0/0/4
[SW1-GigabitEthernet0/0/4]port hybrid pvid vlan 3
[SW1-GigabitEthernet0/0/4]port hybrid untagged vlan 2 to 3	
[SW1-GigabitEthernet0/0/4]quit 
[SW1]interface g0/0/2
[SW1-GigabitEthernet0/0/2]port link-type trunk 	
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 3
[SW1-GigabitEthernet0/0/2]quit 
SW2
<Huawei>system-view
[Huawei]sysname SW2
[SW2]dhcp enable
[SW2]vlan 2
[SW2-vlan2]quit 
[SW2]vlan 3
[SW2-vlan3]quit 

[SW2]dhcp enable
[SW2]interface Vlanif 2
[SW2-Vlanif2]ip address 172.16.1.2 255.255.255.0	
[SW2-Vlanif2]dhcp select relay 	
[SW2-Vlanif2]dhcp relay server-ip 12.1.1.1	
[SW2-Vlanif2]quit 

[SW2]interface Vlanif 3
[SW2-Vlanif3]ip address 172.16.2.2 255.255.255.0	
[SW2-Vlanif3]quit 

[SW2]interface g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk 	
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3
[SW2-GigabitEthernet0/0/1]quit 
[SW2]interface g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type trunk 	
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 3
[SW2-GigabitEthernet0/0/2]quit
[SW2]interface g0/0/3	
[SW2-GigabitEthernet0/0/3]port link-type access 
[SW2-GigabitEthernet0/0/3]port default vlan 2
[SW2-GigabitEthernet0/0/3]quit 	
[SW2]interface g0/0/4
[SW2-GigabitEthernet0/0/4]port hybrid pvid vlan 2
[SW2-GigabitEthernet0/0/4]port hybrid untagged vlan 2 to 3
[SW2-GigabitEthernet0/0/4]quit 
SW3
<Huawei>system-view 
[Huawei]sysname SW3	
[SW3]vlan 2
[SW3-vlan2]quit 
[SW3]vlan	
[SW3]vlan 3	
[SW3-vlan3]quit 

[SW3]dhcp enable 

[SW3]interface Vlanif 2
[SW3-Vlanif2]ip address 172.16.1.3 255.255.255.0
[SW3-Vlanif2]dhcp select relay 	
[SW3-Vlanif2]dhcp relay server-ip 12.1.1.1	
[SW3-Vlanif2]quit 
[SW3]interface Vlanif 3
[SW3-Vlanif3]ip address 172.16.2.3 255.255.255.0	
[SW3-Vlanif3]dhcp select relay 	
[SW3-Vlanif3]dhcp relay server-ip 12.1.1.1	
[SW3-Vlanif3]quit 

[SW3]interface g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk 	
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3	
[SW3-GigabitEthernet0/0/1]quit

[SW3]interface g0/0/2
[SW3-GigabitEthernet0/0/2]port hybrid pvid vlan 2	
[SW3-GigabitEthernet0/0/2]port hybrid untagged vlan 2 to 3
[SW3-GigabitEthernet0/0/2]quit 
[SW3]interface g0/0/3	
[SW3-GigabitEthernet0/0/3]port hybrid pvid vlan 3
[SW3-GigabitEthernet0/0/3]port hybrid untagged vlan 3
[SW3-GigabitEthernet0/0/3]quit 

测试

1.PC1和PC3接口都为 Access模式,VLAN2
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第3张图片
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第4张图片

2.PC2-PC4-PC5-PC6都为同一个网段
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第5张图片
3.PC2访问PC4/5/6
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第6张图片
4.PC4访问PC5/6,可以与5通,不可以与6通
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第7张图片
PC5与PC6通信
实验-华为VLAN的三种模式-(Access、Trunk、hybrid)_第8张图片

你可能感兴趣的:(NP,VLAN,交换机,华为,网络)