What are the steps for installing a DHCP server on Linux?
The steps for installing a DHCP server are as follows:
- Open the terminal and log in to the system using root privileges.
- Install DHCP server software using one of the following commands:
- Debian/Ubuntu system: use ‘sudo apt-get install isc-dhcp-server’ command.
- Install the DHCP package on CentOS/RHEL systems using the command: sudo yum install dhcp
- After the installation is complete, open the DHCP server’s configuration file using a text editor. The configuration file is located at /etc/dhcp/dhcpd.conf on Debian/Ubuntu systems, and at /etc/dhcp/dhcpd.conf on CentOS/RHEL systems.
- Set up the parameters for the DHCP server, including the IP address range, subnet mask, gateway, DNS server, and more. Here is an example configuration:
- Create a subnet with the IP address range of 192.168.1.100 to 192.168.1.200, a router at 192.168.1.1, and domain name servers at 8.8.8.8 and 8.8.4.4 using a netmask of 255.255.255.0.
- The setup will assign IP addresses ranging from 192.168.1.100 to 192.168.1.200 to clients, and configure the gateway and DNS server as 192.168.1.1 and 8.8.8.8/8.8.4.4.
- Save and close the configuration file.
- Start the DHCP server. On Debian/Ubuntu systems, use the following command to start the service: sudo systemctl start isc-dhcp-server; on CentOS/RHEL systems, use the following command to start the service: sudo systemctl start dhcpd.
- Option: To enable the DHCP server to start up automatically, use the following commands based on your operating system:
For Debian/Ubuntu: sudo systemctl enable isc-dhcp-server
For CentOS/RHEL: sudo systemctl enable dhcpd - Check if the DHCP server is functioning properly by examining the DHCP server logs in the /var/log/syslog file.
After completing the above steps, your Linux system has been successfully installed and configured as a DHCP server.