一、基于接口的Vlan划分
在Switch创建VLAN 2和VLAN3,并将连接用户的接口分别加入对应VLAN。
<HUAWEI>system-view
[HUAWEl] sysname SwitchA
[SwitchA]vlan batch23 //批量创建VLAN 2和VLAN 3
[SwitchA]interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type access //和接入设备相连的接口类型必须是access,接口默认类型不是access,需要手动配置为access
[SwitchA-GigabitEthernet0/0/1]port default vlan2 //将接GE0/0/1加入VLAN 2
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA]interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type access
[SwitchA-GigabitEthernet0/0/2] port default vlan3 //将接¥GE0/0/2加入VLAN 3
[SwitchA-GigabitEthernet0/0/2] quit
二、基于MAC地址划分
配置SwitchA。
<HUAWEl>system-view
[HUAWEl] sysname SwitchA
[SwitchA] vlan batch 100 200 //创建VLAN 100和VLAN 200
[SwitchA]interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type trunk //交换机之间相连接口类型建议使用trunk,接口默认类型不是trunk,需要手动配置为trunk
[SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 100 200//接GE0/0/2加入VLAN 100和VLAN 200
[SwitchA-GigabitEthernet0/0/2]quit
[SwitchA] vlan 100
[SwitchA-vlan100] mac-vlan mac-address 00e0-fcef-00c0 //MAc地址为00e0-fcef-00c0的报文在VLAN100内转发
[SwitchA-vlan100] quit
[SwitchA] vlan 200
[SwitchA-vlan200] mac-vlan mac-address 00e0-fcef-00c1 //MAC地址为00e0-fcef-00c1的报文在VLAN200内转发
[SwitchA-vlan200] quit
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1l port link-type hvbrid //基于MAC划分VLAN只能应用在类型为hybrid的接口,默认接口类型不是hybrid,需要手动配置
[SwitchA-GigabitEthernet0/0/1] port hybrid untagged vlan 100 200//对VLAN为100、200的报文,剥掉VLAN Tag
[SwitchA-GigabitEthernet0/0/1]mac-vlan enable //使能接囗的MAC-VLAN功能
[SwitchA-GigabitEthernet0/0/1] quit
三、基于IP子网划分VLAN
1.创建VLAN
[Switch] vlan batch 100 200 300 //创建VLAN 100、VLAN 200和VLAN 300
2.配置接口
[Switch]interface gigabitethernet 0/0/1
[Switch-GigabitEthernet0/0/1] port link-type hybrid //基于IP子网划分VLAN只能应用在类型为hybrid
的接口,默认接口类型不是hybrid,需要手动配置
[Switch-GigabitEthernet0/0/1] port hybrid untagged vlan 100 200300 //对VLAN为100、200、300的报文,剥掉VLAN Tag
[Switch-GigabitEthernet0/0/1]ip-subnet-vlan enable //使能接囗的IP-VLAN功能
[Switch]interface gigabitethernet 0/0/2
[Switch-GigabitEthernet0/0/2] port link-type trunk//交换机之间使用trunk类型透传需要的VLAN
[Switch-GigabitEthernet0/0/2] port trunk allow-pass vlan 100 200 300
[Switch-GigabitEthernet0/0/2]quit
[Switch] vlan 100
[Switch-vlan100]ip-subnet-vlan 1 ip 192.168.1.2 24 priority2 //iP地址为192.168.1.2/24,优先级为2的报文,在VLAN 100域内转发
[Switch-vlan100] quit
[Switch] vlan 200
[Switch-vlan200]ip-subnet-vlan 1ip 192.168.2.2 24 priority3 //P地址为192.168.2.2/24,优先级为3的报文,在VLAN 200域内转发
[Switch-vlan200] quit
[Switch] vlan 300
[Switch-vlan300]ip-subnet-vlan 1 ip 192.168.3.2 24 priority4 //P地址为192.168.3.2/24,优先级为4的报文,在VLAN 300域内转发
[Switch-vlan300]quit
标签:vlan,模型,VLAN,GigabitEthernet0,划分,Switch,SwitchA,100 From: https://blog.csdn.net/limengshi138392/article/details/139101908