The dhclient Program


The dhclient Program

The dhclient program is the client portion of DHCP. It is run automatically at each system boot if you have any network interfaces that are configured to use DHCP.

Command-Line Options for dhclient

If you need to modify the default behavior of dhclient, you can do so by supplying flags to it with an option in /etc/rc.conf. This option should appear below the ifconfig line where the DHCP interface is configured:

dhcp_flags="flags"


Here, flags is a list of options for dhclient, which are passed to the program as though it were being invoked at the command line. Table 35.1 shows the valid options that can be used.

Table 35.1. Valid Options for dhclient

Option

Action

-d

This option will force dhclient to stay in the foreground rather than move to the background after it gets its configuration information. This should be used only for debugging purposes and should probably never be used in /etc/rc.conf.

-q

This option tells dhclient to be quiet when it runs (in other words, it won't print messages except in error conditions).

-1

This option causes dhclient to try only once to get a lease on an IP address. If this fails, dhclient will exist with a status of 2. Note that this is the numeral 1 and not a lowercase letter I.


The dhclient.conf File

/etc/dhclient.conf is the configuration file for dhclient in which you can specify various options beyond the simple behavior switches available at the command line or in rc.conf. The file must exist for dhclient to run, although by default, the file contains nothing but comments. dhclient has reasonable default values that will work fine in most typical circumstances, so most users will not have to worry about this file.

However, you should be aware of some of the options that can be controlled in this file. Table 35.2 lists some of them.

Table 35.2. Some dhclient.conf Options

Option

Action

timeout n

Here, n is the number of seconds dhclient should wait for a response when trying to contact a DHCP server before giving up and deciding the server is unavailable. By default, this is 60 seconds.

retry n

Here, n is the number of seconds dhclient should wait before trying to contact the DHCP server again if the first request timed out. By default, it will wait five minutes.

select-timeout n

Some networks may have more than one DHCP server on them. In this case, the client may receive multiple offers of configuration information. The first offer received is not always the best offer (for example, if the second offer received contains the same IP address the client was using in a previous session, it is preferable to an offer where the IP address is different). Here, n is the number of seconds dhclient should wait after receiving a first offer to see whether any other servers respond with offers.

reboot n

When dhclient starts, it will try to obtain the same IP address it had the last time. If it cannot get the same address, it will then accept a different one. Here, n is the number of seconds dhclient will wait before giving up and deciding it can't get the same IP address it had last time. The default is 10 seconds.

request option

The client will request information for the specified options from the DHCP server. See the man dhcp-options page for information on the available options.

require option

The client will require information for the specified options from the DHCP server. If the required information is not provided, the client will reject the offer. See the man dhcp-options page for information on the available options.

default option value

If the DHCP server does not provide information for the specified option, then value will be used for that option. See the man dhcp-options for information on the available options.

supersede option value

The specified option will always use value, even if the DHCP server sends a different value for that option. See the man dhcp-options page for information on the available options.

reject address

Any offers sent from the DHCP server with the IP address of address will be rejected.


Many more options can be used in the /etc/dhclient.conf configuration file. See the man dhclient.conf page for more information on options available in this file. Also, see the man dhcp-options page for more information about the DHCP options that can be requested or required from the DHCP server.

As mentioned previously, most users will not need to make any changes to /etc/dhclient.conf because the default dhclient values will usually work fine except in highly customized DHCP environments.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net