华为HCIA实验-VLAN划分

王哥哥 网络学习 5,052 次浏览 2条评论

这个实验tmd怎么有这么多,以前都是就端口划到对应的vlan里就好了,tmd有这么多种划分方法,日哦

拓扑图

基于端口划分VLAN

[SWA]vlan 10 //创建vlan10

[SWA-vlan10]int g0/0/1

[SWA-GigabitEthernet0/0/1]port link-type access //端口改成access模式

[SWA-GigabitEthernet0/0/1]port default vlan 10    //端口划入vlan 10

[SWA-vlan10]int g0/0/2

[SWA-GigabitEthernet0/0/2]port link-type access

[SWA-GigabitEthernet0/0/2]port default vlan 10

[SWA-vlan10]int g0/0/3

[SWA-GigabitEthernet0/0/3]port link-type access

[SWA-GigabitEthernet0/0/3]port default vlan 10

[SWA-GigabitEthernet0/0/3]quit

[SWA]dis vlan //查看VLAN端口信息,可以看到3哥端口划入VLAN 10

[SWA]display port vlan active    //查看vlan端口信息

基于MAC地址划分VLAN

将交换机连接主机的端口配置为hybrid端口模式,根据主机的MAC地址,化入相应的VLAN

[SWA]vlan 10 //创建vlan10

[SWA]int g0/0/1

[SWA-GigabitEthernet0/0/1]port default vlan 1     //由于前面将端口划入了VLAN 10,所以现在要把端口先改回VLAN 1,然后才能改成hybrid类型,否则会报错

[SWA-GigabitEthernet0/0/1]port link-type hybrid    //改成hybrid类型

[SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10    //hybrid端口下untagged vlan 10

[SWA]int g0/0/2

[SWA-GigabitEthernet0/0/2]port default vlan 1     

[SWA-GigabitEthernet0/0/2]port link-type hybrid    

[SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10    

[SWA]int g0/0/3

[SWA-GigabitEthernet0/0/3]port default vlan 1     

[SWA-GigabitEthernet0/0/3]port link-type hybrid    

[SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10    

[SWA]dis port vlan active    //配置了hybrid端口后untagged列表中增加了VLAN 10,默认是1

[SWA]vlan 10

[SWA-vlan10]mac-vlan ?

mac-address MAC address

 

[SWA-vlan10]mac-vlan mac-address ?

H-H-H MAC address

 

[SWA-vlan10]mac-vlan mac-address 5400-0000-0001    //VLAN10中绑定主机MAC

[SWA-vlan10]mac-vlan mac-address 5400-0000-0002

[SWA-vlan10]mac-vlan mac-address 5400-0000-0003

[SWA-vlan10]int g0/0/1

[SWA-GigabitEthernet0/0/1]mac-vlan enable    //端口下开启MAC-VLAN

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]mac-vlan enable

[SWA-GigabitEthernet0/0/2]int g0/0/3

[SWA-GigabitEthernet0/0/3]mac-vlan en

[SWA]dis mac-vlan mac-add all    查看VLAN中的mac地址绑定条目

基于子网地址划分VLAN

[SWA-vlan10]undo mac-vlan mac-address 5400-0000-0001    //删除前面的绑定

[SWA-GigabitEthernet0/0/1]undo mac-vlan enable    //取消mac-vlan

我们在查看下,看到里面的已经没了

 

华为交换机的端口默认是hybrid,所以不用修改。端口下直接配置untagged vlan10

[SWA-GigabitEthernet0/0/3]int g0/0/1

[SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10    //hybrid端口下配置下vlan10

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10

[SWA-GigabitEthernet0/0/2]int g0/0/3

[SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10

[SWA]dis port vlan active    //查看下

[SWA]vlan 10

[SWA-vlan10]ip-subnet-vlan ip 192.168.0.1 32    //配置ip地址绑定

[SWA-vlan10]ip-subnet-vlan ip 192.168.0.2 32

[SWA-vlan10]ip-subnet-vlan ip 192.168.0.3 32

[SWA-vlan10]int g0/0/1

[SWA-GigabitEthernet0/0/1]ip-subnet-vlan enable    //端口下开启ip-subnet-vlan

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]ip-subnet-vlan enable

[SWA-GigabitEthernet0/0/2]int g0/0/3

[SWA-GigabitEthernet0/0/3]ip-subnet-vlan enable

[SWA]dis ip-subnet-vlan vlan all    //查看vlan中的ip条目

基于协议划分VLAN

端口是hybrid类型,更具二,三层协议,将主机划到对应的端口

老样子先把前面的东西删掉

[SWA]vlan 10

[SWA-vlan10]undo ip-subnet-vlan all

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]undo ip-subnet-vlan enable

前面已经把端口配置到VLAN10了,这里就少一部,正常还是要做的

[SWA-GigabitEthernet0/0/3]int g0/0/1

[SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10

[SWA-GigabitEthernet0/0/2]int g0/0/3

[SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10

 

[SWA-GigabitEthernet0/0/3]vlan 10    //进入vlan10

[SWA-vlan10]protocol-vlan ipv4    //配置根据ipv4协议划分vlan

[SWA-vlan10]int g0/0/1

[SWA-GigabitEthernet0/0/1]protocol-vlan vlan 10 all    //端口下开启protocol-vlan,关联vlan10,并引用所有的配置协议

[SWA-GigabitEthernet0/0/1]int g0/0/2

[SWA-GigabitEthernet0/0/2]protocol-vlan vlan 10 all

[SWA-GigabitEthernet0/0/2]int g0/0/3

[SWA-GigabitEthernet0/0/3]protocol-vlan vlan 10 all    

 

[SWA]dis protocol-vlan vlan all    //查看vlan中绑定的协议

 

2 条评论

  1. 四月的奥德赛 2020年8月11日 18:23

    思科就第一种 按端口划分 VLAN

    • 王哥哥 2020年8月12日 09:31

      华为都是抄思科的 华为可以做到的东西思科也可以 思科叫pvlan 反正正常都是用端口划的

发表回复

Go