1.基于端口划分VLAN(静态VLAN)
1.网络拓扑图及需求
2.配置命令
交换机1和交换机2的配置同理,下面展示交换机1的配置
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW1
[SW1]vlan batch 1001 1003
Info: This operation may take a few seconds. Please wait for a moment...done.
//int vlan number = int vlanif number
//[SW1]int vlan 1001;注意!这里不需要给vlan设置地址,如果设置地址,此vlan的地址就变成了网关地址,此时二层交换机变成三层交换机,不同vlan之间可以相互访问,不能满足需求
//[SW1-Vlanif1001]ip add 192.168.10.254 24
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 1001
[SW1-GigabitEthernet0/0/1]quit
//同理[SW1]int vlan 1003
//[SW1-Vlanif1003]ip add 192.168.30.254 24
[SW1]int GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port de
[SW1-GigabitEthernet0/0/2]port default vlan 1003
[SW1]int GigabitEthernet 0/0/24
[SW1-GigabitEthernet0/0/24]port link-type trunk
[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan all
[SW1]quit
3.Hybird端口类型
hybird:混合的
交换机的端口三种类型中的一种,可以用来起到access或trunk的作用,例如上述命令中
trunk接口改为hybird
[SW1]int GigabitEthernet 0/0/24
\\配置端口模式为hybird
[SW1-GigabitEthernet0/0/24]port link-type hybird
\\让链路中打上1001和1003标记的流量通过
[SW1-GigabitEthernet0/0/24]port hybird tagged vlan 1001 to 1003
2.基于MAC地址划分VLAN
将mac地址和vlan绑定,交换机在识别到pc的mac地址后,会自动将pc划分到对应vlan,前提是接口需要开启此功能
配置命令
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]vlan 1011
//将mac地址与vlan绑定
[Huawei-vlan1011]mac-vlan mac-address 5489-985A-71AE
[Huawei-vlan1011]quit
//接口开启基于mac地址划分vlan的功能
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]mac-vlan enable
标签:24,vlan,配置,int,VLAN,GigabitEthernet0,交换机,SW1,port
From: https://www.cnblogs.com/myLu01/p/18459433