Disclaimer: The information contained herein is NOT official information of any kind and there are no warranties to the accuracy of the data. All information is provided in good faith. Use at your own risk.
This HOWTO explains how to setup your Linux system to work in a DHCP
environment as a client (DHCPcd). If you are looking for a DHCP server you
need to read DHCPd mini-HOWTO at
http://sunsite.unc.edu/LDP/HOWTO/mini/DHCPd.
DHCP is a protocol that allows a client machine
to obtain network information from a server. Many organizations are
starting to use it because it eases network administration especially in
large networks or networks which have lots of mobile users. DHCP is also
being heavily used by cable Internet service provider such as MediaOne
Express, Time Warner etc.
More info about DHCP can be found in
DHCP FAQ.
Dan has provided a patch for it that can be obtained at http://www.cro.net/~vuksan/dhcppatch. To apply it just copy it to the dhcpcd source directory (instruction how to get source are in the following section) and type
patch < dhcppatch
dhcpcd should compile cleanly after the patch has been applied. Note that this patch works only against dhcpcd 0.65 :-(.
Another patch has been provided by Paul Rossington if you have problems with the one above. It is actually the whole if.C file. Get it at http://www.cro.net/~vuksan/if.C and copy it to the dhcpcd source directory.
Other alternative when running 2.1.x kernels is to use dhcpcd 1.3.3 which is a modified version that has been written by Sergei Viznyuk sergei@phystech.com in order to avoid problems with 2.1.x kernels. You can fetch it at:
http://www.cps.msu.edu/~dunham/out/dhcpcd-1.3.3.tar.gz
DHCPcd configuration under RedHat 5.0 is really easy. All you need to do is start the Control Panel by typing
control-panel
Then select "Network Configuration" and under eth0 interface define DHCP as your protocol. Other parameters should be left blank.
If you are trying to run dhcpcd on the Token Ring Network it will not work. This is the solution provided to me by Henrik Stoerner:
The problem is that dhcpcd only knows about Ethernet cards. If it finds a Token-Ring card, it refuses to do anything with it and reports "interface is not ethernet".
The solution is to apply a simple patch to the dhcpcd-0.65 sources. I have put up a small web page with the patch, RedHat RPM-files and a precompiled binary at http://eolicom.olicom.dk/~storner/dhcp/
The patch has been sent to the dhcpcd maintainer, so hopefully it will be included in a future release of dhcpcd.
Step 1) No matter what distribution you are using you will need to download the DHCP client daemon for Linux. The package you need to download is called dhcpcd and the current version is 0.70. The description of the package reads:
Title: dhcpcd Version: 0.70 Entered-date: 05NOV97 Description: dhcpcd is an RFC2131 compliant DHCP client daemon. It gets an IP address and other information from a corresponding DHCP server, configures the network interface automatically, and tries to renew the lease time according to RFC2131. It works in the RFC1541 compliant mode when the '-r' option is specified. So far it is found that dhcpcd 0.70 works with the following DHCP servers: 1. ISC's dhcpcd-BETA-5.15 2. DHCP server on Windows NT server 3.51 3. DHCP server version 1.3b by WIDE project. 4. DHCP server in the SolarNet PC-Admin 1.5 package 5. DHCP server used in Time Warner Cable's Internet Access Service 6. DHCP server used in Bell Atlantic ADSL See the "Changes" file if you want to know the difference from the previous version. Keywords: DHCP, client, Linux Author: yoichi@fore.com (Yoichi Hariguchi) Maintained-by: yoichi@fore.com (Yoichi Hariguchi) Primary-site: ftp.kobe-u.ac.jp /pub/PC-UNIX/Linux/network/dhcp 33kB dhcpcd-0.70.tar.gz Alternate-site: sunsite.unc.edu /pub/Linux/system/Network/daemons 33kB dhcpcd-0.70.tar.gz Original-site: Platforms: Linux 1.2.xx, 1.3.xx, 2.0.x Copying-policy: GPL
You can download the latest copy of the DHCPcd from any sunsite mirror or following:
Download the latest version of dhcpcd.tar.gz
tar -zxvf dhcpcd-0.70.tar.gz
cd dhcpcd-0.70 make
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. Now skip to Step 2
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:
rpm -i dhcpcd-0.6-2.i386.rpm
Alternatively you can compile your own version by following the steps outlined in the Slackware part. When done go to Step 2
There is deb package of DHCPcd at
or you can follow the Slackware installation instructions.
In order to unpack the deb package type
dpkg -i /where/ever/your/debian/packages/are/dhcpd*deb
When done go to Step 2
Following step(s) are depended on your needs.
a) If you need network connectivity only occasionally you can start dhcpcd from the command line (you need to be root to execute it) by typing
/usr/sbin/dhcpcdWhen you need to down (turn off) the network type
/usr/sbin/dhcpcd -k
You now only lack nameservers configuration file (/etc/resolv.conf). For instructions on how to create a resolv.conf go to Step 3
b) If you want (need) network connectivity all the time and would like dhcpcd to start at boot time follow the steps below.
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. It should look as follows:
#!/bin/sh # # rc.inet1 This shell script boots up the base INET system. # # Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93 # HOSTNAME=`cat /etc/HOSTNAME` #This is probably not necessary but I #will leave it in anyways # Attach the loopback device. /sbin/ifconfig lo 127.0.0.1 /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the # eth0 interface. If you're only using loopback or SLIP, don't include the # rest of the lines in this file. /usr/sbin/dhcpcd
Save the above file as rc.inet1. Reboot your computer. Go to Step 3.
This information was provided to me by nothing (nothing@cc.gatech.edu)
Save the file. Reboot your computer and go to Step 3
It appears that there isn't a need for any DHCPcd configuration because:
From: Heiko Schlittermann
The contents of the /etc/rc?.d/ dirs is then executed at boot time.
/etc/init.d/dhcpcd start
Go to Step 3.
Step 3) This step should be the same for all distributions.
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. 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 to the syslog (on Slackware /var/adm/syslog) if you need to check up on it.
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 DHCPcds resolv.conf by doing the following:
mv /etc/resolv.conf /etc/resolv.conf.OLD
mkdir /etc/dhcpc
ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
If that doesn't work try this (fix suggested by nothing@cc.gatech.edu with a little amendment by Henrik Stoerner)
I changed to:
Notice the ! (bang) in
Now sit back and enjoy :-).
If you have followed the steps outlined above and you are unable to access
the network there are several possible explanations:
I. Your network card is not configured properly.
During the boot up
process your Linux will probe your network card and should say something along
these lines:
II. Your DHCP server supports RFC 1541
Try running dhcpcd by typing
Use ifconfig to check if your network interface is configured (wait few seconds
for the configuration process, initally it will say Inet.addr=0.0.0.0)
If this solves your problem add the "-r" flag to the boot up scripts from Step 2)
ie. instead of
III. During bootup I get error message "Using DHCP for eth0 ... failed"
but my system works fine.
You are most likely using RedHat and you haven't followed instructions
acurately :-). You are missing the ! (bang) in one of the if statements Jump back up and read it again.
IV. My network works for few minutes and then stops responding
There are some reports of gated (gateway daemon) screwing up routing on
Linux boxes which results in problem described above. Check if gated is
running
If it is try removing it with RedHat's RPM manager or removing the entry
in /etc/rc.d/
#################################
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 \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
^^^^
echo "failed."
exit 1
#################################
#################################
elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
echo -n "Using DHCP for ${DEVICE}... "
/sbin/dhcpcd
echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
if [ ! -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
^^^^^^
echo "failed."
exit 1
#################################
if [ ! -f /var/run/dhcp-wait-${DEVICE}.pid ];
Troubleshooting
eth0: 3c509 at 0x300 tag 1, 10baseT port, address 00 20 af ee 11 11, IRQ 10.
3c509.c:1.07 6/15/95 becker@cesdis.gsfc.nasa.gov
If a message like this doesn't appear your ethernet card might not be recognized
by your Linux system. If you have a generic ethernet card (a NE2000 clone) you
should have received a disk with DOS utilities that you can use to set up
the card. Try playing with IRQs until Linux recognizes your card (IRQ
9,10,12 are usually good).
dhcpcd -r
/sbin/dhcpcd
you will have /sbin/dhcpcd -r
ps -auxww | grep gate
Thanks to all the people that contributed with their ideas and suggestions. Especially the following:
Heiko Schlittermann (heiko@os.inf.tu-dresden.de)
Jonathan Smith (jps2@ra.msstate.edu)
Dan Khabaza (danyh@iil.intel.com)
Hal Sadofsky (sadofsky@math.uoregon.edu)
Henrik Stoerner (henrik_stoernet@olicom.dk)
Paul Rossington (paulrossington@unn.unisys.com)