How to set static or fixed IP address using DHCP

DHCP, stands for Dynamic Host Configuration Protocol, is an autoconfiguration protocol used in IP network. Computers/Notebooks that connect to IP network must be configured first to be able to access internet/intranet. The configuration of IP network can be static or dynamic. The DHCP allows computers to be configured dynamically/automatically so the network administrators do not need to manually configure computers statically one by one.

However, by using DHCP you can set the computers to be static or fixed IP address. You might want to do IP-based policy for some of workstations inside you Local Area Network (LAN) and it makes easier to do IP-base policy this way. This tutorial shows you how to set static or fixed ip address using DHCP.

Basically it is already in the dhcpd.conf(5) manual page. In your Linux/Unix system, you can read the manual by executing ‘man dhcpd.conf’ assuming you already installed the TCP/IP network related packages of your system. One thing, you need to have the MAC / physical address of each network interface card (NIC) inside the LAN. We will set static or fixed address based-on the MAC address.

Let’s start to the configuration

Open / edit the dhcpd.conf file using your familiar editor. In your existing dhcpd.conf configuration file, append the lines below:

host client1 {
	hardware ethernet 00:1A:80:D9:33:6F;
	fixed-address 172.16.17.249;
        option subnet-mask 255.255.255.0;
	option routers 172.16.17.254;
        option domain-name-servers 208.67.222.222, 208.67.220.220;
}

You can also point the router to others gateway (if you have more than one router)

host client2 {
	hardware ethernet 00:1A:80:D9:3A:6F;
	fixed-address 172.16.17.250;
        option subnet-mask 255.255.255.0;
	option routers 172.16.17.1;
        option domain-name-servers 208.67.222.222, 208.67.220.220;
}

That’s it. Then restart the DHCPD service. Once client1 or client2 connect to the network, they will get IP address 172.16.17.249 and 172.16.17.250 respectively.