dhcp.client

TCP/IP host configuration utility

Note: You must be root to run this utility.

Syntax:

dhcp.client [-abdHkmnRru] [-A num] [-D ident] [-h hostname]
            [-I num] [-i interface] 
            [-P port] [-p port] [-s host]
            [-T secs] [-t num] &

Runs on:

Neutrino

Options:

-A num
The dhcp.client declines addresses if they fail an ARP probe (see RFC 2131 and RFC 5227). This option sets the number of consecutive ARP probe tests of the assigned address that can fail before dhcp.client gives up. The default is 5; a value of 0 turns off ARP probing.
-a
Apply the assigned IP address as an alias instead of overwriting the current configuration.
-b
Request the DHCP server to send its response packets only to the client where appropriate (default is to request the server to broadcast).
-D ident
Specify the client identifier. The default identifier is the MAC address.
-d
Write debugging info to the system log, syslogd.
-H
Don't apply the hostname to the local system, whether supplied by the server or via the -h option. In the latter case, the hostname is still sent to the server via option 12.

The -H option could be useful in cases where the -h option is used to identify the client, and you want to apply a different hostname locally, or you simply want to ignore the server hostname assignment.

-h hostname
Hostname of client (default is supplied by the server if the hostname is available).
-I num
The number of times to poll waiting for interface to be available (default 5). Polling is done every 2 seconds.

You can use this option to make dhcp.client wait until the interface it's to use is available. This is useful in a boot environment when you might not know when the driver is running and registered with the TCPIP stack. The exit status is 2 if no interface is found.

-i interface
The name of the interface to configure (e.g. en0, en1). The default is the first interface found.
-k
Don't set the CS_DOMAIN (Domain Name) configuration string if you're using the -m option.
-m
(QNX Neutrino extension) Instead of writing the domain and nameserver data to /etc/resolv.conf (the default), write the data to the _CS_DOMAIN and _CS_RESOLVE memory configuration-defined values (see confstr() in the Neutrino C Library Reference):
_CS_DOMAIN
Domain name.
_CS_RESOLVE
Nameserver.

If you specify -m and -n together, the domain is added, but the nameservers aren't. If you specify -m and -k, _CS_DOMAIN isn't set.

-n
Don't add the DHCP-supplied nameservers to /etc/resolv.conf or _CS_RESOLVE. If you also specify -m, the domain is added, but the nameservers aren't. If you don't specify -m, neither the domain nor the nameservers are added.
-P port
DHCP server port (default is dhcp port or port 67).
-p port
DHCP client port (default is dhcpc port or port 68).
-R
Don't apply the DHCP-supplied default route. If you specify this option, the default route supplied by the DHCP server isn't applied, but it's still supplied to the dhcp-up script (see below) in case you wish to apply it later.
-r
Add .node_number to the resolv.conf file name. Off by default.
Note: QNX Neutrino ignores the -r option.
-s host
Accept packets from this server only; ignore responses from other servers.
-T sec
Specify the time, in seconds, to wait for the client to complete (server ACK) its negotiation with the server. This is applied every time the client returns to the initialize (DISCOVER) state. If a timeout occurs, dhcp.client terminates with an exit status of 3.
-t num
Attempt to reach the server num times before giving up and terminating (the default is forever). Each attempt lasts 1 minute.

You're likely to use this option in combination with the -u option so that dhcp.client times out after a specified number of attempts.

-u
Don't move dhcp.client to the background until the interface is configured.

This option is useful for spawning dhcp.client. The process doesn't move to the background until it has contacted a server and applied a TCP/IP configuration. The exit status is 3 if no server responds.

Description:

The dhcp.client obtains the TCP/IP configuration parameters dynamically from a DHCP (Dynamic Host Configuration Protocol) server, then automatically configures your TCP/IP host. You don't have to provide an IP address or any configuration parameters, or run any configuration utilities.

Note: This utility needs to have the setuid ("set user ID") bit set in its permissions. If you use mkefs, mketfs, or mkifs on a Windows host to include this utility in an image, use the perms attribute to specify its permissions explicitly, and the uid and gid attributes to set the ownership correctly.

If dhcp.client is terminated, it releases the DHCP address assigned by the server back to the server. If the client is terminated with SIGPWR, the address isn't released; the lease will timeout or be continued at client restart (depending on server policies).

Note: You must start io-pkt* before starting dhcp.client.

The minimum commands to run under QNX Neutrino are:

io-pkt-v4 -dne2000 -ptcpip
if_up -p enx
dhcp.client &
if_up enx

Or:

io-pkt-v4 -dne2000 -ptcpip
dhcp.client -Ix -u

If you wish dhcp.client to apply the IP address as an alias instead of overwriting the currently assigned IP address, you must pass the -a option. This option is useful if you wish to assign multiple IP addresses to an interface. You must pass the -a option if you wish to use dhcp.client and AutoIP (lsm-autoip.so) on the same interface.

By default, dhcp.client searches for an unconfigured interface to provide service. If AutoIP is in use, an unconfigured interface will not be available, and the dhcp.client will terminate. In order for dhcp.client to provide service to an interface that already has an IP address assigned to it, use the -i option (in combination with -a), and the interface will have both a DHCP and AutoIP IP address assigned to it.

This utility obtains and implements the following information from the DHCP server:

/etc/dhcp/dhcp-check

This is an optional script that you can use to see if the DHCP configuration is correct. It should return 0 if the configuration is acceptable, or a non-zero value if it isn't (which results in a DHCPDECLINE).

Environment variables, which contain the configuration that was obtained from the server, are passed to this file. When the file is spawned, it doesn't inherit the full environment. For example, the PATH environment variable isn't available. To determine which variables are available, you can create a script such as this:

#!/bin/sh

env > /tmp/config

The environment definitions are:

INTERFACE
The interface that was configured (e.g. INTERFACE=en0).
IPADDRESS
The client IP address that was obtained from the server (e.g. IPADDRESS=10.0.0.1).
NETMASK
The client netmask that was obtained from the server (e.g. NETMASK=255.0.0.0).
HOSTNAME
The hostname of the client (e.g. HOSTNAME=node1).
BROADCAST
The client broadcast address that was obtained from the server (e.g. BROADCAST=10.255.255.255).
GATEWAY
The gateway that the client is to use (e.g. GATEWAY=10.0.0.2).
SERVER
The DHCP server's ID (IP address) (e.g. SERVER=10.0.0.3).
NAMESERVER1, NAMESERVER2
The nameserver that the client is to use (e.g. NAMESERVER1=10.0.0.4).
LEASEOBTAINED
The time at which the lease was obtained (e.g. LEASEOBTAINED=Mon Oct 30 16:46:10 2000).
LEASEEXPIRES
The time at which the lease expires (e.g. LEASEEXPIRES=Mon Oct 31 16:46:10 2000).
RELAYAGENT
A DHCP relay agent forwards packets between dhcp.client and the DHCP server if they're on different networks. This is the IP address of the relay agent if it's present.
SERVERNAME
The hostname of the DHCP server.
DOMAIN
The domain supplied by the DHCP server to be added to /etc/resolv.conf or CS_DOMAIN (configuration string).
SIADDR
The next server to use in bootstrap. If a FILENAME was supplied, it would be obtained from this server.

The following options are available but not applied by the dhcp.client process:

FILENAME
The filename supplied in the server response (e.g. FILENAME=/bootimg).

Any other options are defined as environment variables OPTIONx, where x is the option number. If the option is known, dhcp.client tries to format it as readable information. If the option isn't known, dhcp.client displays each octet as hexadecimal (e.g. OPTION200= F1 AA 56 42).

Currently, dhcp.client is aware of options 1 to 61.

/etc/dhcp/dhcp-up

If this file exists, it is run after a DHCP server has been contacted and the configuration options above have been applied. This file can be a binary program or a script and must be executable (see chmod). If the file is a script, the first line must be the command interpreter. For example:

#!/bin/sh

The environment is the same as for dhcp-check.

/etc/dhcp/dhcp-options

This file defines the DHCP options that the client wishes to obtain from the DHCP server. You need this file only if you're adding custom DHCP option handling to the /etc/dhcp/dhcp-up file. If you add code to the dhcp-up script to handle an option, you must also add this option to /etc/dhcp/dhcp-options. The options listed in dhcp-options file are sent to the server in addition to the options:

which the dhcp.client process itself includes.

Here's an example of the dhcp-options file:

200
150
#This is a comment
90

Specify each option on its own line, listing them in order of priority. Comments must be on a separate line; they can be up to 80 characters long.

Based on:

RFC 2131

Files:

The dhcp.client utility requires the libsocket.so shared library.

Exit status:

0
Success.
1
An error occurred.
2
No interface was found.
3
No server responded.

Errors:

Errors that occur during configuration are reported to the system log.