https://wiki.archlinux.org/api.php?action=feedcontributions&user=Mgb&feedformat=atomArchWiki - User contributions [en]2024-03-19T07:20:06ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Dhcpcd&diff=305561Dhcpcd2014-03-19T07:53:29Z<p>Mgb: /* Modify systemd unit file */</p>
<hr />
<div>{{DISPLAYTITLE:dhcpcd}}<br />
[[Category:Networking]]<br />
{{Related articles start}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related articles end}}<br />
<br />
[http://roy.marples.name/projects/dhcpcd/ 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.<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
== Installation ==<br />
<br />
The {{Pkg|dhcpcd}} package is available in the [[official repositories]]. It is part of the {{Grp|base}} group, so it is likely already installed on your system.<br />
<br />
You might be interested in {{AUR|dhcpcd-ui}}, 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.<br />
<br />
== Running ==<br />
<br />
''dhcpcd'' is usually controlled via the provided service file {{ic|dhcpcd@.service}}, which takes the interface name as an argument (see [[systemd#Using units]] for details):<br />
<br />
# systemctl start dhcpcd@''interface''.service<br />
# systemctl enable dhcpcd@''interface''.service<br />
<br />
To start ''dhcpcd'' manually, simply run the following command:<br />
<br />
{{hc|# dhcpcd ''interface''|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: ''interface'': broadcasting for a lease<br />
...<br />
dhcpcd: ''interface'': leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
== Configuration ==<br />
<br />
The main configuration is done in {{ic|/etc/dhcpcd.conf}}, see {{ic|dhcpcd.conf(5)}} for details. Some of the frequently used options are highlighted below.<br />
<br />
=== DHCP static route(s) ===<br />
<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on {{ic|10.11.12.0/24}} via a gateway machine at {{ic|192.168.192.5}}:<br />
<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
<br />
The {{ic|40}} prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== DHCP Client Identifier ===<br />
<br />
The DHCP client may be uniquely identified in different ways by the server: <br />
* hostname (or the hostname value sent by the client), <br />
* MAC address of the network interface controller through which the connection is being made, linked to this is the third, <br />
* Identity Association ID (IAID), which is an abstraction layer to differentiate different use-cases and/or interfaces on a single host, <br />
* DHCP Unique Identifier (DUID). <br />
For a further description, see [https://tools.ietf.org/html/rfc3315#section-4.2 RFC 3315]. <br />
<br />
It depends on the DHCP-server configuration which options are optional or required to request a DHCP IP lease. If the ''dhcpcd'' default configuration fails to obtain an IP, the following options are available to use in {{ic|dhcpcd.conf}}: <br />
* {{ic|hostname}} sends the hostname set in {{ic|/etc/hostname}}<br />
* {{ic|clientid}} sends the MAC address as identifier<br />
* {{ic|IAID <interface>}} derives the IAID for the {{ic|interface <interface>}} to use for DHCP discovery. Both have to be used [https://bbs.archlinux.org/viewtopic.php?pid=1388376#p1388376 together], but more frequently the next option is used: <br />
* {{ic|duid}} triggers using a combination of DUID and IAID as identifier. <br />
<br />
The DUID value is set in {{ic|/etc/dhcpcd.duid}}. <br />
<br />
Care must be taken on a network running [[Wikipedia:Dynamic DNS|Dynamic DNS]] to ensure that all three are unique. If duplicate DUID values are presented to the DNS server, e.g. in the case where a virtual machine has been cloned and the hostname and MAC have been made unique but the DUID has not been changed, then the result will be that as each client with the duplicated DUID requests a lease the server will remove the predecessor from the DNS record.<br />
<br />
=== Speed up DHCP by disabling ARP probing ===<br />
<br />
''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}}:<br />
<br />
noarp<br />
<br />
This is equivalent to passing {{ic|--noarp}} to {{ic|dhcpcd}}, and disables the described ARP probing, speeding up connections to networks with DHCP.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Remove old DHCP lease ===<br />
<br />
The file {{ic|/var/lib/dhcpcd/dhcpcd-''interface''.lease}}, where {{ic|''interface''}} is the name of the interface on which you have a lease, contains the actual DHCP lease reply sent by the DHCP server. It is used to determine the last lease from the server, and its {{ic|mtime}} attribute is used to determine when it was issued. This last lease information is then used to request the same IP address previously held on a network, if it is available. If you do not want that, simply delete this file.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Client ID ===<br />
<br />
If you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
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:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== Problems with incompliant routers ===<br />
<br />
For some (incompliant) routers, you will not be able to connect properly unless you comment the line<br />
<br />
require dhcp_server_identifier<br />
<br />
in {{ic|/etc/dhcpcd.conf}}. This should not cause issues unless you have multiple DHCP servers on your network (not typical); see [http://technet.microsoft.com/en-us/library/cc977442.aspx this page] for more information.<br />
=== dhcpcd, systemd & wpa_supplicant ===<br />
<br />
archlinux dhcpcd package is delivered with a client configuration script to run wpa_supplicant (/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant).<br />
<br />
When you manage wpa_supplicant daemon with systemd this can result in unexpected behavior e.g. <br />
* you stop wpa_supplicant via systemd and dhcpcd starts wpa_supplicant via hook<br />
* dhcpcd starts wpa_supplicant daemon during boot (this can result in systemd-udevd error: "error changing net interface name wlan0 to wlp4s0: Device or resource busy" and can prevent "Predictable Network Interface Names" )<br />
<br />
To disable wpa_supplicant daemon start from dhcpcd you can:<br />
* modify the systemd unit file for dhcpcd<br />
* or modify dhcpcd.conf<br />
<br />
==== Modify systemd unit file ====<br />
The archlinux dhcpcd Package is delivered with unit files dhcpcd.service dhcpcd@.service (in /lib/systemd/system/). To disable wpa_supplicant from dhcpcd add the "-C wpa_supplicant" option.<br />
<br />
To change the archlinux unit file you should copy file to /etc/systemd/system/ and modify it - or you create a new unit.<br />
<br />
A modified archlinux unit file looks like:<br />
<br />
{{hc|/etc/systemd/system/dhcpcd.service|2=<br />
[Unit] <br />
Description=dhcpcd on all interfaces <br />
Wants=network.target<br />
Before=network.target<br />
<br />
[Service] <br />
Type=forking <br />
PIDFile=/run/dhcpcd.pid <br />
ExecStart=/usr/bin/dhcpcd -q -b -C wpa_supplicant<br />
ExecStop=/usr/bin/dhcpcd -x<br />
<br />
[Install] <br />
WantedBy=multi-user.target<br />
}}<br />
<br />
== Hooks ==<br />
<br />
''dhcpcd'' executes all scripts found in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks/}} in a lexical order. See {{ic|dhcpcd(5)}} and {{ic|dhcpcd-run-hooks(8)}} for details.<br />
<br />
{{Note|<br />
* Each script can be disabled using the {{ic|nohook}} option in {{ic|dhcpcd.conf}}.<br />
* The {{ic|env}} option can be used to set an environment variable for '''all''' hooks. For example, you can force the hostname hook to always set the hostname with {{ic|1=env force_hostname=YES}}.<br />
}}<br />
<br />
{{Expansion|describe (at least some) provided hooks, e.g. {{ic|10-wpa_supplicant}}}}</div>Mgbhttps://wiki.archlinux.org/index.php?title=Dhcpcd&diff=305560Dhcpcd2014-03-19T07:45:08Z<p>Mgb: /* Modify systemd unit file */</p>
<hr />
<div>{{DISPLAYTITLE:dhcpcd}}<br />
[[Category:Networking]]<br />
{{Related articles start}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related articles end}}<br />
<br />
[http://roy.marples.name/projects/dhcpcd/ 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.<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
== Installation ==<br />
<br />
The {{Pkg|dhcpcd}} package is available in the [[official repositories]]. It is part of the {{Grp|base}} group, so it is likely already installed on your system.<br />
<br />
You might be interested in {{AUR|dhcpcd-ui}}, 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.<br />
<br />
== Running ==<br />
<br />
''dhcpcd'' is usually controlled via the provided service file {{ic|dhcpcd@.service}}, which takes the interface name as an argument (see [[systemd#Using units]] for details):<br />
<br />
# systemctl start dhcpcd@''interface''.service<br />
# systemctl enable dhcpcd@''interface''.service<br />
<br />
To start ''dhcpcd'' manually, simply run the following command:<br />
<br />
{{hc|# dhcpcd ''interface''|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: ''interface'': broadcasting for a lease<br />
...<br />
dhcpcd: ''interface'': leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
== Configuration ==<br />
<br />
The main configuration is done in {{ic|/etc/dhcpcd.conf}}, see {{ic|dhcpcd.conf(5)}} for details. Some of the frequently used options are highlighted below.<br />
<br />
=== DHCP static route(s) ===<br />
<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on {{ic|10.11.12.0/24}} via a gateway machine at {{ic|192.168.192.5}}:<br />
<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
<br />
The {{ic|40}} prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== DHCP Client Identifier ===<br />
<br />
The DHCP client may be uniquely identified in different ways by the server: <br />
* hostname (or the hostname value sent by the client), <br />
* MAC address of the network interface controller through which the connection is being made, linked to this is the third, <br />
* Identity Association ID (IAID), which is an abstraction layer to differentiate different use-cases and/or interfaces on a single host, <br />
* DHCP Unique Identifier (DUID). <br />
For a further description, see [https://tools.ietf.org/html/rfc3315#section-4.2 RFC 3315]. <br />
<br />
It depends on the DHCP-server configuration which options are optional or required to request a DHCP IP lease. If the ''dhcpcd'' default configuration fails to obtain an IP, the following options are available to use in {{ic|dhcpcd.conf}}: <br />
* {{ic|hostname}} sends the hostname set in {{ic|/etc/hostname}}<br />
* {{ic|clientid}} sends the MAC address as identifier<br />
* {{ic|IAID <interface>}} derives the IAID for the {{ic|interface <interface>}} to use for DHCP discovery. Both have to be used [https://bbs.archlinux.org/viewtopic.php?pid=1388376#p1388376 together], but more frequently the next option is used: <br />
* {{ic|duid}} triggers using a combination of DUID and IAID as identifier. <br />
<br />
The DUID value is set in {{ic|/etc/dhcpcd.duid}}. <br />
<br />
Care must be taken on a network running [[Wikipedia:Dynamic DNS|Dynamic DNS]] to ensure that all three are unique. If duplicate DUID values are presented to the DNS server, e.g. in the case where a virtual machine has been cloned and the hostname and MAC have been made unique but the DUID has not been changed, then the result will be that as each client with the duplicated DUID requests a lease the server will remove the predecessor from the DNS record.<br />
<br />
=== Speed up DHCP by disabling ARP probing ===<br />
<br />
''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}}:<br />
<br />
noarp<br />
<br />
This is equivalent to passing {{ic|--noarp}} to {{ic|dhcpcd}}, and disables the described ARP probing, speeding up connections to networks with DHCP.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Remove old DHCP lease ===<br />
<br />
The file {{ic|/var/lib/dhcpcd/dhcpcd-''interface''.lease}}, where {{ic|''interface''}} is the name of the interface on which you have a lease, contains the actual DHCP lease reply sent by the DHCP server. It is used to determine the last lease from the server, and its {{ic|mtime}} attribute is used to determine when it was issued. This last lease information is then used to request the same IP address previously held on a network, if it is available. If you do not want that, simply delete this file.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Client ID ===<br />
<br />
If you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
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:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== Problems with incompliant routers ===<br />
<br />
For some (incompliant) routers, you will not be able to connect properly unless you comment the line<br />
<br />
require dhcp_server_identifier<br />
<br />
in {{ic|/etc/dhcpcd.conf}}. This should not cause issues unless you have multiple DHCP servers on your network (not typical); see [http://technet.microsoft.com/en-us/library/cc977442.aspx this page] for more information.<br />
=== dhcpcd, systemd & wpa_supplicant ===<br />
<br />
archlinux dhcpcd package is delivered with a client configuration script to run wpa_supplicant (/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant).<br />
<br />
When you manage wpa_supplicant daemon with systemd this can result in unexpected behavior e.g. <br />
* you stop wpa_supplicant via systemd and dhcpcd starts wpa_supplicant via hook<br />
* dhcpcd starts wpa_supplicant daemon during boot (this can result in systemd-udevd error: "error changing net interface name wlan0 to wlp4s0: Device or resource busy" and can prevent "Predictable Network Interface Names" )<br />
<br />
To disable wpa_supplicant daemon start from dhcpcd you can:<br />
* modify the systemd unit file for dhcpcd<br />
* or modify dhcpcd.conf<br />
<br />
==== Modify systemd unit file ====<br />
The archlinux dhcpcd Package is delivered with unit files dhcpcd.service dhcpcd@.service (in /lib/systemd/system/). To disable wpa_supplicant from dhcpcd add the "-C wpa_supplicant" option.<br />
<br />
To change the archlinux unit file you should copy file to /etc/systemd/system/ and modify it - or you create a new unit.<br />
<br />
A modified archlinux unit file looks like:<br />
<br />
<code><br />
[Unit] <br><br />
Description=dhcpcd on all interfaces <br><br />
Wants=network.target <br><br />
Before=network.target<br />
<br />
[Service] <br><br />
Type=forking <br><br />
PIDFile=/run/dhcpcd.pid <br><br />
ExecStart=/usr/bin/dhcpcd -q -b -C wpa_supplicant <br><br />
ExecStop=/usr/bin/dhcpcd -x <br><br />
<br />
[Install] <br><br />
WantedBy=multi-user.target<br />
</code><br />
<br />
== Hooks ==<br />
<br />
''dhcpcd'' executes all scripts found in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks/}} in a lexical order. See {{ic|dhcpcd(5)}} and {{ic|dhcpcd-run-hooks(8)}} for details.<br />
<br />
{{Note|<br />
* Each script can be disabled using the {{ic|nohook}} option in {{ic|dhcpcd.conf}}.<br />
* The {{ic|env}} option can be used to set an environment variable for '''all''' hooks. For example, you can force the hostname hook to always set the hostname with {{ic|1=env force_hostname=YES}}.<br />
}}<br />
<br />
{{Expansion|describe (at least some) provided hooks, e.g. {{ic|10-wpa_supplicant}}}}</div>Mgbhttps://wiki.archlinux.org/index.php?title=Dhcpcd&diff=305559Dhcpcd2014-03-19T07:33:17Z<p>Mgb: /* Troubleshooting */</p>
<hr />
<div>{{DISPLAYTITLE:dhcpcd}}<br />
[[Category:Networking]]<br />
{{Related articles start}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related articles end}}<br />
<br />
[http://roy.marples.name/projects/dhcpcd/ 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.<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
== Installation ==<br />
<br />
The {{Pkg|dhcpcd}} package is available in the [[official repositories]]. It is part of the {{Grp|base}} group, so it is likely already installed on your system.<br />
<br />
You might be interested in {{AUR|dhcpcd-ui}}, 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.<br />
<br />
== Running ==<br />
<br />
''dhcpcd'' is usually controlled via the provided service file {{ic|dhcpcd@.service}}, which takes the interface name as an argument (see [[systemd#Using units]] for details):<br />
<br />
# systemctl start dhcpcd@''interface''.service<br />
# systemctl enable dhcpcd@''interface''.service<br />
<br />
To start ''dhcpcd'' manually, simply run the following command:<br />
<br />
{{hc|# dhcpcd ''interface''|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: ''interface'': broadcasting for a lease<br />
...<br />
dhcpcd: ''interface'': leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
== Configuration ==<br />
<br />
The main configuration is done in {{ic|/etc/dhcpcd.conf}}, see {{ic|dhcpcd.conf(5)}} for details. Some of the frequently used options are highlighted below.<br />
<br />
=== DHCP static route(s) ===<br />
<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on {{ic|10.11.12.0/24}} via a gateway machine at {{ic|192.168.192.5}}:<br />
<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
<br />
The {{ic|40}} prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== DHCP Client Identifier ===<br />
<br />
The DHCP client may be uniquely identified in different ways by the server: <br />
* hostname (or the hostname value sent by the client), <br />
* MAC address of the network interface controller through which the connection is being made, linked to this is the third, <br />
* Identity Association ID (IAID), which is an abstraction layer to differentiate different use-cases and/or interfaces on a single host, <br />
* DHCP Unique Identifier (DUID). <br />
For a further description, see [https://tools.ietf.org/html/rfc3315#section-4.2 RFC 3315]. <br />
<br />
It depends on the DHCP-server configuration which options are optional or required to request a DHCP IP lease. If the ''dhcpcd'' default configuration fails to obtain an IP, the following options are available to use in {{ic|dhcpcd.conf}}: <br />
* {{ic|hostname}} sends the hostname set in {{ic|/etc/hostname}}<br />
* {{ic|clientid}} sends the MAC address as identifier<br />
* {{ic|IAID <interface>}} derives the IAID for the {{ic|interface <interface>}} to use for DHCP discovery. Both have to be used [https://bbs.archlinux.org/viewtopic.php?pid=1388376#p1388376 together], but more frequently the next option is used: <br />
* {{ic|duid}} triggers using a combination of DUID and IAID as identifier. <br />
<br />
The DUID value is set in {{ic|/etc/dhcpcd.duid}}. <br />
<br />
Care must be taken on a network running [[Wikipedia:Dynamic DNS|Dynamic DNS]] to ensure that all three are unique. If duplicate DUID values are presented to the DNS server, e.g. in the case where a virtual machine has been cloned and the hostname and MAC have been made unique but the DUID has not been changed, then the result will be that as each client with the duplicated DUID requests a lease the server will remove the predecessor from the DNS record.<br />
<br />
=== Speed up DHCP by disabling ARP probing ===<br />
<br />
''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}}:<br />
<br />
noarp<br />
<br />
This is equivalent to passing {{ic|--noarp}} to {{ic|dhcpcd}}, and disables the described ARP probing, speeding up connections to networks with DHCP.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Remove old DHCP lease ===<br />
<br />
The file {{ic|/var/lib/dhcpcd/dhcpcd-''interface''.lease}}, where {{ic|''interface''}} is the name of the interface on which you have a lease, contains the actual DHCP lease reply sent by the DHCP server. It is used to determine the last lease from the server, and its {{ic|mtime}} attribute is used to determine when it was issued. This last lease information is then used to request the same IP address previously held on a network, if it is available. If you do not want that, simply delete this file.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Client ID ===<br />
<br />
If you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
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:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== Problems with incompliant routers ===<br />
<br />
For some (incompliant) routers, you will not be able to connect properly unless you comment the line<br />
<br />
require dhcp_server_identifier<br />
<br />
in {{ic|/etc/dhcpcd.conf}}. This should not cause issues unless you have multiple DHCP servers on your network (not typical); see [http://technet.microsoft.com/en-us/library/cc977442.aspx this page] for more information.<br />
=== dhcpcd, systemd & wpa_supplicant ===<br />
<br />
archlinux dhcpcd package is delivered with a client configuration script to run wpa_supplicant (/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant).<br />
<br />
When you manage wpa_supplicant daemon with systemd this can result in unexpected behavior e.g. <br />
* you stop wpa_supplicant via systemd and dhcpcd starts wpa_supplicant via hook<br />
* dhcpcd starts wpa_supplicant daemon during boot (this can result in systemd-udevd error: "error changing net interface name wlan0 to wlp4s0: Device or resource busy" and can prevent "Predictable Network Interface Names" )<br />
<br />
To disable wpa_supplicant daemon start from dhcpcd you can:<br />
* modify the systemd unit file for dhcpcd<br />
* or modify dhcpcd.conf<br />
<br />
==== Modify systemd unit file ====<br />
The archlinux dhcpcd Package is delivered with unit files dhcpcd.service dhcpcd@.service (in /lib/systemd/system/). To disable wpa_supplicant from dhcpcd add the "-C wpa_supplicant" option.<br />
<br />
To change the archlinux unit file you should copy file to /etc/systemd/system/ and modify it - or you create a new unit.<br />
<br />
A modified archlinux unit file looks like:<br />
<code><br />
[Unit]<br />
Description=dhcpcd on all interfaces<br />
Wants=network.target<br />
Before=network.target<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/run/dhcpcd.pid<br />
ExecStart=/usr/bin/dhcpcd -q -b -C wpa_supplicant<br />
ExecStop=/usr/bin/dhcpcd -x<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</code><br />
<br />
== Hooks ==<br />
<br />
''dhcpcd'' executes all scripts found in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks/}} in a lexical order. See {{ic|dhcpcd(5)}} and {{ic|dhcpcd-run-hooks(8)}} for details.<br />
<br />
{{Note|<br />
* Each script can be disabled using the {{ic|nohook}} option in {{ic|dhcpcd.conf}}.<br />
* The {{ic|env}} option can be used to set an environment variable for '''all''' hooks. For example, you can force the hostname hook to always set the hostname with {{ic|1=env force_hostname=YES}}.<br />
}}<br />
<br />
{{Expansion|describe (at least some) provided hooks, e.g. {{ic|10-wpa_supplicant}}}}</div>Mgb