MAN page from Mandrake 9.X dhcp-client-3.0-1.rc12.2mdk.i586.rpm
Section: Maintenance Commands (8)Index
dhclient - Dynamic Host Configuration Protocol Client
The Internet Software Consortium DHCP Client, dhclient, provides ameans for configuring one or more network interfaces using the DynamicHost Configuration Protocol, BOOTP protocol, or if these protocolsfail, by statically assigning an address.
The DHCP protocol allows a host to contact a central server whichmaintains a list of IP addresses which may be assigned on one or moresubnets. A DHCP client may request an address from this pool, andthen use it on a temporary basis for communication on network. TheDHCP protocol also provides a mechanism whereby a client can learnimportant details about the network to which it is attached, such asthe location of a default router, the location of a name server, andso on.
On startup, dhclient reads thedhclient.conffor configuration instructions. It then gets a list of all thenetwork interfaces that are configured in the current system. Foreach interface, it attempts to configure the interface using the DHCPprotocol.
In order to keep track of leases across system reboots and serverrestarts, dhclient keeps a list of leases it has been assigned in thedhclient.leases(5) file. On startup, after reading the dhclient.conffile, dhclient reads the dhclient.leases file to refresh its memoryabout what leases it has been assigned.
When a new lease is acquired, it is appended to the end of thedhclient.leases file. In order to prevent the file from becomingarbitrarily large, from time to time dhclient creates a newdhclient.leases file from its in-core lease database. The old versionof the dhclient.leases file is retained under the namedhclient.leases~until the next time dhclient rewrites the database.
Old leases are kept around in case the DHCP server is unavailable whendhclient is first invoked (generally during the initial system bootprocess). In that event, old leases from the dhclient.leases filewhich have not yet expired are tested, and if they are determined tobe valid, they are used until either they expire or the DHCP serverbecomes available.
A mobile host which may sometimes need to access a network on which noDHCP server exists may be preloaded with a lease for a fixedaddress on that network. When all attempts to contact a DHCP serverhave failed, dhclient will try to validate the static lease, and if itsucceeds, will use that lease until it is restarted.
A mobile host may also travel to some networks on which DHCP is notavailable but BOOTP is. In that case, it may be advantageous toarrange with the network administrator for an entry on the BOOTPdatabase, so that the host can boot quickly on that network ratherthan cycling through the list of old leases.
The names of the network interfaces that dhclient should attempt toconfigure may be specified on the command line. If no interface namesare specified on the command line dhclient will normally identify allnetwork interfaces, eliminating non-broadcast interfaces ifpossible, and attempt to configure each interface.
It is also possible to specify interfaces by name in thedhclient.conf(5)file. If interfaces are specified in this way, then the client willonly configure interfaces that are either specified in theconfiguration file or on the command line, and will ignore all otherinterfaces.
If the DHCP client should listen and transmit on a port other than thestandard (port 68), the-pflag may used. It should be followed by the udp port number thatdhclient should use. This is mostly useful for debugging purposes.If a different port is specified for the client to listen on andtransmit on, the client will also use a different destination port -one greater than the specified destination port.
The DHCP client normally transmits any protocol messages it sendsbefore acquiring an IP address to, 255.255.255.255, the IP limitedbroadcast address. For debugging purposes, it may be useful to havethe server transmit these messages to some other address. This canbe specified with the -sflag, followed by the IP address or domain name of the destination.
For testing purposes, the giaddr field of all packets that the clientsends can be set using the-gflag, followed by the IP address to send. This is only useful for testing,and should not be expected to work in any consistent or useful way.
The DHCP client will normally run in the foreground until it hasconfigured an interface, and then will revert to running in thebackground. To run force dhclient to always run as a foregroundprocess, the-dflag should be specified. This is useful when running the clientunder a debugger, or when running it out of inittab on System Vsystems.
The client normally prints a startup message and displays theprotocol sequence to the standard error descriptor until it hasacquired an address, and then only logs messages using thesyslog (3)facility. The-qflag prevents any messages other than errors from being printed to thestandard error descriptor.
The client normally doesn't release the current lease as it is notrequired by the DHCP protocol. Some cable ISPs require their clientsto notify the server if they wish to release an assigned IP address.The-rflag explicitly releases the current lease, and once the lease has beenreleased, the client exits.
The-1flag cause dhclient to try once to get a lease. If it fails, dhclient exitswith exit code two.
The DHCP client normally gets its configuration information from/etc/dhclient.conf,its lease database from/var/lib/dhcp/dhclient.leases,stores its process ID in a file called/var/run/dhclient.pid,and configures the network interface using/sbin/dhclient-scriptTo specify different names and/or locations for these files, use the-cf,-lf,-pfand-sfflags, respectively, followed by the name of the file. This can beparticularly useful if, for example,/var/lib/dhcpor/var/runhas not yet been mounted when the DHCP client is started.
The DHCP client normally exits if it isn't able to identify anynetwork interfaces to configure. On laptop computers and othercomputers with hot-swappable I/O buses, it is possible that abroadcast interface may be added after system startup. The-wflag can be used to cause the client not to exit when it doesn't findany such interfaces. Theomshell (8)program can then be used to notify the client when a network interfacehas been added or removed, so that the client can attempt to configure an IPaddress on that interface.
The DHCP client can be directed not to attempt to configure any interfacesusing the-nflag. This is most likely to be useful in combination with the-wflag.
The client can also be instructed to become a daemon immediately, ratherthan waiting until it has acquired an IP address. This can be done bysupplying the-nwflag.
The syntax of the dhclient.conf
(5) file is discussed separately.
The DHCP client provides some ability to control it while it isrunning, without stopping it. This capability is provided using OMAPI,an API for manipulating remote objects. OMAPI clients connect to theclient using TCP/IP, authenticate, and can then examine the client'scurrent status and make changes to it.
Rather than implementing the underlying OMAPI protocol directly, userprograms should use the dhcpctl API or OMAPI itself. Dhcpctl is awrapper that handles some of the housekeeping chores that OMAPI doesnot do automatically. Dhcpctl and OMAPI are documented in dhcpctl(3)and omapi(3). Most things you'd want to do with the client canbe done directly using the omshell(1) command, rather thanhaving to write a special program.
THE CONTROL OBJECT
The control object allows you to shut the client down, releasing allleases that it holds and deleting any DNS records it may have added.It also allows you to pause the client - this unconfigures anyinterfaces the client is using. You can then restart it, whichcauses it to reconfigure those interfaces. You would normally pausethe client prior to going into hibernation or sleep on a laptopcomputer. You would then resume it after the power comes back.This allows PC cards to be shut down while the computer is hibernatingor sleeping, and then reinitialized to their previous state once thecomputer comes out of hibernation or sleep.
The control object has one attribute - the state attribute. To shutthe client down, set its state attribute to 2. It will automaticallydo a DHCPRELEASE. To pause it, set its state attribute to 3. Toresume it, set its state attribute to 4.
FILES/sbin/dhclient-script,/etc/dhclient.conf, /var/lib/dhcp/dhclient.leases, /var/run/dhclient.pid,/var/lib/dhcp/dhclient.leases~.
(8), dhclient-script (8), dhclient.conf
has been written for the Internet Software Consortiumby Ted Lemon in cooperation with VixieEnterprises. To learn more about the Internet Software Consortium,seehttp://www.isc.org
To learn more about VixieEnterprises, seehttp://www.vix.com.
This client was substantially modified and enhanced by Elliot Pogerfor use on Linux while he was working on the MosquitoNet project atStanford.
The current version owes much to Elliot's Linux enhancements, butwas substantially reorganized and partially rewritten by Ted Lemonso as to use the same networking framework that the Internet SoftwareConsortium DHCP server uses. Much system-specific configuration codewas moved into a shell script so that as support for more operatingsystems is added, it will not be necessary to port and maintainsystem-specific configuration code to these operating systems - instead,the shell script can invoke the native tools to accomplish the samepurpose.
- COMMAND LINE
- THE CONTROL OBJECT
- SEE ALSO
This document was created byman2html,using the manual pages.