dhcp报文交互:
dhcp discovery(广播):
dhcp offer(单播):
dhcp request(广播):
dhcp ack(单播):
注意事项:
1、dhcp默认租期24h,当时间到12h发送renew报文给server请求续租,若server回复ack报文,此时PC的可用时间又更新为24h,若一直未收到server的回复,等到PC的可用时间还剩3h时触发rebinding报文给其他的server,若收到回复,则继续进入4种报文交重新互获取ip
2、dhcp discovery时可以指定要分配的ip,server查看ip池确认该ip是否被分配出去,若已被分配出去,回复dhcp offer分配其他可用ip,PC收到后使用dhcpoffer里分配的ip
3、dhcp server收到discovery报文,从ip池里选一个ip后会在server端ping 3次再回复offer,PC收到ip后也会ping 1次,若发现ip冲突会发decline报文向server请求更换ip
4、server收到discovery报文时会将PC的mac和要分配的ip的绑定关系存储,当PC下线会发送release报文,server将pc的绑定关系删除,并将ip归还ip池
5、PC接口在配置完ip address dhcp后会开始发送dhcp报文
当不同vlan共享一个dhcp server的时候可以使用dhcp中继,在svi10:ip helper-address 【server物理口地址】主要目的是将dhcp的广播报文转单播,且修改目的ip为dhcp server的地址
DHCP静态绑定配置
Server静态绑定配置:手动将ip和PC绑定
config#ip dhcp pool client
dhcp-config#client-identifier 01xx.xxxx.xxxx.xx //01代表以太网,后面是client的mac地址
dhcp-config#host 10.1.1.200 255.255.255.255 //一个池对应一个host
dhcp-config#default-router 10.1.1.1
dhcp-config#dns-server 8.8.8.8
dhcp-config#lease 0 10 //租期0天10小时
config# show ip dhcp binding //查看ip和pc绑定表
Client配置:即使client关机再次e0/0获取的ip仍是10.1.1.200
config#int e0/0
config-if#ip addresss dhcp client-id e0/0
config# show ip dhcp lease //查看pc获得的ip