Difference between revisions of "Dhcpcd"

From ArchWiki
Jump to: navigation, search
m (Configuration)
Line 64: Line 64:
 
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.
 
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.
  
==== Speed up DHCP by disabling ARP probing ====
+
=== Speed up DHCP by disabling ARP probing ===
  
 
''dhcpcd'' contains an implementation of a recommendation of the DHCP standard ([http://www.ietf.org/rfc/rfc2131.txt RFC2131] section 2.2) to check via ARP if the assigned IP address is really not taken. This seems mostly useless in home networks, so you can save about 5 seconds on every connect by adding the following line to {{ic|/etc/dhcpcd.conf}}:
 
''dhcpcd'' contains an implementation of a recommendation of the DHCP standard ([http://www.ietf.org/rfc/rfc2131.txt RFC2131] section 2.2) to check via ARP if the assigned IP address is really not taken. This seems mostly useless in home networks, so you can save about 5 seconds on every connect by adding the following line to {{ic|/etc/dhcpcd.conf}}:

Revision as of 20:53, 17 February 2014

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.

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

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.

Speed up DHCP by disabling ARP probing

dhcpcd contains an implementation of a recommendation of the DHCP standard (RFC2131 section 2.2) to check via ARP if the assigned IP address is really not taken. This seems mostly useless in home networks, so you can save about 5 seconds on every connect by adding the following line to /etc/dhcpcd.conf:

noarp

This is equivalent to passing --noarp to dhcpcd, and disables the described ARP probing, speeding up connections to networks with DHCP.

Troubleshooting

Check DHCP problem by releasing IP first

Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:

# dhcpcd -k

Then request a new one:

# dhcpcd

Maybe you had to run those two commands many times.