DHCP

281 阅读1分钟

DHCP

动态主机配置协议DHCP(Dynamic Host Configuration Protocol)是一种网络管理协议,用于集中对用户IP地址进行动态管理和配置

DHCP的好处

  • 减少管理员工作量
  • 避免输入错误的可能
  • 避免ip地址冲突
  • 提高ip地址的利用率
  • 方便客户端的配置

DHCP的分配方式

  • 自动分配:分配到一个IP地址后永久使用
  • 手动分配:有DHCP服务器管理员专门指定IP地址
  • 动态分配:使用完释放改IP,供其他客户机使用

DHCP工作原理

未命名文件.jpg

DHCP实验拓扑

image.png

配置主机

image.png

配置路由

image.png

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0/0]q
[R1]dhcp enable  //开启DHCP功能。
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select interface //使用接口的ip作为网关
[R1-GigabitEthernet0/0/0]dhcp server lease day 10 //设置要租用的全局ip地址池有效期
[R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8 //设置DNS地址

测试

image.png

实验2

image.png

[Huawei]sys r1
[r1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[r1]ip pool ky29 //配置IP地址
Info: It's successful to create an IP address pool.
[r1-ip-pool-ky29]getway-list 192.168.1.254
[r1-ip-pool-ky29]gateway-list 192.168.1.254   //配置出口网关地址。
[r1-ip-pool-ky29]network 192.168.1.0 mask 24
[r1-ip-pool-ky29]lease day 10 hour 0 minute 0
[r1-ip-pool-ky29]dns-list 8.8.8.8
[r1-ip-pool-ky29]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
Apr 24 2023 15:00:02-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r1-GigabitEthernet0/0/0]dhcp se	
[r1-GigabitEthernet0/0/0]dhcp select glo	
[r1-GigabitEthernet0/0/0]dhcp select global