1.\" Copyright (c) 2006-2012 Roy Marples 2.\" All rights reserved 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd March 19, 2012 26.Dt DHCPCD 8 27.Os 28.Sh NAME 29.Nm dhcpcd 30.Nd an RFC 2131 compliant DHCP client 31.Sh SYNOPSIS 32.Nm 33.Op Fl ABbDdEGgHJKkLnpqTVw 34.Op Fl C , Fl Fl nohook Ar hook 35.Op Fl c , Fl Fl script Ar script 36.Op Fl e , Fl Fl env Ar value 37.Op Fl F , Fl Fl fqdn Ar FQDN 38.Op Fl f , Fl Fl config Ar file 39.Op Fl h , Fl Fl hostname Ar hostname 40.Op Fl I , Fl Fl clientid Ar clientid 41.Op Fl i , Fl Fl vendorclassid Ar vendorclassid 42.Op Fl l , Fl Fl leasetime Ar seconds 43.Op Fl m , Fl Fl metric Ar metric 44.Op Fl O , Fl Fl nooption Ar option 45.Op Fl o , Fl Fl option Ar option 46.Op Fl Q , Fl Fl require Ar option 47.Op Fl r , Fl Fl request Ar address 48.Op Fl S , Fl Fl static Ar value 49.Op Fl s , Fl Fl inform Ar address Ns Op Ar /cidr 50.Op Fl t , Fl Fl timeout Ar seconds 51.Op Fl u , Fl Fl userclass Ar class 52.Op Fl v , Fl Fl vendor Ar code , Ar value 53.Op Fl W , Fl Fl whitelist Ar address Ns Op Ar /cidr 54.Op Fl y , Fl Fl reboot Ar seconds 55.Op Fl X , Fl Fl blacklist Ar address Ns Op Ar /cidr 56.Op Fl Z , Fl Fl denyinterfaces Ar pattern 57.Op Fl z , Fl Fl allowinterfaces Ar pattern 58.Op interface 59.Op ... 60.Nm 61.Fl k , Fl Fl release 62.Op interface 63.Nm 64.Fl U, Fl Fl dumplease 65.Ar interface 66.Nm 67.Fl Fl version 68.Nm 69.Fl x , Fl Fl exit 70.Op interface 71.Sh DESCRIPTION 72.Nm 73is an implementation of the DHCP client specified in 74.Li RFC 2131 . 75.Nm 76gets the host information 77.Po 78IP address, routes, etc 79.Pc 80from a DHCP server and configures the network 81.Ar interface 82of the 83machine on which it is running. 84.Nm 85then runs the configuration script which writes DNS information to 86.Xr resolvconf 8 , 87if available, otherwise directly to 88.Pa /etc/resolv.conf . 89If the hostname is currently blank, (null) or localhost, or 90.Va force_hostname 91is YES or TRUE or 1 then 92.Nm 93sets the hostname to the one supplied by the DHCP server. 94.Nm 95then daemonises and waits for the lease renewal time to lapse. 96It will then attempt to renew its lease and reconfigure if the new lease 97changes. 98.Pp 99.Nm 100is also an implementation of the BOOTP client specified in 101.Li RFC 951 . 102.Pp 103.Nm 104is also an implementation of an IPv6 Router Solicitor as specified in 105.Li RFC 6106 106with regard to the RDNSS and DNSSL options. 107.Ss Local Link configuration 108If 109.Nm 110failed to obtain a lease, it probes for a valid IPv4LL address 111.Po 112aka ZeroConf, aka APIPA 113.Pc . 114Once obtained it restarts the process of looking for a DHCP server to get a 115proper address. 116.Pp 117When using IPv4LL, 118.Nm 119nearly always succeeds and returns an exit code of 0. 120In the rare case it fails, it normally means that there is a reverse ARP proxy 121installed which always defeats IPv4LL probing. 122To disable this behaviour, you can use the 123.Fl L , Fl Fl noipv4ll 124option. 125.Ss Multiple interfaces 126If a list of interfaces are given on the command line, then 127.Nm 128only works with those interfaces, otherwise 129.Nm 130discovers available Ethernet interfaces. 131If any interface reports a working carrier then 132.Nm 133will try and obtain a lease before forking to the background, 134otherwise it will fork right away. 135This behaviour can be modified with the 136.Fl b , Fl Fl background 137and 138.Fl w , Fl Fl waitip 139options. 140.Pp 141If a single interface is given then 142.Nm 143only works for that interface and runs as a separate instance. 144The 145.Fl w , Fl Fl waitip 146option is enabled in this instance to maintain compatibility with older 147versions. 148.Pp 149Interfaces are preferred by carrier, DHCP lease/IPv4LL and then lowest metric. 150For systems that support route metrics, each route will be tagged with the 151metric, otherwise 152.Nm 153changes the routes to use the interface with the same route and the lowest 154metric. 155See options below for controlling which interfaces we allow and deny through 156the use of patterns. 157.Ss Hooking into DHCP events 158.Nm 159runs 160.Pa @SCRIPT@ , 161or the script specified by the 162.Fl c , Fl Fl script 163option. 164This script runs each script found in 165.Pa @HOOKDIR@ 166in a lexical order. 167The default installation supplies the scripts 168.Pa 01-test , 169.Pa 10-mtu , 170.Pa 20-resolv.conf 171and 172.Pa 30-hostname . 173You can disable each script by using the 174.Fl C , Fl Fl nohook 175option. 176See 177.Xr dhcpcd-run-hooks 8 178for details on how these scripts work. 179.Nm 180currently ignores the exit code of the script. 181.Ss Fine tuning 182You can fine-tune the behaviour of 183.Nm 184with the following options: 185.Bl -tag -width indent 186.It Fl b , Fl Fl background 187Background immediately. 188This is useful for startup scripts which don't disable link messages for 189carrier status. 190.It Fl c , Fl Fl script Ar script 191Use this 192.Ar script 193instead of the default 194.Pa @SCRIPT@ . 195.It Fl D , Fl Fl duid 196Generate an 197.Li RFC 4361 198compliant clientid. 199This requires persistent storage and not all DHCP servers work with it so it 200is not enabled by default. 201.Nm 202generates the DUID and stores it in 203.Pa @SYSCONFDIR@/dhcpcd.duid . 204This file should not be copied to other hosts. 205.It Fl d , Fl Fl debug 206Echo debug messages to the stderr and syslog. 207.It Fl E , Fl Fl lastlease 208If 209.Nm 210cannot obtain a lease, then try to use the last lease acquired for the 211interface. 212If the 213.Fl p, Fl Fl persistent 214option is not given then the lease is used if it hasn't expired. 215.It Fl e , Fl Fl env Ar value 216Push 217.Ar value 218to the environment for use in 219.Xr dhcpcd-run-hooks 8 . 220For example, you can force the hostname hook to always set the hostname with 221.Fl e 222.Va force_hostname=YES . 223.It Fl g , Fl Fl reconfigure 224.Nm 225will re-apply IP address, routing and run 226.Xr dhcpcd-run-hooks 8 227for each interface. 228This is useful so that a 3rd party such as PPP or VPN can change the routing 229table and / or DNS, etc and then instruct 230.Nm 231to put things back afterwards. 232.Nm 233does not read a new configuration when this happens - you should rebind if you 234need that functionality. 235.It Fl F , Fl Fl fqdn Ar fqdn 236Requests that the DHCP server updates DNS using FQDN instead of just a 237hostname. 238Valid values for 239.Ar fqdn 240are disable, none, ptr and both. 241.Nm 242itself never does any DNS updates. 243.Nm 244encodes the FQDN hostname as specified in 245.Li RFC1035 . 246.It Fl f , Fl Fl config Ar file 247Specify a config to load instead of 248.Pa @SYSCONFDIR@/dhcpcd.conf . 249.Nm 250always processes the config file before any command line options. 251.It Fl h , Fl Fl hostname Ar hostname 252Sends 253.Ar hostname 254to the DHCP server so it can be registered in DNS. 255If 256.Ar hostname 257is an empty string then the current system hostname is sent. 258If 259.Ar hostname 260is a FQDN (ie, contains a .) then it will be encoded as such. 261.It Fl I , Fl Fl clientid Ar clientid 262Send the 263.Ar clientid . 264If the string is of the format 01:02:03 then it is encoded as hex. 265For interfaces whose hardware address is longer than 8 bytes, or if the 266.Ar clientid 267is an empty string then 268.Nm 269sends a default 270.Ar clientid 271of the hardware family and the hardware address. 272.It Fl i , Fl Fl vendorclassid Ar vendorclassid 273Override the 274.Ar vendorclassid 275field sent. 276The default is 277dhcpcd <version>. 278If not set then none is sent. 279.It Fl k , Fl Fl release 280This causes an existing 281.Nm 282process running on the 283.Ar interface 284to release its lease, de-configure the 285.Ar interface 286and then exit. 287.Nm 288then waits until this process has exited. 289.It Fl l , Fl Fl leasetime Ar seconds 290Request a specific lease time in 291.Ar seconds . 292By default 293.Nm 294does not request any lease time and leaves it in the hands of the 295DHCP server. 296.It Fl m , Fl Fl metric Ar metric 297Metrics are used to prefer an interface over another one, lowest wins. 298.Nm 299will supply a default metic of 200 + 300.Xr if_nametoindex 3 . 301An extra 100 will be added for wireless interfaces. 302.It Fl n , Fl Fl rebind 303Notifies 304.Nm 305to reload its configuration and rebind its interfaces. 306If 307.Nm 308is not running, then it starts up as normal. 309.It Fl o , Fl Fl option Ar option 310Request the DHCP 311.Ar option 312variable for use in 313.Pa @SCRIPT@ . 314.It Fl p , Fl Fl persistent 315.Nm 316normally de-configures the 317.Ar interface 318and configuration when it exits. 319Sometimes, this isn't desirable if, for example, you have root mounted over 320NFS. 321You can use this option to stop this from happening. 322.It Fl r , Fl Fl request Op Ar address 323Request the 324.Ar address 325in the DHCP DISCOVER message. 326There is no guarantee this is the address the DHCP server will actually give. 327If no 328.Ar address 329is given then the first address currently assigned to the 330.Ar interface 331is used. 332.It Fl s , Fl Fl inform Op Ar address Ns Op Ar /cidr 333Behaves like 334.Fl r , Fl Fl request 335as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST. 336This does not get a lease as such, just notifies the DHCP server of the 337.Ar address 338in use. 339You should also include the optional 340.Ar cidr 341network number in case the address is not already configured on the interface. 342.Nm 343remains running and pretends it has an infinite lease. 344.Nm 345will not de-configure the interface when it exits. 346If 347.Nm 348fails to contact a DHCP server then it returns a failure instead of falling 349back on IPv4LL. 350.It Fl t , Fl Fl timeout Ar seconds 351Timeout after 352.Ar seconds , 353instead of the default 30. 354A setting of 0 355.Ar seconds 356causes 357.Nm 358to wait forever to get a lease. 359.It Fl u , Fl Fl userclass Ar class 360Tags the DHCP message with the userclass 361.Ar class . 362DHCP servers use this to give members of the class DHCP options other than the 363default, without having to know things like hardware address or hostname. 364.It Fl v , Fl Fl vendor Ar code , Ns Ar value 365Add an encapsulated vendor option. 366.Ar code 367should be between 1 and 254 inclusive. 368To add a raw vendor string, omit 369.Ar code 370but keep the comma. 371Examples. 372.Pp 373Set the vendor option 01 with an IP address. 374.D1 dhcpcd \-v 01,192.168.0.2 eth0 375Set the vendor option 02 with a hex code. 376.D1 dhcpcd \-v 02,01:02:03:04:05 eth0 377Set the vendor option 03 with an IP address as a string. 378.D1 dhcpcd \-v 03,\e"192.168.0.2\e" eth0 379Set un-encapsulated vendor option to hello world. 380.D1 dhcpcd \-v ,"hello world" eth0 381.It Fl Fl version 382Display both program version and copyright information. 383.Nm 384then exits before doing any configuration. 385.It Fl w , Fl Fl waitip 386Wait for an address to be assigned before forking to the background. 387.It Fl x , Fl Fl exit 388This will signal an existing 389.Nm 390process running on the 391.Ar interface 392to de-configure the 393.Ar interface 394and exit. 395.Nm 396then waits until this process has exited. 397.It Fl y , Fl Fl reboot Ar seconds 398Allow 399.Ar reboot 400seconds before moving to the discover phase if we have an old lease to use. 401The default is 5 seconds. 402A setting of 0 seconds causes 403.Nm 404to skip the reboot phase and go straight into discover. 405.El 406.Ss Restricting behaviour 407.Nm 408will try to do as much as it can by default. 409However, there are sometimes situations where you don't want the things to be 410configured exactly how the the DHCP server wants. 411Here are some options that deal with turning these bits off. 412.Bl -tag -width indent 413.It Fl A , Fl Fl noarp 414Don't request or claim the address by ARP. 415This also disables IPv4LL. 416.It Fl B , Fl Fl nobackground 417Don't run in the background when we acquire a lease. 418This is mainly useful for running under the control of another process, such 419as a debugger or a network manager. 420.It Fl C , Fl Fl nohook Ar script 421Don't run this hook script. 422Matches full name, or prefixed with 2 numbers optionally ending with 423.Pa .sh . 424.Pp 425So to stop 426.Nm 427from touching your DNS or MTU settings you would do:- 428.D1 dhcpcd -C resolv.conf -C mtu eth0 429.It Fl G , Fl Fl nogateway 430Don't set any default routes. 431.It Fl H , Fl Fl xidhwaddr 432Use the last four bytes of the hardware address as the DHCP xid instead 433of a randomly generated number. 434.It Fl J , Fl Fl broadcast 435Instructs the DHCP server to broadcast replies back to the client. 436Normally this is only set for non Ethernet interfaces, 437such as FireWire and InfiniBand. 438In most instances, 439.Nm 440will set this automatically. 441.It Fl K , Fl Fl nolink 442Don't receive link messages for carrier status. 443You should only have to use this with buggy device drivers or running 444.Nm 445through a network manager. 446.It Fl L , Fl Fl noipv4ll 447Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf). 448.It Fl O , Fl Fl nooption Ar option 449Don't request the specified option. 450If no option given, then don't request any options other than those to 451configure the interface and routing. 452.It Fl Q , Fl Fl require Ar option 453Requires the 454.Ar option 455to be present in all DHCP messages, otherwise the message is ignored. 456To enforce that 457.Nm 458only responds to DHCP servers and not BOOTP servers, you can 459.Fl Q 460.Ar dhcp_message_type . 461.It Fl q , Fl Fl quiet 462Quiet 463.Nm 464on the command line, only warnings and errors will be displayed. 465The messages are still logged though. 466.It Fl S, Fl Fl static Ar value 467Configures a static 468.Ar value . 469If you set 470.Ic ip_address 471then 472.Nm 473will not attempt to obtain a lease and just use the value for the address with 474an infinite lease time. 475.Pp 476Here is an example which configures a static address, routes and dns. 477.D1 dhcpcd -S ip_address=192.168.0.10/24 \e 478.D1 -S routers=192.168.0.1 \e 479.D1 -S domain_name_servers=192.168.0.1 \e 480.D1 eth0 481.It Fl T, Fl Fl test 482On receipt of DHCP messages just call 483.Pa @SCRIPT@ 484with the reason of TEST which echos the DHCP variables found in the message 485to the console. 486The interface configuration isn't touched and neither are any configuration 487files. 488To test INFORM the interface needs to be configured with the desired address 489before starting 490.Nm . 491.It Fl U, Fl Fl dumplease Ar interface 492Dumps the last lease for the 493.Ar interface 494to stdout. 495.Ar interface 496could also be a path to a DHCP wire formatted file. 497.It Fl V, Fl Fl variables 498Display a list of option codes and the associated variable for use in 499.Xr dhcpcd-run-hooks 8 . 500Variables are prefixed with new_ and old_ unless the option number is -. 501Variables without an option are part of the DHCP message and cannot be 502directly requested. 503.It Fl W, Fl Fl whitelist Ar address Ns Op /cidr 504Only accept packets from 505.Ar address Ns Op /cidr . 506.Fl X, Fl Fl blacklist 507is ignored if 508.Fl W, Fl Fl whitelist 509is set. 510.It Fl X, Fl Fl blacklist Ar address Ns Op Ar /cidr 511Ignore all packets from 512.Ar address Ns Op Ar /cidr . 513.It Fl Z , Fl Fl denyinterfaces Ar pattern 514When discovering interfaces, the interface name must not match 515.Ar pattern 516which is a space or comma separated list of patterns passed to 517.Xr fnmatch 3 . 518.It Fl z , Fl Fl allowinterfaces Ar pattern 519When discovering interfaces, the interface name must match 520.Ar pattern 521which is a space or comma separated list of patterns passed to 522.Xr fnmatch 3 . 523If the same interface is matched in 524.Fl Z , Fl Fl denyinterfaces 525then it is still denied. 526.El 527.Sh 3RDPARTY LINK MANAGEMENT 528Some interfaces require configuration by 3rd parties, such as PPP or VPN. 529When an interface configuration in 530.Nm 531is marked as STATIC or INFORM without an address then 532.Nm 533will monitor the interface until an address is added or removed from it and 534act accordingly. 535For point to point interfaces (like PPP), a default route to its 536destination is automatically added to the configuration. 537If the point to point interface is configured for INFORM, then 538.Nm 539unicasts INFORM to the destination, otherwise it defaults to STATIC. 540.Sh NOTES 541.Nm 542requires a Berkley Packet Filter, or BPF device on BSD based systems and a 543Linux Socket Filter, or LPF device on Linux based systems. 544.Sh FILES 545.Bl -ohang 546.It Pa @SYSCONFDIR@/dhcpcd.conf 547Configuration file for dhcpcd. 548If you always use the same options, put them here. 549.It Pa @SYSCONFDIR@/dhcpcd.duid 550Text file that holds the DUID used to identify the host. 551.It Pa @SCRIPT@ 552Bourne shell script that is run to configure or de-configure an interface. 553.It Pa @HOOKDIR@ 554A directory containing bourne shell scripts that are run by the above script. 555Each script can be disabled by using the 556.Fl C , Fl Fl nohook 557option described above. 558.It Pa @DBDIR@/dhcpcd\- Ns Ar interface Ns .lease 559The actual DHCP message send by the server. 560We use this when reading the last 561lease and use the files mtime as when it was issued. 562.It Pa /var/run/dhcpcd.pid 563Stores the PID of 564.Nm 565running on all interfaces. 566.It Pa /var/run/dhcpcd\- Ns Ar interface Ns .pid 567Stores the PID of 568.Nm 569running on the 570.Ar interface . 571.El 572.Sh SEE ALSO 573.Xr fnmatch 3 , 574.Xr if_nametoindex 3 , 575.Xr dhcpcd.conf 5 , 576.Xr resolv.conf 5 , 577.Xr dhcpcd-run-hooks 8 , 578.Xr resolvconf 8 579.Sh STANDARDS 580RFC 951, RFC 1534, RFC 2131, RFC 2132, RFC 2855, RFC 3004, RFC 3361, RFC 3396, 581RFC 3397, RFC 3442, RFC 3927, RFC 4361, RFC 4390, RFC 4702, RFC 5969, RFC 6106. 582.Sh AUTHORS 583.An Roy Marples Aq roy@marples.name 584.Sh BUGS 585Please report them to 586.Lk http://roy.marples.name/projects/dhcpcd 587