Assign a static IP to DHCP client

Published by Tobias Hofmann on

2 min read

After setting up a DHCP server on a Raspberry Pi running Linux I get working leases for my clients. However, these are not static. It can happen that my smartphone gets a new IP address the next it connects: instead of For some clients I want to make sure they always use the same IP. This can achieved with ISC DHCP Server by registering a static lease for a specific MAC.


I’ll use my soundbar for the rest of this blog as an example. The MAC of the network card is bc:30:d9:2a:c9:50. I want to always assign the IP to the soundbar.

Find out client data

To find out the client data like MAC and current lease, check the DHCP server log. Or take a look at the back of the device or its settings to find out the MAC. For the DHCP server log on assigned leases:

sudo systemctl status isc-dhcp-server.service

The last line shows that the DHCP server assigned an IP to a client and shows also the MAC address.

DHCPACK on to bc:30:d9:2a:c9:50

Let’s make sure the MAC bc:30:d9:2a:c9:50 always gets the IP


sudo vim /etc/dhcp/dhcpd.conf

This is the DHCP server configuration file. I already configured it for a subnet 192.168.0.x where the server is assigning leases for the IP addresses in the range of to

Inside the subnet configuration, I have to add a configuration for the soundbar for IP

host soundbar {
  hardware ethernet bc:30:d9:2a:c9:50;

The complete dhcpd.conf file will look like this:

subnet netmask {
  option routers;
  option domain-name "";
  option domain-name-servers,;
  host soundbar {
    hardware ethernet bc:30:d9:2a:c9:50;

Activate configuration

To activate the new configuration, make either DHCPD load the new configuration from file, or restart the service.

sudo systemctl restart isc-dhcp-server.service

Check the status of the service.

sudo systemctl status isc-dhcp-server.service


The assigned leases can be found in the dhcpd.leases file. All leases assigned are listed here, including the mac address, IP address, start and end time of the lease. If all works out as planned, the soundbar will be in there with the static IP.

sudo more /var/lib/dhcp/dhcpd.leases


Let the world know

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.


Dillon · July 17, 2020 at 23:24

With a few exceptions all of my Wi-Fi devices use DHCP addresses, but the printers, AND and Plexserver all need static so this is useful to me. I’ve been able to configure them manually, but not every device is that friendly.

Johnny · August 21, 2020 at 19:50

Very useful. I configure them also in Bind9 on the Pi along with Mac assignment for the IP addresses and domain that I set, so that I can just say “ping laptop” and it pings the PC laptop or “ping mbp” and it pings the MacBook. Makes doing VNC a bit easier, or setting up dev and production web servers, database servers, and so on.

Anthon · October 7, 2021 at 07:59

The entry in the leases file, in your Result section, is IMO there because of the earlier dynamic assignment of that number.
It might be that isc-dhcpd is smart enough to not assign to another machine, essentially excluding the fixed address from your dynamic range. IMO it is better to have fixed addresses outside of that dynamic range, that way you can have a backup DHCP server with the shared fixed addresses, but non-overlapping dynamic ranges.

    Tobias Hofmann · October 7, 2021 at 16:56

    DHCPD assigned .152 to that host because of the configuration. The IP is in the range of the dynamic IPs, it’s only that only the soundbar host is getting that IP. DHCPD won’t assign .152 to another host, as it is reserved. If the host requesting an IP does not match the MAC adress, it won’t get the IP assigned.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.