日期:2014-05-16 浏览次数:20750 次
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.
linux dhclient 的语法
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 [ ...ifN ] ]
-p port If the DHCP client should listen and transmit on a port other
than the standard (port 68), the -p flag may used. It should be
followed by the udp port number that dhclient should 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 should
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 should
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 would 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 notify
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 particularly 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
notify 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