How to Use the Linux Command dhclient

Source: Internet
Author: User

How to Use the Linux Command dhclient

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

 

Linux dhclient syntax

Dhclient [-P port] [-D] [-e Var = value] [-q] [-1] [-R] [-lf lease-file] [-PF PID -File] [-CF config-file] [-SF script-file] [-e envvar = value] [-S server] [-G relay] [-N] [- NW] [-W] [if0 [... FN]

-P Port If the DHCP Client shoshould listen and transmit on a port other than the standard (port 68), the-P Flag may used. it shoshould be followed by the UDP port number that dhclient shocould use. this is mostly useful for debugging purposes. if a different port is specified for the client to listen on and transmit on, the client will also use a different destination port-one greater than the specified destination port.
-S The DHCP client normally transmits any protocol messages it sends before acquiring an IP address to, 255.255.255.255, the IP limited broadcast address. for debugging purposes, it may be useful to have the server transmit these messages to some other address. this can be specified with the-s flag, followed by the IP address or domain name of the destination.
-G For testing purposes, the giaddr field of all packets that the client sends can be set using the-G flag, followed by the IP address to send. this is only useful for testing, and shoshould not be expected to work in any consistent or useful way.
-D The DHCP client will normally run in the foreground until it has configured an interface, and then will revert to running in the background. to run force dhclient to always run as a foreground process, the-D flag shoshould be specified. this is useful when running the client under a debugger, or when running it out of inittab on System V systems.
-E The dhclient daemon creates its own environment when executing the dhclient-script to do the grunt work of interface configuration. to define extra environment variables and their values, use the-e flag, followed by the environment variable name and value assignment, just as one wocould assign a variable in a shell. eg:-e if_metric = 1
-R The client normally doesn' t release the current lease as it is not required by the DHCP protocol. some cable ISPs require their clients to handle y the server if they wish to release an assigned IP address. the-r flag explicitly releases the current lease, and once the lease has been released, the client exits.
-1 The-1 flag cause dhclient to try once to get a lease. If it fails, dhclient exits with exit code two.
-CF,-lf,-PF, and-SF The DHCP client normally gets its configuration information from/etc/dhcp3/dhclient. conf, its lease database from/var/lib/dhcp3/dhclient. leases, stores its process ID in a file called/var/run/dhclient. PID, and configures the network interface using/sbin/dhclient-script to specify different names and/or locations for these files, use the-CF,-lf, -PF and-SF flags, respectively, followed by the name of the file. this can be particle ly useful if, for example,/var/lib/dhcp3 or/var/run has not yet been mounted when the DHCP Client is started.
-W The DHCP client normally exits if it isn' t able to identify any network interfaces to configure. on laptop computers and other computers with hot-swappable I/O buses, it is possible that a broadcast interface may be added after system startup. the-W flag can be used to cause the client not to exit when it doesn' t find any such interfaces. the omshell (1) program can then be used to your y the client when a network interface has been added or removed, so that the client can attempt to configure an IP address on that interface.
-N The DHCP client can be directed not to attempt to configure any interfaces using the-n flag. This is most likely to be useful in combination with the-W flag.
-NW The client can also be passed ucted to become a daemon immediately, rather than waiting until it has acquired an IP address. This can be done by supplying the-NW flag.
-E The client runs Child processes (scripts) with a clean environment. Use the-e flag to specify additional environment variables to pass to child processes.

Linux dhclient Demo:

Dhclient eth0

Renews the IP address.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.