Setup a DHCP server - Linux
The Dynamic Host Configuration Protocol (DHCP) is a standardized network protocol used on Internet Protocol (IP) networks for dynamically distributing network configuration parameters, such as IP addresses for interfaces and services. With DHCP, computers request IP addresses and networking parameters automatically from a DHCP server, reducing the need for a network administrator or a user to configure these settings manually.
ISC DHCP
All IP devices need addresses, and ISC DHCP is the easiest and most efficient way to provide them. ISC DHCP is open source software that implements the Dynamic Host Configuration Protocol for connection to an IP network. It is production-grade software that offers a complete solution for implementing DHCP servers, relay agents, and clients from small local networks to large enterprises. ISC DHCP solution supports both IPv4 and IPv6, and is suitable for use in high-volume and high-reliability applications.
Lets start installing ISC DHCP on our linux machine:
$ sudo apt-get install isc-dhcp-server -y
$ cd /etc/dhcp
$ sudo nano dhcpd.conf
Copy the code below and make changes to your needs and network:
1
2
3
4
5
6
7
8
9
10
# Change this line
option domain-name "linux.dr.pt";
option domain-name-servers 10.0.0.101;
# Add this to the end of file
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.150 10.0.0.160;
option routers 10.0.0.254;
option broadcast-address 10.0.0.255;
}
Then just start ISC DHCP with this command: $ sudo service isc-dhcp-server start
. It could take a while until the hosts do a dhcp renew but in the end should look something like the image below:
Figure 1: New DHCP information.