Professional Documents
Culture Documents
This document provides a simple guide to configuring a Solaris system as a DHCP server
using the software supplied with the operating system. The command line interface is
used thoughout, no reference made to the Sun's GUI tool 'dhcpmgr'. This procedure was
performed on a Solaris 9 system, though it is likely also applicable to Solaris 7 & 8.
The dhcp server setup here serves a single network, makes no effort to register names in
any naming service, and does not enable BOOTP.
Packages
You should have the 3 basic DHCP packages installed;
Procedure
1. Create basic DHCP configuration and dhcptab files
2. Create a macro for the local network
3. Create the local network table
4. Add some entries to the network table
5. Start the DHCP server
Use dhcpconfig to setup dhcpsvc.conf and dhcptab, here we simply define the type of
datastore (SUNWfiles = text files) and the location of datafiles;
Here we create a macro for our local network ( the one we will serve IP addresses for) in
dhcptab
# dhtadm -A -m 192.9.200.0 -d
':Broadcst=192.9.200.255:Subnet=255.255.255.0:MTU=1500:'
Here we define three local IP address that will be leased out by the dhcp server...
Use the standard init.d boot script and watch /var/adm/messages for problems;
# sh /etc/init.d/dhcp start
If you have problems stop the daemon and run it manually with the debug & verbose
options;
# /usr/lib/inet/in.dhcpd -dv
3fe143d6: Daemon Version: 3.5
3fe143d6: Maximum relay hops: 4
3fe143d6: Run mode is: DHCP Server Mode.
3fe143d6: Datastore resource: SUNWfiles
What is DHCP?
DHCP is used to automatically configure network parameters on client workstations.
Whilst it can be used to configure any and every known network parameter it is typically
used simply to automatically allocate IP addresses and deliver static information such as
the addresses of network routers and DNS servers.
Introduction
One of the problems that can arise when trying to use a Solaris box as a DHCP
client is that by default, the server is expected to supply a hostname, in addition
to all the other stuff (like IP address, DNS servers, etc.). Most cable modems and
home routers don't supply a (usable) hostname, so it gets set to "unknown". This
page describes how to get around that. (Where this page says "cable modem",
"DSL modem" can be substituted.)
This page assumes that le0 is the interface you using for your DHCP connection.
Substitute hme0 or whatever interface you're actually using in the examples below.
Setting up DHCP
There are two ways of using DHCP:
• DHCP has limited control
• DHCP has full control
The first case may be where you want to use your own /etc/resolv.conf and so
on, with a minimum of hassle.
The second case would be the normal situation, especially if your cable modem
provider has a habit of changing DNS name server IP addresses on you (like
mine does!), so I'll concentrate on that here. I have a script to automate the first
method, should you want to use it. You'll need to change the DEFAULT_ADDR and
INTERFACE variables as required.
The first thing to do is to create an empty /etc/hostname.le0, like this:
> /etc/hostname.le0
Creating this file ensures that the interface gets plumbed, ready for the DHCP
software to do its stuff.
Next, you create /etc/dhcp.le0. This file can be empty if you want to accept the
defaults, but may also contain one or both of these directives:
• wait time, and
• primary
By default, ifconfig will wait 30 seconds for the DHCP server to respond (after
which time, the boot will continue, while the interface gets configured in the
background). Specifying the wait directive tells ifconfig not to return until the
DHCP has responded. time can be set to the special value of forever, with
obvious meaning. I use a time value of 300, which seems to be long enough for
my cable provider.
The primary directive indicates to ifconfig that the current interface is the
primary one, if you have more than one interface under DHCP control. If you only
have one interface under DHCP control, then it is automatically the primary one,
so primary is redundant (although it's permissible).
With these files in place, subsequent reboots will place le0 under DHCP control:
you're ready to go!
Unknown hostname
Actually, there's one snag: most (if not all) cable modem DHCP servers don't
provide you with a hostname (even if they did, odds are it won't be one you want
anyway!). This wouldn't be a problem, except that the boot scripts
(/etc/init.d/rootusr in particular) try to be clever, and set your hostname to
"unknown" in this case, which is not at all useful!
The trick is to change your hostname back to the right one, preferably without
changing any of the supplied startup scripts, which are liable to be being
stomped on when you upgrade or install a patch. You've also got to do it early
enough in the boot process, so that rpcbind, sendmail and friends don't get
confused by using the wrong hostname. To solve this problem, put this little script
in to /etc/init.d/set_hostname, with a symbolic link to it from
/etc/rc2.d/S70set_hostname.
Starting with Solaris 10, the preceding paragraph can be ignored. Instead, just
make sure that the hostname you want to use is in /etc/nodename; the contents
of that file will then be used to set the hostname. (Note that it is essential that the
hostname you put into /etc/nodename is terminated with a carriage return.
Breakage will happen if this is not the case.) Also, from Solaris 8 it is possible to
tell the DHCP software not to request a hostname from the DHCP server. To do
this, remove the token 12 from the PARAM_REQUEST_LIST line in
/etc/default/dhcpagent. (/etc/default/dhcpagent describes what the default
tokens are; 12 is the hostname, 3 is the default router, 6 is the DNS server, and
so on.)
With these modifications in place, reboot, and you'll be using your cable modem
in no time!
If you've got more than one machine, and you want to access the Internet from all
of them, you might also find my Solaris NAT page useful.
If this page has been useful to you, please consider buying a copy of my book,
Solaris Systems Programming.