Difference between revisions of "Dhcpd"

From ArchWiki
Jump to: navigation, search
(Configuration: explicit daemon operations examples are forbidden according to Help:Style#Daemon_operations)
Line 29: Line 29:
Start the {{ic|dhcpd4.service}} daemon:
Start the ''dhcpd'' daemon with {{ic|dhcpd4.service}} using [[Systemd#Using units|systemctl]]. Optionally, enable it to start automatically on boot.
{{bc| systemctl start dhcpd4.service}}
And optionally, enable for autostart on boot:
{{bc| systemctl enable dhcpd4.service|}}
Read [[Daemons]] for more information.
Read [[Daemons]] for more information.

Revision as of 17:15, 1 October 2013

dhcpd is the Internet Systems Consortium DHCP Server. It is useful for instance on a machine acting as a router on a LAN.


Install the dhcp package, available in the official repositories.


Assign an static IPv4 address to the interface you want to use (usually eth0). The first 3 bytes of this address cannot be exactly the same as those of another interface.

# ip link set up dev eth0
# ip addr add dev eth0 # arbitrary address

To have your static ip assigned at boot, see Network Configuration#Static IP address.

The default dhcpd.conf contains many uncommented examples, so relocate it

# mv /etc/dhcpd.conf /etc/dhcpd.conf.example

Edit the configuration file to contain:

# Using the google's dns in the example.
# Change it to if you have a dns server installed
option domain-name-servers;
option subnet-mask;
option routers;
subnet netmask {

Start the dhcpd daemon with dhcpd4.service using systemctl. Optionally, enable it to start automatically on boot.

Read Daemons for more information.

Now, any computer you connect over ethernet will be assigned an IPv4 address (from to in this example).

Tips and Tricks

Listening on only one interface

If your computer is already part of one or several networks, it could be a problem if your computer starts giving ip addresses to machines from the other networks.

In order to force the DHCP server to listen only on one of the network interfaces, you need to specify it in the dhcpd command line.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This appears not to work as of ArchLinux 2013-07-01 - see talk page for details. (Discuss in Talk:Dhcpd#)

This is done by editing the configuration file:

# Assuming the device of your lan is eth1
DHCP4_ARGS="-q eth1"

Another step is to tell the routing table on which interface to listen to for the broadcasts:

# ip route add dev eth1

Now, the clients on eth1 will be managed by your DHCP server without having any impact on any client / server on any other ntework interface.


You will see configuration files, etc. related to dhcpcd. That one is the DHCP client executable and has nothing to do with dhcpd.

See also