1.搭建拓扑图并命名
[Huawei]sysname DHCP
[DHCP]
[Huawei]sysname R1
[R1]
2.2台路由器上开启dhcp服务并配置ip
[DHCP]interface g0/0/0
[DHCP-GigabitEthernet0/0/0]ip add
[DHCP-GigabitEthernet0/0/0]ip address 192.168.1.2 24
Feb 6 2018 15:29:35-08:00 DHCP %%01IFNET/4/LINK_STATE(l)[0]:The line protocol I
P on the interface GigabitEthernet0/0/0 has entered the UP state.
[DHCP-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[DHCP-GigabitEthernet0/0/0]q
[DHCP]dhcp
[DHCP]dhcp en
[DHCP]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[DHCP]
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip add
[R1-GigabitEthernet0/0/0]ip address 192.168.1.2 24
Feb 6 2018 15:30:02-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]q
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1-GigabitEthernet0/0/1]ip address 192.168.2.254 24
Feb 6 2018 15:34:28-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]
3.配置地址池、路由
[DHCP]ip pool p1
Info: It's successful to create an IP address pool.
配置网段
[DHCP-ip-pool-p1]network 192.168.2.254 mask 24
配置网关
[DHCP-ip-pool-p1]gateway-list 192.168.2.254
配置默认路由
[DHCP]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
4.配置dhcp中继
DHCP的g0/0/0应用基于全局dhcp
[DHCP-GigabitEthernet0/0/0]dhcp select global
R1上配置中继
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]dhcp select relay
[R1-GigabitEthernet0/0/1]dhcp relay server-ip 192.168.1.1
5.测试
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe79:652f
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.254
Physical address..................: 54-89-98-79-65-2F
DNS server........................:
6.配置dns、地址排除、租期并测试
[DHCP]ip pool p1
[DHCP-ip-pool-p1]dn
[DHCP-ip-pool-p1]dns-list 8.8.8.8
[DHCP-ip-pool-p1]excluded-ip-address 192.168.2.100 192.168.2.252
[DHCP-ip-pool-p1]
[DHCP-ip-pool-p1]lease day 3
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fea6:606e
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.99
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.254
Physical address..................: 54-89-98-A6-60-6E
DNS server........................: 8.8.8.8
7.查看dhcp地址池地址使用状况
display ip pool name p1 used
Pool-name : p1
Pool-No : 0
Lease : 3 Days 0 Hours 0 Minutes
Domain-name : -
DNS-server0 : 8.8.8.8
NBNS-server0 : -
Netbios-type : -
Position : Local Status : Unlocked
Gateway-0 : 192.168.2.254
Mask : 255.255.255.0
××× instance : --
Pool-name : p1
Pool-No : 0
Lease : 3 Days 0 Hours 0 Minutes
Domain-name : -
DNS-server0 : 8.8.8.8
NBNS-server0 : -
Netbios-type : -
Position : Local Status : Unlocked
Gateway-0 : 192.168.2.254
Mask : 255.255.255.0
××× instance : --
Start End Total Used Idle(Expired) Conflict Disable
192.168.2.1 192.168.2.254 253 2 98(0) 0 153
Network section :
Index IP MAC Lease Status
98 192.168.2.99 5489-98a6-606e 1362 Used
252 192.168.2.253 5489-9879-652f 1796 Used