华为dhcp服务配置在三层交换机上
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys sw1
[sw1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[sw1]vlan batch 10 20
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 10
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 20
[sw1-GigabitEthernet0/0/2]q
[sw1]int vlanif 10
[sw1-Vlanif10]ip add 192.168.10.1 24
[sw1-Vlanif10]q
[sw1]int vlanif 20
[sw1-Vlanif20]ip add 192.168.20.1 24
[sw1-Vlanif20]q
[sw1]ip pool net10 配置为vlan10分配IP地址的地址池,名为net10
[sw1-ip-pool-net10]network 192.168.10.0 mask 24
[sw1-ip-pool-net10]gateway-list 192.168.10.1
[sw1-ip-pool-net10]lease day 0 hour 2
[sw1-ip-pool-net10]dns-list 200.200.200.200
[sw1-ip-pool-net10]static-bind ip-address 192.168.10.254 mac-address 40B0-769F-9452 为固定mac分配固定ip(可省)
[sw1-ip-pool-net10]excluded-ip-address 192.168.10.250 192.168.10.253 不分配的ip地址(段),可省
[sw1-ip-pool-net10]q
[sw1]int vlanif 10
[sw1-Vlanif10]dhcp select global 启用全局的地址池给DHCP客户端,网关地址设置在哪个接口,就在哪个接口启用全局地址池;这里特别注意dhcp服务配置在三层交换机和路由器上命令不同;
此时在pc1或pc2上通过命令:ipconfig即可查看到分配的ip地址
同样在vlanif 20上配置net20地址池
[sw1-Vlanif10]q
[sw1]ip pool net20
[sw1-ip-pool-net20]network 192.168.20.0 mask 24
[sw1-ip-pool-net20]gateway-list 192.168.20.1
[sw1-ip-pool-net20]lease day 0 hour 2
[sw1-ip-pool-net20]dns-list 200.200.200.200
[sw1-ip-pool-net20]int vlanif 20
[sw1-Vlanif20]dhcp select global
此时在pc3或pc4通过命令:ipconfig即可查看到分配的ip地址;同时pc1也能ping通pc3