- create vlan
- assign port to vlan
- view vlan
- delete vlan
- Configure the gateway, subnet mask, and DHCP relay of the vlan
After using ssh to connect to the management network port of the switch:
1. Create vlan:
#进入配置状态
<S100> system-view #可以简写:sys
#创建vlan
[s100]vlan vlan-id
## 如果vlan-id不存在则创建该vlan
## 批量创建vlan:
[s100]vlan batch vlan-id1 to vlan-id2
[s100]quit ##或ctrl + z
[s100]save
[s100]quit
2. Assign the port to the vlan:
<S100> system-view
[s100]vlan vlan-id ##选择vlan 并进入配置状态
[s100]port Gx/y/z ##G表示光纤网口 x模块号,y层号,z端口号
[s100]quit ##或ctrl + z
[s100]save
[s100]quit
3. View vlan:
3.1 View how many vlans there are currently
<S100> system-view
[s100] display vlan ##可简写dis vlan
3.2 Check how many switch ports there are in a vlan:
[s100] display vlan vlan-id
## 或通过以下命令查配置文件
3.3 View switch port status:
## 查看所有端口
[s100] display interface brief
## 查看某端口信息
[s100]display interface G0/0/12
## 查看交换机端口mac
[s100]display mac-address
##查看arp表项:
[s100]display arp
4. Delete vlan
## 删除一个vlan
<S100> system-view
[s100] undo vlan vlan-id
## 删除多个vlan
[s100] undo vlan batch vlan-id1 to vlan-id2
*Problems encountered:
[s100]undo vlan 100
Error: The VLAN has a L3 interface. Please delete it first.
##原因为为要删除的vlan配置了ip地址导致,如vlan编号为100:
## 解决:
[s100]display current-configuration
##看到:
interface Vlanif100
ip address 10.101.1.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.10.203
##输入
[s100]interface Vlanif 100
[s100-Vlanif100]dis this
##看到以下信息:
#
interface Vlanif100
ip address 10.101.1.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.10.203
#
return
[s100]undo ip address
[s100]undo dhcp select
[s100]display this
#
interface Vlanif100
#
return
[s100]undo interface Vlanif 100
[s100]undo vlan 100
5. Configure gateway, subnet mask, dhcp relay for vlan
## 例:
## 创建vlan2
## 配置网关:192.168.10.1,子网掩码:255.255.255.0
## 配置中继的dhcp-server为:192.168.10.123
<S100> system-view
[s100] vlan 2
[s100-vlan2]interface vlanif 2
[s100-Vlanif2]ip addr 192.168.10.1 255.255.255.0
[s100-Vlanif2]dhcp select relay
[s100-Vlanif2]dhcp relay server-ip 192.168.10.123
[s100-Vlanif2]display this
#
interface Vlanif2
ip address 192.168.10.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.10.123
#
return