配置DHCP服务器

配置DHCP服务器

1.实验1:DHCP池

image-20250612151014302

<Huawei>SYS
[Huawei]sysname AR1
[AR1]interface GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 192.168.0.1 24
[AR1-GigabitEthernet0/0/0]quit
    
[AR1]interface GigabitEthernet 0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.1.1 24
[AR1-GigabitEthernet0/0/1]quit

[AR1]interface GigabitEthernet 2/0/0
[AR1-GigabitEthernet2/0/0]ip address 172.16.0.1 24

[AR1]dhcp enable                                --全局启用DHCP服务
[AR1]ip pool office202                              --为VLAN 1创建地址池
[AR1-ip-pool-office202]network 192.168.0.1 mask 24  --指定地址池所在的网段
[AR1-ip-pool-office202]gateway-list 192.168.0.1     --指定该网段的网关
[AR1-ip-pool-office202]dns-list 8.8.8.8             --指定DNS服务器
[AR1-ip-pool-office202]dns-list 114.114.114.114     --指定第二个DNS服务器
[AR1-ip-pool-office202]lease day 0 hour 2 minute 0  --地址租约,允许客户端使用多长时间
[AR1-ip-pool-office202]excluded-ip-address 192.168.0.10 192.168.0.20    --指定排除的地址范围
Error:The gateway cannot be excluded.                         --不能包括网关
image-20250612121956738

image-20250612121944999

image-20250612122256455

image-20250612122312598

image-20250612122545655

[AR1]display dhcp server statistics 
image-20250612122646333

2.实验2:DHCP查询,续期,释放

image-20250612140143924

WIINDOWS2016

image-20250612140222455

不要勾上

image-20250612140304653

image-20250612140335663

查询

image-20250612140443246

续期

image-20250612140649678

释放

image-20250612141039185

3.实验3:DHCP接口取地址

[AR1]interface GigabitEthernet 0/0/1
[AR1-GigabitEthernet0/0/1]dhcp select interface 
[AR1-GigabitEthernet0/0/1]dhcp server dns-list 8.8.8.8    
[AR1-GigabitEthernet0/0/1]dhcp server excluded-ip-address 192.168.1.10 192.168.1
.20
[AR1-GigabitEthernet0/0/1]dhcp server lease day 0 hour 2 minute 0
image-20250612142759731

4.实验4:DHCP中继

AR1

[AR1]ip route-static 192.168.2.0 24 172.16.0.2

[AR1]dhcp enable
[AR1]ip pool office206
[AR1-ip-pool-office206]network 192.168.2.0 mask 24
[AR1-ip-pool-office206]gateway-list 192.168.2.1
[AR1-ip-pool-office206]dns-list 8.8.8.8
[AR1-ip-pool-office206]excluded-ip-address 192.168.2.10 192.168.2.15    
[AR1-ip-pool-office206]lease day 0 hour 2 minute 0

[AR1-GigabitEthernet2/0/0]dhcp select global 

AR2

<Huawei>sys
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 172.16.0.2 24
[Huawei-GigabitEthernet0/0/0]quit

[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.2.1 24
[Huawei-GigabitEthernet0/0/1]quit

[Huawei]ip route-static 192.168.0.0 24 172.16.0.1
[Huawei]ip route-static 192.168.1.0 24 172.16.0.1

[Huawei]dhcp enable 
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]dhcp select relay
[Huawei-GigabitEthernet0/0/1]dhcp relay server-ip 172.16.0.1

测试

image-20250612145931569

image-20250612145916339

5.补充:

查看租期情况

[AR1]display ip pool name office202 
image-20250612142931152

查看已用的IP地址

[AR1]display ip pool name office202 used 
image-20250612143129660

6.思考题

image-20250612151152102

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注