Dynamic Host Configuration Protocol (DHCP) is a crucial service for any network, as it automatically assigns IP addresses and other network configuration information to devices connected to the network. In this guide, we will walk you through the process of how to set up DHCP server on Arch Linux. Let’s get started!
Prerequisites
Before we dive into setting up the DHCP server, ensure that you have the following:
- An Arch Linux system with a static IP address
- Root or sudo privileges
How to Set up DHCP Server on Arch Linux
Update Your System
First, ensure your Arch Linux system is up to date by running the following command:
sudo pacman -Syu
Install the DHCP Package on Arch Linux
Install the ISC DHCP server package by executing:
sudo pacman -S dhcp
Configure the DHCP Server on Arch Linux
After installing the DHCP server package, you need to configure it. Open the /etc/dhcpd.conf
configuration file with your favorite text editor:
sudo vim /etc/dhcpd.conf
Add the following configuration to the file, making sure to replace {subnet}
, {netmask}
, {range_start}
, {range_end}
, {broadcast}
, {routers}
, and {dns_servers}
with the appropriate values for your network:
subnet {subnet} netmask {netmask} {
range {range_start} {range_end};
option broadcast-address {broadcast};
option routers {routers};
option domain-name-servers {dns_servers};
}
For example:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
Save and close the file.
Configure the DHCP Server Interface on Linux
Next, you need to specify the network interface that the DHCP server will listen on. Open the /etc/conf.d/dhcpd
file:
sudo vim /etc/conf.d/dhcpd
Add the following line, replacing {interface}
with the appropriate network interface name:
DHCPD_ARGS="{interface}"
For example:
DHCPD_ARGS="enp0s3"
Save and close the file.
Enable and Start the DHCP Server on Linux
Enable the DHCP server to start automatically at boot:
sudo systemctl enable dhcpd.service
Start the DHCP server:
sudo systemctl start dhcpd.service
Verify that the DHCP server is running:
sudo systemctl status dhcpd.service
Configure the Firewall
If you have a firewall running on your Arch Linux system, you need to allow DHCP traffic. Check out our guide on how to configure the firewall on Arch Linux for detailed instructions.
Conclusion
Congratulations! You have successfully set up a DHCP server on Arch Linux. This will allow you to manage IP addresses on your network automatically, making it easier to add new devices and maintain the network.
If you’re interested in learning more about managing an Arch Linux server, check out these articles: