How to setup a DHCP client in Solaris

Setting up a Solaris system as a DHCP client is fairly straight forward, it's just a matter of setting up files on your system...

The Basics

Firstly, confirm that each NIC you want to setup connects to the network and has a file /etc/hostname.<interface> associated with it. If not create the file association. For example:

# touch /etc/hostname.hme0

NOTE: hme0 is the interface I wish to setup using DHCP.

If you have more than one network interface associated with the system then a /etc/hostname.<interface> file must be created for each interface you wish to use.

The daemon dhcpagent is the DHCP client that runs on the Solaris OS. With this in place we can simply create an associated DHCP file for the interface we wish to use for DHCP. For example:

# touch /etc/dhcp.hme0

NOTE: Again, hme0 is the interface I wish to associate with DHCP.

If you have more than one network interface and if each of these receive an ip address from DHCP servers, then a /etc/dhcp.<interface> file must be created for each of them.

This should make your Solaris system a DHCP client ready to receive it's IP address from the DHCP Servers.

When you reboot your system, the interface will be dynamically configured.

To bring up the interface using DHCP without rebooting, we can use the following commands:

ifconfig <interface> plumb
ifconfig <interface> dhcp start

For example:

# ifconfig hme0 plumb
# ifconfig hme0 dhcp start

The following command can be used to display the DHCP lease information:

ifconfig <interface> dhcp status

For example:

# ifconfig hme0 dhcp status

Likewise, the following command can be used to release the DHCP lease:

ifconfig <interface> dhcp release
# ifconfig hme0 dhcp release

Simple tuning

Example 1 — DHCP wait time
By default, the system waits for upto 30 seconds for the DHCP Server to respond. However, this can be modified by entering the wait time in the /etc/dhcp.<interface> file. For exmaple, if I decide to let my solaris system wait for 60 seconds then enter the wait time as follows:

# cat /etc/dhcp.hme0
wait 60

Example 2 — Setting primary interface
If it is a primary interface then this can be mentioned as follows:

# cat /etc/dhcp.hme0
wait 60

NOTE: Setting the primary keyword in the dhcp file can also be useful if your primary NIC has failed, by adding this entry to the next NIC forces the dhcpagent to focus on this interface first.

Editing "dhcpagent" configuration

By default the dhcpagent will request the following from the DHCP server:

    · Subnet Mask
    · Default Router
    · DNS Server
    · Hostname
    · DNS Domain Name
    · Broadcast Address
    · Encapsulated Vendor Options

This configuration is stored in /etc/default/dhcpagent. For example:

# cat /etc/default/dhcpagent

The above line defines what is being requested from the DHCP Server. The following table lists each paramter used:

Table 1 — DHCP Client Parameters
value comment
1Subnet Mask
3Default Router
6DNS Server
15DNS Domain Name
28Broadcast Address
43Encapsulated Vendor options (vendor specific information as desribed in RFC 2132)

If you decide to not request for any of the above parameters then all you need to do is to remove the corresponding number from the PARAM_REQUEST_LIST.

For example — No hostname request
If you do not want to request for the "Hostname" from the DHCP server, then simply remove the parameter "12" so it looks as follows:


After making you changes, simply save the file. Once the system restarts the hostname is not requested from the DHCP server.