DHCP static IP assignation


Global configuration

Access configuration file

The main configuration file is /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf


Static IP @

This new configuration will ONLY accept known clients and give them a static IP @.

# Sample /etc/dhcpd.conf
# (add your comments here) 
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 172.16.50.255;
option routers 172.16.50.254;
# Google 8.8.8.8 8.8.4.4
# OpenDNS 208.67.222.222 208.67.220.220 (https://www.opendns.com/home-internet-security/opendns-ip-addresses/)
option domain-name-servers 172.16.50.2, 208.67.222.222, 8.8.8.8;
option domain-name "mydomain.lan";
option ntp-servers 172.16.50.254;

deny unknown-clients;

subnet 172.16.50.0 netmask 255.255.255.0 {
    host client1 {
        hardware ethernet AA:00:DF:E5:F7:D7;
        fixed-address 172.16.50.20;
    }
    host client2 {
        hardware ethernet 00:CD:BC:38:AC:45;
        fixed-address 172.16.50.21;
    }
}

Note:

The deny unknown-clients; command is why only known clients are accepted.


For each client you have to adjust:

  • MAC @
  • Set a specific static IP @

Add new host

Configuration file

Edit the configuration file:

vim /etc/dhcp/dhcpd.conf


Declare new host

Add new host at the end of the file :

host myNewHost {
  hardware ethernet 00:0e:af:31:d1:cc;
  fixed-address 172.16.50.60;
  option host-name "myNewHost";
}

==> Don't forget to the given IP @ must match the DNS server declaration !


Take on changes

Restart the DHCP server :

/etc/init.d/isc-dhcp-server restart