命令说明
新交换机,开局配置DHCP服务,给局域网电脑客户端分配IP地址,并保留几个IP地址以供固定IP地址的设备使用。
配置案例
配置DHCP
代码语言:javascript复制####开启dhcp服务#####
<Sysname>system-view
[Sysname]dhcp enable
####配置dhcp地址池名称ap,这里ap是名称####
[Sysname]dhcp server ip-pool ap
####配置dhcp地址池网段####
[Sysname-dhcp-pool-ap]network 192.168.20.0 mask 255.255.255.0
####配置dhcp地址池网关地址####
[Sysname-dhcp-pool-ap]gateway-list 192.168.20.254
####配置dhcp地址池dns服务器####
[Sysname-dhcp-pool-ap]dns-list 114.114.114.114 223.5.5.5
####排除IP####
[Sysname]dhcp server forbidden-ip 192.168.20.250
应用配置
代码语言:javascript复制####建立VLAN,配置备注描述,相当于备注这个VLAN是干什么使用的,便于维护####
[Sysname]vlan 20
[Sysname-vlan20]description ap
[Sysname-vlan20]quit
####配置VLAN20 VLAN接口地址,也就是对应的DHCP地址池网关####
[Sysname]interface Vlan-interface 20
[Sysname-Vlan-interface20]ip address 192.168.20.254 24
[Sysname-Vlan-interface20]quit
####将交换机G1/0/1口划入VLAN20####
[Sysname]interface GigabitEthernet 1/0/1
[Sysname-GigabitEthernet1/0/1]port link-type access
[Sysname-GigabitEthernet1/0/1]port access vlan 20
[Sysname-GigabitEthernet1/0/1]quit
####电脑客户端接入交换机G1/0/1口即可获取到IP####
[Sysname]display dhcp server ip-in-use
IP address Client identifier/ Lease expiration Type
Hardware address
192.168.20.1 0035-3664-382e-3339- Jun 16 10:38:43 2022 Auto(C)
3533-2e30-3230-362d-
4745-302f-302f-31