DHCP mini-HOWTO
vuksan@veus.hr
Revision HistoryRevision v4.12October 22, 2000Revised by: vv
This document attempts to answer basic questions on how to
set up your Linux box to serve as a DHCP server or a DHCP client.
----; Table of Contents; 1. Introduction: ; 1.1. Standard Disclaimer; 1.2. New Versions of this Document; 1.3. Feedback; 1.4. Contributors; 1.5. Copyright Information; 2. DHCP protocol; 3. Client Setup: ; 3.1. Downloading the client daemon (dhcpcd); 3.2. Slackware; 3.3. !RedHat 6.x and Mandrake 6.x; 3.4. !RedHat 5.x; 3.5. !RedHat 4.x and Caldera !OpenLinux 1.1/1.2; 3.6. Debian; 3.7. LinuxPPC and !MkLinux?; 3.8. Tying it all together; 3.9. Various notes; 3.10. Troubleshooting; 3.11. Alternative DHCP client (ISC dhclient); 4. DHCP Server Setup: ; 4.1. DHCP server for UNIX; 4.2. DHCP server configuration; 4.3. Options for DHCPd; 4.4. Starting the server; 4.5. Other interesting documents
No liability for the contents of this documents can be accepted. Use the concepts, examples and other content at your own risk. As this is a new edition of this document, there may be errors and inaccuracies, that may of course be damaging to your system. Proceed with caution, and although this is highly unlikely, I don't take any responsibility for that.
Also bear in mind that this is NOT official information. Much content in this document are assumptions, which appear to work for people. Use the information at your own risk.
New versions of this document are available from
http://www.oswg.org/oswg-nightly/DHCP.html
Following translations of the DHCP mini-HOWTO are available:
*
Chinese - http://www.linux.org.tw/CLDP/mini/DHCP.html
* *
Japanese - http://www.linux.or.jp/JF/JFdocs/DHCP.html
* *
Spanish - ftp://cuates.pue.upaep.mx/pub/linux/LuCAS/DHCP-mini-Como/
*
Permission is hereby granted to all individuals who want to translate the document into their own language. I would only ask that you provide a link back to this document and inform me of a URL to your translation so I can include a link to it.
Feedback is most certaintly welcome for this document. Without your submissions and input, this document wouldn't exist. So, please post your additions, comments and criticisms to `vuksan-feedback@veus.hrb.
This document has been modified from the original version by Paul Makeev.
The following people have contributed to this mini-HOWTO.
*
Heiko Schlittermann
* *
Jonathan Smith
* *
Dan Khabaza
* *
Hal Sadofsky
* *
Henrik Stoerner
* *
Paul Rossington
* *
numerous others
This document is copyrighted (c) 1998 Vladimir Vuksan and distributed under the terms of the !OpenContent? License (OPL). Full text of the license can be found at
http://www.opencontent.org/opl.shtml
DHCP is Dynamic Host Configuration Protocol. It is used to
control vital networking parameters of hosts (running clients)
with the help of a server. DHCP is backward compatible with
BOOTP. For more information see RFC 2131 (old RFC 1541) and
other. (See Internet Resources section at the end of the
document). You can also read
http://web.syr.edu/jmwobus/comfaqs/dhcp.faq.html.
This mini-HOWTO covers both the DHCP SERVER daemon as well as DHCP CLIENT daemon. Most people need the client daemon which is used by workstations to obtain network information from a remote server. The server daemon is used by system administrators to distribute network information to clients so if you are just a regular user you need the CLIENT daemon.
Currently there are three different DHCP client programs for Linux, dhcpcd, pump and dhclient. This mini-HOWTO deals primarily with dhcpcd.
Depending on your distribution you might have to download the DHCP client daemon. If you want to compile it from the source you package you need is called dhcpcd and the current version is 1.3.18. It is maintained by Sergei Viznyuk `sergei@phystech.comb and today it comes as a binary package with most distributions.
dhcpcd source can be downloaded from following locations
*
ftp://ftp.phystech.com/pub/ (Primary site)
* *
http://www.cps.msu.edu/dunham/out/
*
Then follow the instructions below. They should be the same.
You can download the latest copy of the DHCPcd from any Metalab mirror or following:
*
ftp://metalab.unc.edu/pub/Linux/system/network/daemons
* *
ftp://ftp.phystech.com/pub/ (Primary site)
*
Download the latest version of dhcpcd.tar.gz.
*
Unpack it
tar -zxvf dhcpcd-1.3.18pl1.tar.gz
* *
cd into the directory and make dhcpcd
cd dhcpcd-1.3.18pl1
make
* *
Install it (you have to run the following command as root)
make install
*
This will create the directory /etc/dhcpc where DHCPcd will store the DHCP information and dhcpcd file will be copied into /usr/sbin.
In order to make the system initialize using DHCP during boot type:
cd /etc/rc.d
mv rc.inet1 rc.inet1.OLD
This will move the old network initialization script into rc.inet1.OLD. You now need to create the new rc.inet1 script. Following code is all you need:
#
HOSTNAME=`cat /etc/HOSTNAME` #This is probably not necessary but I
/sbin/ifconfig lo 127.0.0.1 /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
/usr/sbin/dhcpcd
Save it and reboot your computer.
When you are finished go the last step.
DHCPcd configuration under !RedHat 6.0+ is really easy. All you need to do is start the Control Panel by typing control-panel.
*
Select "Network Configuration"
* *
Click on Interfaces
* *
Click Add
* *
Select Ethernet
* *
In the Edit Ethernet/Bus Interface select "Activate interface at boot time" as well as select "DHCP" as "Interface configuration protocol"
*
Please note that in !RedHat 6.x Redhat as default includes a DHCP client called pump instead of above mentioned dhcpcd. CD-ROM does include dhcpcd RPM so if you have no luck with pump try with dhcpcd. After you install dhcpcd (e.g. rpm -i dhcpcd-1.3.17pl2-1.i386.rpm) you will have to make some changes.
Additional notes from Alexander Stevenson `alexander.stevenson@home.comb:
I had no luck with DHCPcd. What finally worked for me was "pump", which comes with Linux Mandrake 6.0 (and so I assume it is included with
pump -i eth0 -h hostname
It didn't matter what "hostname" was, but without it the server would not respond.
I then changed the line in my /sbin/ifup script to reflect the change; the default version does not have the -h switch, and so didn't work for me.
Basically, if you're using linuxconf, and after setting the adapter to "DHCP" it still doesn't work, try adding a "-h hostname" to the pump line in the /sbin/ifup script. My script now looks like this:
... if [ -n "$PUMP"?; then echo -n "Determining IP information for $DEVICE..." if /sbin/pump -i $DEVICE -h hostname; then echo " done." else echo " failed." exit 1 fi else ...
Another more elegant way to add hostname field is provided by Aad van der Klaauw:
Currently i'm configuring a gateway system at home, needed to set the MAC address and use the '-h hostname' workaround. So I decided to not change the script but to use the configure file. In my /etc/sysconfig/network-scripts/ifcfg-eth0 I have added the following
DEVICE="eth0" MACADDR="00:11:22:33:44:55" DHCP_HOSTNAME="trigger_for_terayon"
Which will survive upgrades, and is imho a "cleaner" way.
That is it. Reboot your machine or type /sbin/ifup eth0 on the command line.
DHCPcd configuration under !RedHat 5.0+ is really easy. All you need to do is start the Control Panel by typing control-panel.
*
Select "Network Configuration"
* *
Click on Interfaces
* *
Click Add
* *
Select Ethernet
* *
In the Edit Ethernet/Bus Interface select "Activate interface at boot time" as well as select "DHCP" as "Interface configuration protocol"
*
When you are finished go the last step.
DHCPcd is included in the standard !RedHat distribution as an RPM and you can find it on your distribution's CD-ROM in RPMS directory or you can download it from:
ftp://ftp.redhat.com/pub/redhat/redhat-4.2/i386/!RedHat/RPMS/dhcpcd-0.6-2.i386.rpm
Install it with rpm -i dhcpcd-0.6-2.i386.rpm.
Alternatively you can compile your own version by following the steps outlined in the Slackware.
The following information was provided to me by nothing `nothing@cc.gatech.edub.
Removed my static ip and name from /etc/resolv.conf. However, I did leave in the search line and my two nameserver lines (for some reason my dhcpcd never creates a /etc/dhcpc/resolv.conf, so I have to use a static /etc/resolv.conf).
In /etc/sysconfig/network I removed the HOSTNAME and GATEWAY entries. I left the other entries as is (NETWORKING, DOMAINNAME, GATEWAYDEV).
In /etc/sysconfig/network-scripts/ifcfg-eth0 I removed the IPADDR, NETMASK, NETWORK, and BROADCAST entries. I left DEVICE and ONBOOT as is. I changed the BOOTPROTO line to BOOTPROTO=dhcp.
Save the file. Reboot your computer.
When you are finished go the last step.
There is a deb package of DHCPcd (make sure it starts with dhcpcd) at:
http://ftp.debian.org/debian/dists/slink/main/binary-i386/net/
Or, follow the Slackware installation instructions.
To unpack the deb package type dpkg -i /where/ever/your/debian/packages/are/dhcpcd*deb.
It appears that there isn't a need for any DHCPcd configuration because:
The dhcpcd package installs it's startup script as usual for debian packages in /etc/init.d/package_name, here as /etc/init.d/dhcpcd, and links this to the various /etc/rc?.d/ directories.
--From: Heiko Schlittermann
`heiko@os.inf.tu-dresden.deb
The contents of the /etc/rc?.d/ dirs is then executed at boot time.
If you don't reboot after installing you should consider starting the daemon manually: /etc/init.d/dhcpcd start.
When you are finished go the last step.
Following section has been written by R. Shapiro
As of the "1999" (R5) release, Linuxppc is now almost completely compatible with Redhat 6, with one caveat (see below). In general the instructions are exactly the same as for the current release of !RedHat 6.x and Mandrake 6.x.
The remaining problem is that Redhat 6 uses the 'pump' client for dhcp by default, and 'pump' doesn't work reliably in Linuxppc. To get around this, you should install the latest dhcpcd from Sergei Viznyuk, and then edit /sbin/ifup to use dhcpcd instead of pump.
Change
if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp?; then PUMP=true fi if [ -n "$PUMP"?; then
with
if [ "$BOOTPROTO" = bootp?; then
echo " done." else echo " failed." exit 1 fi elif [ "$BOOTPROTO" = dhcp?; then echo -n "Determining IP information for $DEVICE..." if /sbin/dhcpcd -d $DEVICE ; then if [ -f /etc/dhcpc/dhcpcd-${DEVICE}.exe?; then /etc/dhcpc/dhcpcd-${DEVICE}.exe fi
and a coresponding changes for ifdown. Change
if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp?; then .... fi
with
if [ "$BOOTPROTO" = bootp?; then fi if [ "$BOOTPROTO" = dhcp?; then if [ -f /var/run/dhcpcd-${DEVICE}.pid?; then kill `cat /var/run/dhcpcd-${DEVICE}.pid` rm -f /var/run/dhcpcd-${DEVICE}.pid fi fi
A working ppc rpm for dhcpcd is included on the Linuxppc 1999 cd; a
slightly later rpm is available in the contrib directory on
ftp://ftp.linuxppc.org/.
Sources, which compile out of the box in Linuxppc 1999, are available
from
ftp://ftp.phystech.com/pub/dhcpcd-1.3.17-pl9.tar.gz.
After your machine reboots your network interface should be configured. Type: ifconfig.
lo Link encap:Local Loopback
inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1 RX packets:302 errors:0 dropped:0 overruns:0 frame:0 TX packets:302 errors:0 dropped:0 overruns:0 carrier:0 coll:0 eth0 Link encap:Ethernet HWaddr 00:20:AF:EE:05:45 inet addr:24.128.53.102 Bcast:24.128.53.255 Mask:255.255.254.0 ^^^^^^^^^^^^^^^^^^^^^^^ UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 RX packets:24783 errors:1 dropped:1 overruns:0 frame:1 TX packets:11598 errors:0 dropped:0 overruns:0 carrier:0 coll:96 Interrupt:10 Base address:0x300
If you have some normal number under inet addr you are set. If you see 0.0.0.0 don't despair, it is a temporary setting before dhcpcd acquires the IP address. If even after few minutes you are seeing 0.0.0.0 please check out Troubleshooting. DHCPcd is a daemon and will stay running as long as you have your machine on. Every three hours it will contact the DHCP server and try to renew the IP address lease. It will log all the messages in the syslog (on Slackware /var/adm/syslog, !RedHat/!OpenLinux /var/log/syslog).
One final thing. You need to specify your nameservers. There are two ways to do it, you can either ask your provider to provide you with the addresses of your name server and then put those in the /etc/resolv.conf or DHCPcd will obtain the list from the DHCP server and will build a resolv.conf in /etc/dhcpc.
I decided to use DHCPcd's resolv.conf by doing the following:
Back up your old /etc/resolv.conf: mv /etc/resolv.conf /etc/resolv.conf.OLD
If directory /etc/dhcpc doesn't exist create it: mkdir /etc/dhcpc
Make a link from /etc/dhcpc/resolv.conf to /etc/resolv.conf: ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
If that doesn't work try this (fix suggested by `nothing@cc.gatech.edub with a little amendment by Henrik Stoerner):
This last step I had to perform only because my dhcpcd doesn't create an /etc/dhcpc/resolv.conf. In /etc/sysconfig/network-scripts/ifup I made the following changes (which are a very poor hack, but they work for me):
elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no?; then echo -n "Using DHCP for ${DEVICE}... " /sbin/dhcpcd -c /etc/sysconfig/network-scripts/ifdhcpc-done ${DEVICE} echo "echo \$$ b /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh if [ -f /var/run/dhcp-wait-${DEVICE}.pid?; then ^^^^ echo "failed." exit 1
I changed to:
elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no?; then echo -n "Using DHCP for ${DEVICE}... " /sbin/dhcpcd echo "echo \$$ b /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh if [ ! -f /var/run/dhcp-wait-${DEVICE}.pid?; then ^^^^^^ echo "failed." exit 1
Note: Notice the ! (bang) in if
lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual
lib/InlineParser.php:336: Warning: Invalid [] syntax ignored: [[ ! -f
lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual