Linux "dhclient" Command Line Options and Examples
Dynamic Host Configuration Protocol Client

The Internet Systems Consortium DHCP Client, dhclient, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.


Usage:

dhclient [ -4 | -6 ] [ -S ] [ -N [ -N... ] ] [ -T [ -T... ] ] [ -P [ -P... ] ] -R ] [ -i ] [ -I ] [ -4o6 port ] [ -D LL|LLT ] [ -p
port-number ] [ -d ] [ -df duid-lease-file ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r | -x ] [ -lf lease-file ] [ -pf pid-file ] [ --no-
pid ] [ -cf config-file ] [ -sf script-file ] [ -s server-addr ] [ -g relay ] [ -n ] [ -nw ] [ -w ] [ -v ] [ --version ] [ if0 [
...ifN ] ]




Command Line Options:

-4o6
Participate in the DHCPv4 over DHCPv6 protocol specified by RFC 7341. This associates a DHCPv4 and a DHCPv6 client to allowthe v4 client to send v4 requests encapsulated in a v6 packet. Communication between the two clients is done on a pair of UDPsockets bound to ::1 port and port + 1. Both clients must be launched using the same port argument.
dhclient -4o6 ...
-nw
Become a daemon immediately (nowait) rather than waiting until an IP address has been acquired.
dhclient -nw ...
-q
this is the default.
dhclient -q ...
-v
Enable verbose log messages.
dhclient -v ...
-n
Do not configure any interfaces. This is most likely to be useful in combination with the -w flag.
dhclient -n ...
-e
Define additional environment variables for the environment where dhclient-script executes. You may specify multiple -eoptions on the command line.
dhclient -e ...
-p
The UDP port number on which the DHCP client should listen and transmit. If unspecified, dhclient uses the default port of68. This is mostly useful for debugging purposes. If a different port is specified on which the client should listen andtransmit, the client will also use a different destination port - one less than the specified port.
dhclient -p ...
-s
Specify the server IP address or fully qualified domain name to use as a destination for DHCP protocol messages beforedhclient has acquired an IP address. Normally, dhclient transmits these messages to 255.255.255.255 (the IP limited broadcastaddress). Overriding this is mostly useful for debugging purposes. This feature is not supported in DHCPv6 (-6) mode.
dhclient -s ...
-g
Set the giaddr field of all packets to the relay IP address simulating a relay agent. This is for testing purposes only andshould not be expected to work in any consistent or useful way.
dhclient -g ...
-I
Use the standard DDNS scheme from RFCs 4701 & 4702.
dhclient -I ...
--version
Print version number and exit.Options available for DHCPv6 mode:
dhclient --version ...
-D
Override the default when selecting the type of DUID to use. By default, DHCPv6 dhclient creates an identifier based on thelink-layer address (DUID-LL) if it is running in stateless mode (with -S, not requesting an address), or it creates an identi‐fier based on the link-layer address plus a timestamp (DUID-LLT) if it is running in stateful mode (without -S, requesting anaddress). When DHCPv4 is configured to use a DUID using -i option the default is to use a DUID-LLT. -D overrides thesedefault, with a value of either LL or LLT.
dhclient -D ...
-cf
Path to the client configuration file. If unspecified, the default /etc/dhcp/dhclient.conf is used. See dhclient.conf(5) fora description of this file.
dhclient -cf ...
-df
Path to a secondary lease file. If the primary lease file doesn't contain a DUID this file will be searched. The DUID readfrom the secondary will be written to the primary. This option can be used to allow an IPv4 instance of the client to share aDUID with an IPv6 instance. After starting one of the instances the second can be started with this option pointing to thelease file of the first instance. There is no default. If no file is specified no search is made for a DUID should one notbe found in the main lease file.
dhclient -df ...
-lf
Path to the lease database file. If unspecified, the default /var/lib/dhcp/dhclient.leases is used. See dhclient.leases(5)for a description of this file.
dhclient -lf ...
-pf
Path to the process ID file. If unspecified, the default /var/run/dhclient.pid is used.
dhclient -pf ...
--no-pid
Option to disable writing pid files. By default the program will write a pid file. If the program is invoked with thisoption it will not attempt to kill any existing client processes even if invoked with -r or -x.
dhclient --no-pid ...
-sf
Path to the network configuration script invoked by dhclient when it gets a lease. If unspecified, the default/sbin/dhclient-script is used. See dhclient-script(8) for a description of this file.PORTSDuring operations the client may use multiple UDP ports to provide different functions. Which ports are opened depends on both theway you compiled your code and the configuration you supply. The following should provide you an idea of what ports may be in use.Normally a DHCPv4 client will open a raw UDP socket to receive and send most DHCPv4 packets. It also opens a fallback UDP socket foruse in sending unicast packets. Normally these will both use the well known port number for BOOTPC.For DHCPv6 the client opens a UDP socket on the well known client port and a fallback UDP socket on a random port for use in sendingunicast messages. Unlike DHCPv4 the well known socket doesn't need to be opened in raw mode.If you have included an omapi port statement in your configuration file then the client will open a TCP socket on that port to listenfor OMPAI connections. When something connects another port will be used for the established connection.When DDNS is enabled at compile time (see includes/site.h) the client will open both a v4 and a v6 UDP socket on random ports. Theseports are opened even if DDNS is disabled in the configuration file.CONFIGURATIONThe syntax of the dhclient.conf(5) file is discussed separately.OMAPIThe DHCP client provides some ability to control it while it is running, without stopping it. This capability is provided usingOMAPI, an API for manipulating remote objects. OMAPI clients connect to the client using TCP/IP, authenticate, and can then examinethe client's current status and make changes to it.Rather than implementing the underlying OMAPI protocol directly, user programs should use the dhcpctl API or OMAPI itself. Dhcpctlis a wrapper that handles some of the housekeeping chores that OMAPI does not do automatically. Dhcpctl and OMAPI are documented indhcpctl(3) and omapi(3). Most things you'd want to do with the client can be done directly using the omshell(1) command, rather thanhaving to write a special program.THE CONTROL OBJECTThe control object allows you to shut the client down, releasing all leases that it holds and deleting any DNS records it may haveadded. It also allows you to pause the client - this unconfigures any interfaces the client is using. You can then restart it,which causes it to reconfigure those interfaces. You would normally pause the client prior to going into hibernation or sleep on alaptop computer. You would then resume it after the power comes back. This allows PC cards to be shut down while the computer ishibernating or sleeping, and then reinitialized to their previous state once the computer comes out of hibernation or sleep.The control object has one attribute - the state attribute. To shut the client down, set its state attribute to 2. It will automat‐ically do a DHCPRELEASE. To pause it, set its state attribute to 3. To resume it, set its state attribute to 4.ENVIRONMENT VARIABLESThe following environment variables may be defined to override the builtin defaults for file locations. Note that use of the relatedcommand-line options will ignore the corresponding environment variable settings.PATH_DHCLIENT_CONFThe dhclient.conf configuration file.PATH_DHCLIENT_DBThe dhclient.leases database.PATH_DHCLIENT_PIDThe dhclient PID file.PATH_DHCLIENT_SCRIPTThe dhclient-script file.FILES/sbin/dhclient-script, /etc/dhcp/dhclient.conf, /var/lib/dhcp/dhclient.leases, /var/run/dhclient.pid, /var/lib/dhcp/dhclient.leases~.
dhclient -sf ...