Difference between revisions of "Dhcpcd"

From ArchWiki
Jump to: navigation, search
(I guess this will be still necessary...)
m (Running: oops, this should be general...)
Line 25: Line 25:
 
To start ''dhcpcd'' manually, simply run the following command:
 
To start ''dhcpcd'' manually, simply run the following command:
  
{{hc|# dhcpcd eth0|
+
{{hc|# dhcpcd ''interface''|
 
dhcpcd: version 5.1.1 starting
 
dhcpcd: version 5.1.1 starting
dhcpcd: eth0: broadcasting for a lease
+
dhcpcd: ''interface'': broadcasting for a lease
 
...
 
...
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds
+
dhcpcd: ''interface'': leased 192.168.1.70 for 86400 seconds
 
}}
 
}}
  

Revision as of 20:38, 17 February 2014

Note: dhcpcd (DHCP client daemon) is not the same as dhcpd (DHCP (server) daemon).

dhcpcd is a DHCP and DHCPv6 client. It is currently the most feature-rich open source DHCP client, see the home page for the full list of features.

Installation

The dhcpcd package is available in the official repositories. It is part of the base group, so it is likely already installed on your system.

You might be interested in dhcpcd-uiAUR, which is a GTK+ frontend for the dhcpcd daemon (and optionally wpa_supplicant). It features a configuration dialogue and the ability to enter a pass phrase for wireless networks.

Running

dhcpcd is usually controlled via the provided service file dhcpcd@.service, which takes the interface name as an argument (see systemd#Using units for details):

# systemctl start dhcpcd@interface.service
# systemctl enable dhcpcd@interface.service

To start dhcpcd manually, simply run the following command:

# dhcpcd interface
dhcpcd: version 5.1.1 starting
dhcpcd: interface: broadcasting for a lease
...
dhcpcd: interface: leased 192.168.1.70 for 86400 seconds

Configuration

The main configuration is done in /etc/dhcpcd.conf, see dhcpcd.conf(5) for details. Some of the frequently used options are highlighted below.

Client ID

If you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:

/etc/dhcpcd.conf
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. 
duid

To:

/etc/dhcpcd.conf
# Use the hardware address of the interface for the Client ID (DHCPv4).
clientid

Else, you may not obtain a lease since the DHCP server may not read your DHCPv6-style Client ID correctly. See RFC 4361 for more information.

DHCP static route(s)

If you need to add a static route client-side, create a new dhcpcd hook-script in /usr/lib/dhcpcd/dhcpcd-hooks. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:

/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute
ip route add 10.11.12.0/24 via 192.168.192.5

The 40 prefix means that it is the final hook-script to run when dhcpcd starts.