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.
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.65. The description of the package reads:
Title: dhcpcd Version: 0.65 Entered-date: 05MAY97 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.65 works fine with the following DHCP servers: 1. ISC's dhcpd-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 the Time Warner Cable's Internet Access Service 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.65.tar.gz Alternate-site: sunsite.unc.edu:/pub/Linux/system/network/daemons 33kB dhcpcd-0.65.tar.gz Original-site: Platforms: Linux 1.2.xx, 1.3.xx, 2.0.x Copying-policy: GPL Note: Support for Bell Atlantic ADSL modems has been announced for version 0.7.
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.65.tar.gz
cd dhcpcd-0.65 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)
#################################
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 else rm -f /var/run/dhcp-wait-${DEVICE}.pid echo "done." IPSETUP=yes fi fi################################# I changed to:
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 # else # rm -f /var/run/dhcp-wait-${DEVICE}.pid # echo "done." IPSETUP=yes # fi fi#################################
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:
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.govIf 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 gotten 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).
II. Your DHCP server supports RFC 1541
Try running dhcpcd by typing
dhcpcd -r
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)
Thanks to all the people that contributed with their ideas and suggestions:
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)