CCNA-DHCP

DHCP Service 
Dynamic Host Configuration Protocol  动态主机配置协议服务

0.前身是Boot Protocol,早期的无盘工作站,使用的就是Boot Protocol,能够为我们提供的信息:网关,IP地址,子网掩码,随着网络应用、服务的不断扩展,动态信息的数量也在不断增加,域名、启动文件,网络引导等。所以就进化为了DHCP协议。

1.DHCP is built on a client-servet model, as follows:,使用的是CS的架构,目前支持网络的设备都会内置DHCP 客户端,会自动在网络中寻找服务器
①The DHCP server hosts allocte network addresses and deliver configuration parameters.
②The term "client" refers to a host requesting initiazlization parameters from a DHCP server.

2.DHCP 使用UDP 协议,端口号为67、68,DHCP 是内网服务
客户端向68端口(Bootstrap Protocol Client)请求配置,服务器向67端口(Bootstrap Protocol Server)广播回应请求。

3.DHCP supports these three mechanisms for IP address allocation:
①Automatic allocation; DHCP assigns a permanent IP address to a client.
②Dynamic allocation;DHCP assigns an IP address to a client for a limited period of time.
动态分配:通常会给DHCP 划分一个地址池,就是address pool,然后动态的向外分配地址
③Manual allocation;A client IP address is assigned by the network administrator, and DHCP is used simply to convey the assigned address to the client.
手工分配:针对某个MAC地址请求,分配固定的IP 地址

 

DHCP 工作过程

网络中有一台DHCP 服务器,当连接一台DHCP 客户端的时候,并且配置的是通过DHCP 获取IP地址的话,则会进行以下:
1.DHCP客户端此时的源地址为“0.0.0.0”将通过broadcast发送一个discover message 给端口68,因为还不知道谁是DHCP服务器,所以用广播发送。
2.DHCP 服务器收到客户端的发现消息后将通过UDP,使用67端口发给这台DHCP客户端一个单播的offer message,这个offer message 里包含客户端的MAC地址,准备给客户端分配的IP(从address pool里取出一个未分配的ip) 信息,子网掩码,租约期等。
3.DHCP 客户端收到第一个offter message后,看看符不符合自己的要求,如果复合就再通过broadcast 发送一个request message 给端口68,请求的信息包含offer message信息内容。因为不知道网络中有多少台DHCP 服务器,所以用广播,比如有A、B、C三台DHCP 服务器,几乎同时给这台DHCP 客户端发送了offer message,但是B的消息先到达,则为了不让A、C等待,则会发送广播,这是A和C 就知道客户端已经接受了B的offer message,则A、C刚才发送的offer message里面的ip可以继续拿给别的DHCP 客户端使用。
4.DHCP 服务器收到request message ,会发送一个acknowledge message作为确认,并把自己address pool里的这个IP 标记为已经分配。

 

DHCP Configuration on IOS
1.启动dhcp 服务

Router(config) #service dhcp

2.创建一个地址池

Router(config) #ip dhcp pool iteredu

3.配置dhcp 服务器的管理网段,为哪个网络提供服务

Router(dhcp-config) #network 192.168.1.0 255.255.255.0

4.设置默认网关

Router(dhcp-config) #default-router 192.168.1.254

5.指定网络的域名

Router(dhcp-config) #domain-name iteredu.com

6.配置DNS 服务器

Router(dhcp-config) #dns-server 61.134.1.4 61.134.1.5

7.设置租约期时间,单位默认为天,到期后需要续约,一般都可以续约成功,如果地址池无地址了,则会导致续约失败

Router(dhcp-config) #lease 7

8.不使用指定的IP,排除地址

Router(config) #ip dhcp excluded-address 192.168.1.1 192.168.1.10

4,5,6,7为可选项,可以不配置,但是一般都要配置。

 

实验部分
1.DHCP 只能配置在以太网上
2.DHCP 服务器要手动配置IP 地址,它无法给自己配置IP 地址
3.DHCP 服务器的IP要在它所管理的网段,如,DHCP服务器的IP是192.168.1.254,则这个DHCP 服务器无法管理处192.168.1.0网段外的其他网段。
4.查看debug信息及 关闭debug 信息

Router #debug ip server packet
Router #u all

5.客户端使用dhcp 获取ip

Router(config-if) ip address dhcp

6.查看DHCP 服务器的状态,使用了多少内存,地址池用了多少个地址,收到了多少message,发送了多少message

Rourter #show ip dhcp server statistics

7.查看当前已经绑定/分配的IP 地址

Router #show ip dhcp binding

8.记录所有的地址冲突

Router(config) #show ip dhcp conflict 

冲突检测:思科的地址在分配地址之前,会先ping 这个地址,默认ping 两次。如果ping不通,才会分配。如果一个网络中既有微软的DHCP 服务器又有思科的DHCP服务器,则客户端一定先获得的是微软的offer,因为微软的DHCP 服务器没有冲突检测

posted @ 2020-05-14 15:42  Gnbp  阅读(289)  评论(0编辑  收藏  举报