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.

Dhruv Ranparia · February 5, 2022 at 16:11

Hello Tobias,

I have installed ISC-DHCP on Centos 7.

The issue I am facing with ISC-DHCP is it dose not store lease data for Reserved IP address.

Please find DHCP configuration as below.

log-facility local7;

allow leasequery;
update-static-leases true;
stash-agent-options true;
subnet netmask {

subnet netmask {
# CMTS-1
option routers;
option broadcast-address;
default-lease-time 60; max-lease-time 60;
host pc1 {
hardware ethernet 00:e4:00:f3:dd:0e;
#hardware ethernet c4:04:15:7f:fc:dd;
stash-agent-options true;


    Tobias Hofmann · February 7, 2022 at 08:59

    Hi Dhruv,

    what do you want to achieve? The IP for the host is fix, why let the DHCP server manage the lease data? The usage of the flag update-static-lease is not recommended:
    Are you sure that you need this configuration?

Dhruv · February 9, 2022 at 21:45

Hello Tobias,

Thank you for the respond and removed the update-static-lease

in the Network my CPE device is connected via Cable Modem(CM).

in order to authenticate the CPE I require to have the CM mac which we are getting in option 82.

In case of Host reservation where we require to bind a CPE to a specific IP(which is not technically configured in the CPE)

hence from next time onwards DHPC shall return only the specific IP to CPE. in this case I am not getting any lease entry for the said IP thus no option 82 info so can’t authenticate the client.

Dhruv Ranparia · February 10, 2022 at 13:09

Hello Tobias,

Thank you for the response.

I will try to explain the complete requirement in brief here.

I want to bind some clients to a fixed IP, hence it will make sure that this clients will only Get fixed IP from DHCP server every time. (This IP is not configured statically in the their devices.)

in order to authenticate such devices we require MAC address and along with that some option 82 details. and we can get option 82 details in DHCP server only if there is a lease entry available in lease file.

hence require to have lease data available for reserved IP address if it’s allocated to the client.

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.