home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / doc / HOWTO / mini / DHCPcd < prev    next >
Text File  |  1997-10-13  |  13KB  |  576 lines

  1.  
  2. How to setup Linux as DHCP client
  3.  
  4.    
  5.    
  6.    
  7.      _________________________________________________________________
  8.    
  9.    
  10.    
  11.    _Disclaimer:_ The information contained herein is NOT official
  12.    information of any kind and there are no warranties to the accuracy of
  13.    the data. All information is provided in good faith. Use at your own
  14.    risk.
  15.    
  16.    
  17.      _________________________________________________________________
  18.    
  19.    Vladimir Vuksan, vuksan@veus.hr
  20.    v 2.1, Last revised: October 11th, 1997
  21.    
  22.   Introduction
  23.   
  24.    
  25.    
  26.    This HOWTO explains how to setup your Linux system to work in a DHCP
  27.    environment as a client (DHCPcd). If you are looking for a DHCP server
  28.    you need to read DHCPd mini-HOWTO at
  29.    http://sunsite.unc.edu/LDP/HOWTO/mini/DHCPd. DHCP is a protocol that
  30.    allows a client machine to obtain network information from a server.
  31.    Many organizations are starting to use it because it eases network
  32.    administration especially in large networks or networks which have
  33.    lots of mobile users. DHCP is also being heavily used by cable
  34.    Internet service provider such as MediaOne Express, Time Warner etc.
  35.    More info about DHCP can be found in DHCP FAQ.
  36.    
  37.   Road Runner Service
  38.   
  39.    If you have Road Runner cable service check out
  40.    http://people.qualcomm.com/karn/rr/index.html. If that doesn't solve
  41.    your problem try following.
  42.    
  43.   2.1.x kernels
  44.   
  45.    If you are running a > 2.1.30 kernel (don't remember the exact number
  46.    and www.linuxhq.com is down currently) you might encounter a problem
  47.    with the dhcpc. According to Dan Khabaza:
  48.    _"The changes are due to differences in ipv4 network package, in the
  49.    way it sets the defaults for several fields."_
  50.    
  51.    Dan has provided a patch for it that can be obtained at
  52.    http://www.cro.net/~vuksan/dhcppatch. To apply it just copy it to the
  53.    dhcpcd source directory (instruction how to get source are in the
  54.    following section) and type
  55.    
  56. patch
  57.  
  58.  
  59.  
  60.  
  61.  
  62. dhcpcd should compile cleanly after the patch has been applied.
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.   Method
  70.   
  71.  
  72.  
  73. _Step 1)_ No matter what distribution you are using you will need
  74. to download the DHCP client daemon for Linux. The package you need to download
  75. is called dhcpcd and the current version is 0.65. The description
  76. of the package reads:
  77.  
  78. Title:          dhcpcd
  79. Version:        0.65
  80. Entered-date:   05MAY97
  81. Description:    dhcpcd is an RFC2131 compliant DHCP client daemon. It
  82.                 gets an IP address and other information from a
  83.                 corresponding DHCP server, configures the network
  84.                 interface automatically, and tries to renew the lease
  85.                 time according to RFC2131. It works in the RFC1541
  86.                 compliant mode when the '-r' option is specified.
  87.                 So far it is found that dhcpcd 0.65 works fine with the
  88.                 following DHCP servers:
  89.                   1. ISC's dhcpd-BETA-5.15
  90.                   2. DHCP server on Windows NT server 3.51
  91.                   3. DHCP server version 1.3b by WIDE project.
  92.                   4. DHCP server in the SolarNet PC-Admin 1.5 package
  93.                   5. DHCP server used in the Time Warner Cable's
  94.                      Internet Access Service
  95.                 See the "Changes" file if you want to know the difference
  96.                 from the previous version.
  97. Keywords:       DHCP, client, Linux
  98. Author:         yoichi@fore.com (Yoichi Hariguchi)
  99. Maintained-by:  yoichi@fore.com (Yoichi Hariguchi)
  100. Primary-site:   ftp.kobe-u.ac.jp:/pub/PC-UNIX/Linux/network/dhcp
  101.                 33kB dhcpcd-0.65.tar.gz
  102. Alternate-site: sunsite.unc.edu:/pub/Linux/system/network/daemons
  103.                 33kB dhcpcd-0.65.tar.gz
  104. Original-site:
  105. Platforms:       Linux 1.2.xx, 1.3.xx, 2.0.x
  106. Copying-policy: GPL
  107.  
  108. _Note:_ Support for Bell Atlantic ADSL modems has been announced for
  109. version 0.7.
  110.  
  111.  
  112.  
  113.   Slackware
  114.   
  115.  
  116.  
  117. You can download the latest copy of the DHCPcd from any sunsite mirror
  118. or following:
  119.  
  120. ftp://ftp.cdrom.com/pub/linux/sunsite/system/network/daemons/.
  121.  
  122.  
  123. ftp://sunsite.unc.edu/pub/Linux/system/network/daemons
  124.  
  125.  
  126. ftp://ftp.kobe-u.ac.jp/pub/PC-UNIX/Linux/network/dhcp
  127. (Primary site in Japan)
  128.  
  129.  
  130.  
  131. Download the latest version of dhcpcd.tar.gz
  132.  
  133. Unpack it
  134.  
  135. tar -zxvf dhcpcd-0.65.tar.gz
  136.  
  137. cd into the directory
  138.  
  139. cd dhcpcd-0.65
  140.  
  141. make
  142.  
  143. You need to be root to do the following
  144.  
  145. make install
  146.  
  147.  
  148.  
  149. This will create the directory /etc/dhcpc where DHCPcd will store the
  150. DHCP information and dhcpcd file will be copied into /usr/sbin.
  151. Now skip to Step 2
  152.  
  153.   RedHat
  154.   
  155.  
  156.  
  157. DHCPcd is included in the standard RedHat distribution as an RPM and
  158. you can find it on your distribution's CD-ROM in RPMS directory or you can
  159. download it from:
  160.  
  161.  
  162. ftp://tsx-11.mit.edu/pub/linux/distributions/redhat/redhat-4.2/i386/RedHat/RPMS
  163. /dhcpcd-0.6-2.i386.rpm.
  164.  
  165.  
  166.  
  167.  
  168. and install it with
  169.  
  170. rpm -i dhcpcd-0.6-2.i386.rpm
  171.  
  172.  
  173.  
  174. Alternatively you can compile your own version by following the steps
  175. outlined in the Slackware part. When done go to Step 2
  176.  
  177.   Debian
  178.   
  179.  
  180.  
  181. There is deb package of DHCPcd at
  182.  
  183. ftp://ftp.debian.org/debian/stable/binary/net/
  184.  
  185.  
  186.  
  187.  
  188. or you can follow the Slackware installation instructions.
  189.  
  190.  
  191.  
  192. In order to unpack the deb package type
  193.  
  194. dpkg -i /where/ever/your/debian/packages/are/dhcpd*deb
  195.  
  196.  
  197.  
  198. When done go to Step 2
  199.  
  200.  
  201.  
  202.  
  203.  
  204.   __________________________________________________________________________
  205.  
  206.  
  207.  
  208.  
  209.  
  210. _Step 2)_
  211.  
  212.  
  213.  
  214.  
  215.  
  216. Following step(s) are depended on your needs.
  217.  
  218.  
  219.  
  220. _a) _ If you need network connectivity only occasionally you can
  221. start dhcpcd from the command line (you need to be root to execute it)
  222. by typing
  223.  
  224.  
  225.  
  226. /usr/sbin/dhcpcd
  227.  
  228. When you need to down (turn off) the network type
  229.  
  230. /usr/sbin/dhcpcd -k
  231.  
  232.  
  233.  
  234.  
  235.  
  236. You now only lack nameservers configuration file (/etc/resolv.conf).
  237. For instructions on how to create a resolv.conf go to
  238. Step 3
  239.  
  240.  
  241.  
  242.  
  243.  
  244. _b) _ If you want (need) network connectivity all the time and would
  245. like dhcpcd to start at boot time follow the steps below.
  246.  
  247.  
  248.  
  249.  
  250.  
  251.   Slackware
  252.   
  253.  
  254.  
  255. In order to make the system initialize using DHCP during boot type:
  256.  
  257.  
  258. cd /etc/rc.d
  259. mv rc.inet1 rc.inet1.OLD
  260.  
  261.  
  262.  
  263.  
  264.  
  265. This will move the old network initialization script into rc.inet1.OLD.
  266. You now need to create the new rc.inet1. It should look as follows:
  267.  
  268. #!/bin/sh
  269. #
  270. # rc.inet1      This shell script boots up the base INET system.
  271. #
  272. # Version:      @(#)/etc/rc.d/rc.inet1  1.01    05/27/93
  273. #
  274.  
  275. HOSTNAME=`cat /etc/HOSTNAME` #This is probably not necessary but I
  276.                              #will leave it in anyways
  277.  
  278. # Attach the loopback device.
  279. /sbin/ifconfig lo 127.0.0.1
  280. /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
  281.  
  282. # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
  283. # eth0 interface. If you're only using loopback or SLIP, don't include the
  284. # rest of the lines in this file.
  285.  
  286. /usr/sbin/dhcpcd
  287.  
  288.  
  289.  
  290.  
  291.  
  292. Save the above file as rc.inet1. Reboot your computer. Go to Step
  293. 3.
  294.  
  295.  
  296.  
  297.  
  298.  
  299.   RedHat
  300.   
  301.  
  302.  
  303. This information was provided to me by nothing (nothing@cc.gatech.edu)
  304.  
  305.  
  306.  
  307.  Removed my static ip and name from /etc/resolv.conf. However, I
  308. did leave in the search line and my two nameserver lines (for some reason my
  309. dhcpcd never creates a /etc/dhcpc/resolv.conf, so I have to use a static
  310. /etc/resolv.conf).
  311.  
  312.  
  313.  
  314.  In /etc/sysconfig/network I removed the HOSTNAME and GATEWAY
  315. entries.
  316. I left the other entries as is (NETWORKING, DOMAINNAME, GATEWAYDEV).
  317.  
  318.  
  319.  
  320.  In /etc/sysconfig/network-scripts/ifcfg-eth0 I removed the IPADDR,
  321. NETMASK, NETWORK, and BROADCAST entries. I left DEVICE and ONBOOT as is.
  322. I changed the BOOTPROTO line to BOOTPROTO=dhcp.
  323.  
  324.  
  325.  
  326. Save the file. Reboot your computer and go to Step 3
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.   Debian
  334.   
  335.  
  336.  
  337. It appears that there isn't a need for any DHCPcd configuration because:
  338.  
  339. From: Heiko Schlittermann
  340.  
  341.  
  342.  
  343.  The dhcpcd package installs it's startup script as usual for debian
  344. packages in /etc/init.d/, here as /etc/init.d/dhcpcd,
  345. and links this to the various /etc/rc?.d/ directories.
  346.  
  347.  
  348.  
  349. The contents of the /etc/rc?.d/ dirs is then executed at boot time.
  350.  
  351.  
  352.  
  353.  If you don't reboot after installing you should consider starting
  354. the daemon manually:
  355.  
  356.  
  357.  
  358. /etc/init.d/dhcpcd start
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366. Go to Step 3.
  367.  
  368.  
  369.  
  370.  
  371.  
  372.   __________________________________________________________________________
  373.  
  374.  
  375.  
  376.  
  377.  
  378. _Step 3)_ This step should be the same for all
  379. distributions.
  380.  
  381.  
  382.  
  383. After your machine reboots your network interface should be configured.
  384. Type:
  385.  
  386. ifconfig
  387.  
  388.  
  389.  
  390. You should get something like this
  391.  
  392. lo        Link encap:Local Loopback
  393.           inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0
  394.           UP BROADCAST LOOPBACK RUNNING  MTU:3584  Metric:1
  395.           RX packets:302 errors:0 dropped:0 overruns:0 frame:0
  396.           TX packets:302 errors:0 dropped:0 overruns:0 carrier:0 coll:0
  397.  
  398. eth0      Link encap:Ethernet  HWaddr 00:20:AF:EE:05:45
  399.           inet addr:24.128.53.102  Bcast:24.128.53.255  Mask:255.255.254.0
  400.           ^^^^^^^^^^^^^^^^^^^^^^^
  401.           UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
  402.           RX packets:24783 errors:1 dropped:1 overruns:0 frame:1
  403.           TX packets:11598 errors:0 dropped:0 overruns:0 carrier:0 coll:96
  404.           Interrupt:10 Base address:0x300
  405.  
  406.  
  407.  
  408.  
  409. If you have some normal number under inet. addr you are set. DHCPcd is a
  410. daemon and will stay running as long as you have your machine on. Every three
  411. hours it will contact the DHCP server and try to renew the IP address lease. It
  412. will log all the messages to the syslog (on Slackware /var/adm/syslog) if you
  413. need to check up on it.
  414.  
  415.  
  416.  
  417. One final thing. You need to specify your nameservers. There are two ways to do
  418. it, you can either ask your provider to provide you with the addresses of your
  419. name server and then put those in the /etc/resolv.conf or DHCPcd will obtain
  420. the list from the DHCP server and will build a resolv.conf in /etc/dhcpc.
  421. I decided to use DHCPcds resolv.conf by doing the following:
  422.  
  423. Back up your old /etc/resolv.conf
  424.  
  425. mv /etc/resolv.conf /etc/resolv.conf.OLD
  426.  
  427. If directory /etc/dhcpc doesn't exist create it
  428.  
  429. mkdir /etc/dhcpc
  430.  
  431. Make a link from /etc/dhcpc/resolv.conf to /etc/resolv.conf
  432.  
  433. ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
  434.  
  435.  
  436.  
  437.  If that doesn't work try this (fix suggested by nothing@cc.gatech.edu)
  438.  
  439.  
  440.  
  441.  
  442.  This last step I had to perform only because my dhcpcd doesn't
  443. create an /etc/dhcpc/resolv.conf.  In /etc/sysconfig/network-scripts/ifup I
  444. made the following changes (which are a very poor hack, but they work
  445. for me):
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452. #################################
  453.  
  454.  
  455. elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
  456.     echo -n "Using DHCP for ${DEVICE}... "
  457.     /sbin/dhcpcd -c /etc/sysconfig/network-scripts/ifdhcpc-done ${DEVICE}
  458.     echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
  459.  
  460.     if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
  461.         echo "failed."
  462.         exit 1
  463.     else
  464.         rm -f /var/run/dhcp-wait-${DEVICE}.pid
  465.         echo "done."
  466.         IPSETUP=yes
  467.     fi
  468. fi
  469.  
  470.  
  471. #################################
  472.  
  473. I changed to:
  474.  
  475.  
  476.  
  477. elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
  478.     echo -n "Using DHCP for ${DEVICE}... "
  479.     /sbin/dhcpcd
  480.     echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
  481.  
  482. #    if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
  483. #       echo "failed."
  484. #       exit 1
  485. #    else
  486. #       rm -f /var/run/dhcp-wait-${DEVICE}.pid
  487. #       echo "done."
  488.         IPSETUP=yes
  489. #    fi
  490. fi
  491.  
  492. #################################
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500. Now sit back and enjoy :-).
  501.  
  502.  
  503.  
  504.  
  505.  
  506.   Troubleshooting
  507.   
  508.  
  509.  
  510.  
  511.  
  512. If you have followed the steps outlined above and you are unable to access
  513. the network there are several possible explanations:
  514.  
  515.  
  516.  
  517.  
  518.  
  519. _I. Your network card is not configured properly_. During the boot up
  520. process your Linux will probe your network card and should say something along
  521. these lines:
  522.  
  523. eth0: 3c509 at 0x300 tag 1, 10baseT port, address  00 20 af ee 11 11, IRQ 10.
  524. 3c509.c:1.07 6/15/95 becker@cesdis.gsfc.nasa.gov
  525.  
  526.  
  527. If a message like this doesn't appear your ethernet card might not be recognize
  528. d
  529. by your Linux system. If you have a generic ethernet card (a NE2000 clone) you
  530. should have gotten a disk with DOS utilities that you can use to set up the
  531. card. Try playing with IRQs until Linux recognizes your card (IRQ 9,10,12 are
  532. usually good).
  533.  
  534.  
  535.  
  536.  
  537.  
  538. _II. Your DHCP server supports RFC 1541_
  539.  
  540.  
  541.  
  542. Try running dhcpcd by typing
  543.  
  544.  
  545.  
  546. dhcpcd -r
  547.  
  548.  
  549.  
  550. Use ifconfig to check if your network interface is configured (wait few seconds
  551. for the configuration process, initally it will say Inet.addr=0.0.0.0)
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.   __________________________________________________________________________
  559.  
  560.  
  561.  
  562.  
  563.  
  564. Thanks to all the people that contributed with their ideas and
  565. suggestions:
  566.  
  567.  
  568.  
  569. Heiko Schlittermann (heiko@os.inf.tu-dresden.de)
  570.  
  571. Jonathan Smith (jps2@ra.msstate.edu)
  572.  
  573. Dan Khabaza (danyh@iil.intel.com)
  574.  
  575. Hal Sadofsky (sadofsky@math.uoregon.edu)
  576.