Network
The dhcp-lease-list command
Lists the active DHCP leases of the server: MAC, IP and hostname.
Most useful options
--helpShows the command line help.--parsableOutput meant for programs, with full dates.--lastShows the last lease of each MAC, even if it has already expired.--allShows all entries, including the several one MAC address may have.Copy-ready examples
$ dhcp-lease-listlists the active leases.$ dhcp-lease-list --parsablethe same list with full dates, ready to process in a script.$ dhcp-lease-list --lastone line per MAC with its last lease, even if it is no longer in force.$ dhcp-lease-list --all | grep 192.168.1.all entries from the 192.168.1.x network, old ones included.You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- By default you only see the leases still in force. --last shows the last one of each MAC even if it has expired.
- The dhcp-lease-list manual cites /var/lib/dhcp3/dhcpd.leases, an old path. The Debian dhcpd manual uses /var/lib/dhcp/dhcpd.leases.
- To see the file as it is, without filtering, use cat /var/lib/dhcp/dhcpd.leases.
FAQ
What does dhcp-lease-list show?
The active DHCP leases of the server, read from the lease file. It filters out expired entries.
Where does it read the leases from?
From the dhcpd lease file. The dhcp-lease-list manual cites /var/lib/dhcp3/dhcpd.leases, an old path; the dhcpd manual uses /var/lib/dhcp/dhcpd.leases.
What is the difference between --all and --last?
--all shows every entry, several per MAC if there are any. --last shows only the last one of each MAC, even if it has expired.
When should I use --parsable?
When another program will process the output: the dates come out in full and are easier to handle.
More Network commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course