拓扑图
配置步骤
1、创建vlan,配置端口所属VLAN和对应VLAN接口的IP地址,IP地址即是对应VLAN的网关地址
vlan 2 to 4
#
interface GigabitEthernet1/0/1
port link-mode bridge
port access vlan 2
combo enable fiber
#
interface GigabitEthernet1/0/2
port link-mode bridge
port access vlan 3
combo enable fiber
#
interface GigabitEthernet1/0/3
port link-mode bridge
port access vlan 4
combo enable fiber
#
interface Vlan-interface2
ip address 192.168.2.1 255.255.255.0
#
interface Vlan-interface3
ip address 192.168.3.1 255.255.255.0
#
interface Vlan-interface4
ip address 192.168.4.1 255.255.255.0
2、配置DHCP地址池2 3 4,用来为192.168.2.0/24、192.168.3.0/24、192.168.4.0/24网段内的客户端分配IP地址
DNS地址114.114.114.114
dhcp server ip-pool vlan2
gateway-list 192.168.2.1
network 192.168.2.0 mask 255.255.255.0
dns-list 114.114.114.114
#
dhcp server ip-pool vlan3
gateway-list 192.168.3.1
network 192.168.3.0 mask 255.255.255.0
dns-list 114.114.114.114
#
dhcp server ip-pool vlan4
gateway-list 192.168.4.1
network 192.168.4.0 mask 255.255.255.0
dns-list 114.114.114.114
#
保留地址不下发
dhcp server forbidden-ip 192.168.2.200 192.168.2.254
配置完成后可通过在交换机上使用display dhcp server ip-in-use命令可以查看DHCP服务器为客户端分配的IP地址。
[H3C]display dhcp server ip-in-use
IP address Client identifier/ Lease expiration Type
Hardware address
192.168.2.2 0061-6330-322e-6437- Mar 31 18:15:13 2023 Auto(C)
6165-2e30-3230-362d-
4745-302f-302f-31
192.168.3.2 0061-6330-322e-6464- Mar 31 18:21:21 2023 Auto(C)
3339-2e30-3330-362d-
4745-302f-302f-31
192.168.4.2 0061-6330-322e-6531- Mar 31 18:18:30 2023 Auto(C)
6537-2e30-3430-362d-
4745-302f-302f-31
配置完成后,PC_2/ PC_3/ PC_4客户端可以查看IP地址
选中PC机,右键点击配置,启用接口管理,IPV4配置选择DHCP,点击启用,然后刷新,显示IPV4地址状态,其它的PC操作一致。