How to find out DCHP lease time on macOS

When my macbook connects to WiFi network it gets its ip address via DCHP. It is fairly easy to find out the basic information about the connection, but today I had to find out DHCP lease time (the time when the network settings expire and the computer must update its settings).

The basic info

Go to System Preferences -> Network -> Advanced and there you can see IPv4 / Mask / Router (gateway) info.

Or, you can also get that info by clicking on the WiFi icon (but you must press "alt" key during the click):

DHCP info

But it is a bit harder to get details about DCHP on the mac.

To get DCHP client info you need to open Terminal and enter two commands:

Here is an example of what you'll get:

$ sudo su
Password:
$ cat /var/db/dhcpclient/leases/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IPAddress</key>
        <string>192.168.31.177</string>
        <key>LeaseLength</key>
        <integer>43200</integer>
        <key>LeaseStartDate</key>
        <date>2020-01-12T21:07:10Z</date>
        <key>PacketData</key>
        <data>
        ywX5cQLTLTXjLLLkhzi5nyn2AP8s1xPFQXrsf56sc8FQgZKlzYAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjf7M0Z2LGq4avD9zYXpXaCGYKJ4Na8
        tt3dK5mK9ooPmX4syNZhy3b3P4YrLdpNqrJ4lHXD1Z5NnLTnXkUPcl55oIt9IVlOeAm4
        6smZagRw1i3WYjfajkXuYQ1XU0dozqDIqHepcyn00lP2TmdS==
        </data>
        <key>RouterHardwareAddress</key>
        <data>
        yYEIzZVZ
        </data>
        <key>RouterIPAddress</key>
        <string>192.168.31.1</string>
        <key>SSID</key>
        <string>m45</string>
</dict>
</plist>

The DHCP lease time is in this block:

<key>LeaseLength</key>
<integer>43200</integer>

From this text you can find that the lease time is 43200 seconds. (By the way, this is 12 hours).

Ivan Bessarabov
ivan@bessarabov.ru

13 january 2020