This article describes the functionality of the dhcp-attribute grace-period role and function and provides configuration examples.
dhcp-attribute grace-period
What is the role of the dhcp-attribute grace-period function?
The grace period is the amount of time that a client continues to retain its address lease after the lease expires. The address in use cannot be assigned to any other client during the grace period. When the grace period expires, the address is released back to the address pool. If grace period is not expired and the DHCP client with the same MAC address starts the DORA handshake, then the same address will be leased to that client. The DHCP Local Server functionality of Junos OS allows the grace-period to be defined in seconds. Lease grace periods will be supported per address pool and all address leased from that pool.
Keep in mind that the lease must expire. The lease will expire when the local server does not receive a DHCP renew or rebind for this client for whatever reason (modem shut off, link issues etc..). If the DHCP client sends a release, then the binding and access-internal route are removed immediately (grace-period does not take effect). The grace-period can be defined on the fly. Meaning you can have addresses leased (bound state) and set the grace-period and the changes will take effect immediately.
Example configuration:
lab@H1# run show configuration access address-assignment pool DHCP { family inet { network 192.168.1.0/24; range test { low 192.168.1.2; high 192.168.1.254; } dhcp-attributes { maximum-lease-time 300; grace-period 300; } }
When the grace-period is in effect (lack of renew or rebind) and the lease expires the binding will change from bound to grace-period state. During this time this IP address will not be released back into the address pool and the access-internal route is present in the routing table. The DHCP binding lease timer changes to the timer defined for the grace-period. In this example the grace-period is set for 300 seconds. When the lease expires, the lease timer resets and starts at 300. Once the grace-period expires then the binding and access-internal route are removed and the IP address is reallocated to the pool.
Example: DHCP client in a bound state:
lab@H1# run show dhcp server binding detail Client IP Address: 192.168.1.97 Hardware Address: 00:10:94:00:00:01 State: BOUND(LOCAL_SERVER_STATE_BOUND) Lease Expires: 2013-11-13 20:02:14 UTC Lease Expires in: 296 seconds Lease Start: 2013-11-13 19:57:14 UTC Last Packet Received: 2013-11-13 19:57:14 UTC Incoming Client Interface: ge-1/0/6.0 Server Identifier: 192.168.1.1 Session Id: 2936207 Client Pool Name: DHCP lab@H1# run show route 192.168.1.97 inet.0: 4014 destinations, 4015 routes (4014 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.1.97/32 *[Access-internal/12] 00:01:0 > to 192.168.1.1 via ge-1/0/6.0
Now the lease expires and the binding state changes along with the lease time (grace-period interval).
Lease expires: lab@H1# run show dhcp server binding detail Client IP Address: 192.168.1.97 Hardware Address: 00:10:94:00:00:01 State: BOUND(LOCAL_SERVER_STATE_WAIT_GRACE_PERIOD) Lease Expires: 2013-11-13 20:07:14 UTC Lease Expires in: 297 seconds Lease Start: 2013-11-13 19:57:14 UTC Last Packet Received: 2013-11-13 19:57:14 UTC Incoming Client Interface: ge-1/0/6.0 Server Identifier: 192.168.1.1 Session Id: 2936207 Client Pool Name: DHCP {MASTER}[edit] lab@H1# run show route 192.168.1.97 inet.0: 4014 destinations, 4015 routes (4014 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.1.97/32 *[Access-internal/12] 00:05:21 > to 192.168.1.1 via ge-1/0/6.0