Whole document tree 3. Client SetupCurrently there are three different DHCP client programs for Linux, dhcpcd, pump and dhclient. This mini-HOWTO deals primarily with dhcpcd. 3.1. Downloading the client daemon (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.com> and today it comes as a binary package with most distributions. dhcpcd source can be downloaded from following locations Then follow the instructions below. They should be the same. 3.2. SlackwareYou can download the latest copy of the DHCPcd from any Metalab mirror or following: Download the latest version of dhcpcd.tar.gz.
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:
Save it and reboot your computer. When you are finished go the last step. 3.3. RedHat 6.x and Mandrake 6.xDHCPcd configuration under RedHat 6.0+ is really easy. All you need to do is start the Control Panel by typing control-panel.
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.com>: 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 RedHat as well). The command I used was: 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:
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
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. 3.4. RedHat 5.xDHCPcd configuration under RedHat 5.0+ is really easy. All you need to do is start the Control Panel by typing control-panel.
When you are finished go the last step. 3.5. RedHat 4.x and Caldera OpenLinux 1.1/1.2DHCPcd 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.edu>.
When you are finished go the last step. 3.6. DebianThere 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 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. 3.7. LinuxPPC and MkLinuxFollowing 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
with
and a coresponding changes for ifdown. Change
with
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. 3.8. Tying it all togetherAfter your machine reboots your network interface should be configured. Type: ifconfig. You should get something like this:
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.edu> 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):
I changed to:
Now sit back and enjoy :-). 3.9. Various notesFollowing step(s) are not necessary but might be useful to some people:
3.10. TroubleshootingIf you have followed the steps outlined above and you are unable to access the network there are several possible explanations: 3.10.1. Your network card is not configured properlyDuring the boot up process your Linux will probe your network card and should say something along these lines:
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). 3.10.2. Your DHCP server supports RFC 1541/My DHCP server is Windows NTTry 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) If this solves your problem add the "-r" flag to the boot up scripts, ie: instead of /sbin/dhcpcd you will have /sbin/dhcpcd -r. For example under RedHat edit script /etc/sysconfig/network-scripts/ifup and change the following:
3.10.3. 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 carefully :-). You are missing the ! (bang) in one of the if statements. Jump here and check how to fix it. 3.10.4. My network works for few minutes and then stops respondingThere are some reports of gated (gateway daemon) screwing up routing on Linux boxes which results in problem described above. Check if gated is running with: ps -auxww | grep gate. If it is try removing it with RedHat's RPM manager or removing the entry in /etc/rc.d/. 3.10.5. My ethernet card is recognized during boot up but I still get "NO DHCPOFFER" message in my logs. I also happen to have a PCMCIA ethernet card.You need to make sure that you have the 10BaseT port ("phone" plug) on your network card activated. Best way to verify it is to check what kind of connector your card is configured for during bootup e.g.
I have received reports of laptop users having this kind of problems due to the PCMCIA utilities (specifically ifport) that would set the connector type to 10Base2 (thinnet). You have to make sure you use 10BaseT for your connection. If you are not reconfigure the card and restart the computer. 3.10.6. My DHCP client broadcasts requests but no one answers (Contributed by Peter Amstutz)On some systems, you need to include some hostname for your machine as part of the request. With dhcpcd, do this with dhcpcd -h foohost Probably the hostname wanted will be your account username on the network. 3.10.7. I have followed all the steps but still my machine is not able to connectThe cable modem will usually memorize the ethernet address of your network card so if you connect a new computer or switch network cards you will somehow have to "teach" your cable modem to recognize the new computer/card. Usually you can turn of the modem and bring it back up while computer is on or you will have to call tech support and tell them that you have changed a network card in the computer. You have firewall rules (ipfwadm rules) that disallow port 67/68 traffic used by DHCP to distribute configuration info. Check your firewall rules carefully. 3.10.8. I have MediaOne Express service and I still can't connect.It appears that MediaOne has been using adding some things to DHCP that shouldn't be there. Supposedly this is not a problem anymore but if you experience outages check for these things. If you are (un)lucky to have Windows NT on your machine if you go into Event Viewer you will see a warning like this:
If this is the problem go to ftp://vanbuer.ddns.org/pub/ and either download a binary or get the source for the change. 3.11. Alternative DHCP client (ISC dhclient)If you have not had success getting your Linux connection running with the dhcpcd you might want to try ISC dhclient. dhclient comes with the DHCP distribution from ISC which includes both a DHCP client and a DHCP server. Instructions on how to get and compile the DHCP distribution can be found here. When you are done with it please return to this section to configure the client.
With the current version of the DHCP client, you don't actually need a dhclient.conf. All you have to do is invoke dhclient e.g.: /sbin/dhclient. This will configure all broadcast interfaces. If this doesn't work or you want to specify only one interface create a /etc/dhclient.conf file with this example configuration.
Here we assume that the ethernet interface is eth0. If not change accordingly. Also replace xx:xx:xx:xx:xx with your ethernet address. This dhclient.conf makes the client look more like a Win95 client. |