基于接口配置DHCP功能
[R1]dhcp enable //开启DHCP功能 [R1-GigabitEthernet0/0/0]dhcp select interface //开启接口DHCP功能 [R1-GigabitEthernet0/0/0]dhcp server lease day 2【可选】 //设置租用有效期限为2天 [R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8 //为PC自动分配DNS服务器地址 [R1-GigabitEthernet0/0/1]dhcp server excluded-ip-address 192.168.2.250 192.168.2.253 //配置不参与自动分配的IP地址范围
基于全局配置DHCP
[R1]dhcp enable //开启DHCP功能 [R1]ip pool huawei1 //配置全局地址池 [R1-ip-pool-huawei1]network 192.168.1.0 //指定地址池范围 [R1-ip-pool-huawei1]lease day 2【可选】 //租期为2天,默认1天 [R1-ip-pool-huawei1]gateway-list 192.168.1.254 //出口网关地址 [R1-ip-pool-huawei1]excluded-ip-address 192.168.1.250 192.168.1.253 //不参与自动分配 [R1-ip-pool-huawei1]dns-list 8.8.8.8 //配置DNS服务器地址 [R1-GigabitEthernet0/0/0]dhcp select global //开启接口的DHCP功能
查看
dis ip pool //查看地址池地址分配情况
[R1]dhcp enable //开启DHCP功能 #面向PC的接口: [R1-Ethernet0/0/0]dhcp select relay [R1-Ethernet0/0/0]dhcp relay server-ip 100.1.1.1 //指定DHCP服务器IP地址 #面向PC的接口下调用全局定义的DHCP服务器组: [R1]dhcp server group dhcp-group [R1-dhcp-server-group-dhcp-group]dhcp-server 100.1.1.1 [R1-Ethernet0/0/0]dhcp select relay [R1-Ethernet0/0/0]dhcp relay server-select dhcp-group