dnsmasq

dnsmasq is free software providing services such as Domain Name System (DNS) caching, Dynamic Host Configuration Protocol (DHCP) server, and many more.

Setup a Dynamic Host Configuration Protocol (DHCP) server

The following are the steps to setup a DHCP server with dnsmasq:

  1. Setup a static IP address on the machine acting as the DHCP server

  2. Configure the DHCP server settings from the /etc/dnsmasq.conf file

a) Open up /etc/dnsmasq.conf on a text editor

$ sudo vim /etc/dnsmasq.conf
# OR
$ sudo nano /etc/dnsmasq.conf

b) Add the following lines at the bottom

  • Replace iface, dhcp_start_range, dhcp_end_range and lease_time with the appropriate values

  • The iface value used should match the one that have been configured from part 1 (static IP address allocation)

...
interface=<iface>
dhcp-range=<dhcp_start_range>,<dhcp_end_range>,<lease_time>

c) Save the file

  1. Restart the dnsmasq daemon

Example

Setup a machine as a DHCP server on the interface eth0, with the static IP address of 88.88.88.88, and a DHCP pool range of 88.88.88.0 to 88.88.88.87. The lease time will be set to 24 hours.

Connecting to the DHCP server

Simply connect a physical ethernet adapter from the client interface to the interface on the DHCP server machine that was configured.

Subsequently, verify if the client interface have been successfully configured with an IP address from the DHCP range. Perform the following on the client machine — a few troubleshooting steps will be outlined too.

Linux

Look for the paragraph where the client interface is configured (eg. eth0)

The IP address displayed after inet should be within the DHCP pool range defined in the DHCP server configurations, and the state should be UP.

Troubleshooting on Linux

The following actions can be taken to resolve any issues:

  1. Reset the lease and request for a new IP address via a DHCP query:

  1. Reset the client network interface

  1. Restart the networking.service daemon

Windows

Look for the paragraph where the client interface is configured (eg. Ethernet 8)

The IPV4 address value displayed should be within the range of the DHCP pool range defined in the DHCP server configuration. The default gateway, DHCP server and DNS server entries should be the IP address of the DHCP server.

Troubleshooting on Windows

Reset the lease and request for a new IP address via a DHCP query:

Last updated