mirror of https://github.com/tLDP/LDP
1260 lines
35 KiB
Plaintext
1260 lines
35 KiB
Plaintext
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
|
|
<article>
|
|
<artheader>
|
|
|
|
<title>DHCP mini-HOWTO</title>
|
|
|
|
<author>
|
|
<firstname>Vladimir</firstname>
|
|
<surname>Vuksan</surname>
|
|
<affiliation>
|
|
<address>
|
|
<email>vuksan@veus.hr</email>
|
|
</address>
|
|
</affiliation>
|
|
</author>
|
|
|
|
<revhistory>
|
|
<revision>
|
|
<revnumber>v4.12</revnumber>
|
|
<date>October 22, 2000</date>
|
|
<authorinitials>vv</authorinitials>
|
|
</revision>
|
|
</revhistory>
|
|
|
|
<abstract>
|
|
<para>
|
|
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.
|
|
</para>
|
|
</abstract>
|
|
|
|
</artheader>
|
|
|
|
<sect1>
|
|
<title>Introduction</title>
|
|
|
|
<sect2>
|
|
<title>Standard Disclaimer</title>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
Also bear in mind that this is <emphasis>NOT</emphasis> official information.
|
|
Much content in this document are assumptions, which appear to
|
|
work for people. Use the information at your own risk.
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>New Versions of this Document</title>
|
|
<para>
|
|
New versions of this document are available from
|
|
</para>
|
|
<para>
|
|
<ulink
|
|
url="http://www.oswg.org/oswg-nightly/DHCP.html">http://www.oswg.org/oswg-nightly/DHCP.html</ulink>
|
|
</para>
|
|
<para>
|
|
Following translations of the DHCP mini-HOWTO are available:
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>Chinese - <ulink
|
|
url="http://www.linux.org.tw/CLDP/mini/DHCP.html">http://www.linux.org.tw/CLDP/mini/DHCP.html</ulink></para></listitem>
|
|
<listitem><para>Japanese - <ulink
|
|
url="http://www.linux.or.jp/JF/JFdocs/DHCP.html">http://www.linux.or.jp/JF/JFdocs/DHCP.html</ulink></para></listitem>
|
|
<listitem><para>Spanish - <ulink
|
|
url="ftp://cuates.pue.upaep.mx/pub/linux/LuCAS/DHCP-mini-Como/">ftp://cuates.pue.upaep.mx/pub/linux/LuCAS/DHCP-mini-Como/</ulink></para></listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
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.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Feedback</title>
|
|
<para>
|
|
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 <email>vuksan-feedback@veus.hr</email>.
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Contributors</title>
|
|
<para>
|
|
This document has been modified from the original version
|
|
by Paul Makeev.
|
|
</para>
|
|
<para>
|
|
The following people have contributed to this mini-HOWTO.
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>Heiko Schlittermann</para></listitem>
|
|
<listitem><para>Jonathan Smith</para></listitem>
|
|
<listitem><para>Dan Khabaza</para></listitem>
|
|
<listitem><para>Hal Sadofsky</para></listitem>
|
|
<listitem><para>Henrik Stoerner</para></listitem>
|
|
<listitem><para>Paul Rossington</para></listitem>
|
|
<listitem><para>numerous others</para></listitem>
|
|
</itemizedlist>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Copyright Information</title>
|
|
<para>
|
|
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
|
|
</para>
|
|
<para>
|
|
<ulink
|
|
url="http://www.opencontent.org/opl.shtml">http://www.opencontent.org/opl.shtml</ulink>
|
|
</para>
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>DHCP protocol</title>
|
|
<para>
|
|
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
|
|
<ulink
|
|
url="http://web.syr.edu/~jmwobus/comfaqs/dhcp.faq.html">http://web.syr.edu/~jmwobus/comfaqs/dhcp.faq.html</ulink>.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>Client Setup</title>
|
|
<para>
|
|
Currently there are three different DHCP client programs for Linux, dhcpcd,
|
|
pump and dhclient. This mini-HOWTO deals primarily with dhcpcd.
|
|
</para>
|
|
|
|
<sect2>
|
|
<title>Downloading the client daemon (dhcpcd)</title>
|
|
<para>
|
|
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 <email>sergei@phystech.com</email> and
|
|
today it comes as a binary package with most distributions.
|
|
</para>
|
|
<para>
|
|
dhcpcd source can be downloaded from following locations
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para><ulink
|
|
url="ftp://ftp.phystech.com/pub/">ftp://ftp.phystech.com/pub/</ulink> (Primary site)</para></listitem>
|
|
<listitem><para><ulink
|
|
url="http://www.cps.msu.edu/~dunham/out/">http://www.cps.msu.edu/~dunham/out/</ulink></para></listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
Then follow the instructions below. They should be the same.
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2 id="slackware">
|
|
<title id="slackware.title">Slackware</title>
|
|
<para>
|
|
You can download the latest copy of the DHCPcd from any Metalab mirror
|
|
or following:
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para><ulink
|
|
url="ftp://metalab.unc.edu/pub/Linux/system/network/daemons">ftp://metalab.unc.edu/pub/Linux/system/network/daemons</ulink></para></listitem>
|
|
<listitem><para><ulink
|
|
url="ftp://ftp.phystech.com/pub/">ftp://ftp.phystech.com/pub/</ulink> (Primary site)</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
Download the latest version of <filename>dhcpcd.tar.gz</filename>.
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
<para>
|
|
Unpack it
|
|
</para>
|
|
<para>
|
|
<command>tar -zxvf dhcpcd-1.3.18pl1.tar.gz</command>
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
cd into the directory and make dhcpcd
|
|
</para>
|
|
<para>
|
|
<command>cd dhcpcd-1.3.18pl1</command>
|
|
</para>
|
|
<para>
|
|
<command>make</command>
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
Install it (you have to run the following command as root)
|
|
</para>
|
|
<para>
|
|
<command>make install</command>
|
|
</para>
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
This will create the directory /etc/dhcpc where DHCPcd will store the
|
|
DHCP information and dhcpcd file will be copied into /usr/sbin.
|
|
</para>
|
|
|
|
<para>
|
|
In order to make the system initialize using DHCP during boot type:
|
|
</para>
|
|
|
|
<para>
|
|
<command>cd /etc/rc.d</command>
|
|
</para>
|
|
|
|
<para>
|
|
<command>mv rc.inet1 rc.inet1.OLD</command>
|
|
</para>
|
|
|
|
<para>
|
|
This will move the old network initialization script into
|
|
<filename>rc.inet1.OLD</filename>.
|
|
You now need to create the new <filename>rc.inet1</filename> script.
|
|
Following code is all you need:
|
|
</para>
|
|
|
|
<programlisting>
|
|
#!/bin/sh
|
|
#
|
|
# rc.inet1 This shell script boots up the base INET system.
|
|
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
Save it and reboot your computer.
|
|
</para>
|
|
|
|
<para>
|
|
When you are finished go the <link linkend=nameserver>last step</link>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 id="redhat6">
|
|
<title id="redhat6.title">RedHat 6.x and Mandrake 6.x</title>
|
|
<para>
|
|
DHCPcd configuration under RedHat 6.0+ is really easy. All you need to do
|
|
is start the Control Panel by typing <command>control-panel</command>.
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>Select "Network Configuration"</para></listitem>
|
|
<listitem><para>Click on Interfaces</para></listitem>
|
|
<listitem><para>Click Add</para></listitem>
|
|
<listitem><para>Select Ethernet</para></listitem>
|
|
<listitem><para>In the Edit Ethernet/Bus Interface select "Activate
|
|
interface at boot time" as well as select "DHCP" as "Interface
|
|
configuration protocol"</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
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. <command>rpm -i dhcpcd-1.3.17pl2-1.i386.rpm</command>) you
|
|
will have to make some <link linkend=linuxppc-rh6>changes</link>.
|
|
</para>
|
|
|
|
<para>
|
|
Additional notes from Alexander Stevenson
|
|
<email>alexander.stevenson@home.com</email>:
|
|
</para>
|
|
|
|
<para>
|
|
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:
|
|
</para>
|
|
|
|
<para>
|
|
<command>pump -i eth0 -h hostname</command>
|
|
</para>
|
|
|
|
<para>
|
|
It didn't matter what "hostname" was, but without it the server would
|
|
not respond.
|
|
</para>
|
|
|
|
<para>
|
|
I then changed the line in my <filename
|
|
class="directory">/sbin/ifup</filename> script to reflect the change;
|
|
the default version does not have the -h switch, and so didn't work for
|
|
me.
|
|
</para>
|
|
|
|
<para>
|
|
Basically, if you're using linuxconf, and after setting the adapter to
|
|
"DHCP" it still doesn't work, try adding a "<command>-h
|
|
hostname</command>" to the pump line in the
|
|
<filename>/sbin/ifup</filename> script. My script now looks like this:
|
|
</para>
|
|
|
|
<programlisting>
|
|
...
|
|
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 ...
|
|
</programlisting>
|
|
|
|
<para>
|
|
Another more elegant way to add hostname field is provided by Aad van der Klaauw:
|
|
</para>
|
|
|
|
<para>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
|
|
</para>
|
|
|
|
<programlisting>
|
|
DEVICE="eth0"
|
|
MACADDR="00:11:22:33:44:55"
|
|
DHCP_HOSTNAME="trigger_for_terayon"
|
|
</programlisting>
|
|
|
|
<para>
|
|
Which will survive upgrades, and is imho a "cleaner" way.
|
|
</para>
|
|
|
|
|
|
<para>
|
|
That is it. Reboot your machine or type <command>/sbin/ifup eth0</command> on the command line.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>RedHat 5.x</title>
|
|
<para>
|
|
DHCPcd configuration under RedHat 5.0+ is really easy. All you need to do
|
|
is start the Control Panel by typing <command>control-panel</command>.
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>Select "Network Configuration"</para></listitem>
|
|
<listitem><para>Click on Interfaces</para></listitem>
|
|
<listitem><para>Click Add</para></listitem>
|
|
<listitem><para>Select Ethernet</para></listitem>
|
|
<listitem><para>In the Edit Ethernet/Bus Interface select "Activate
|
|
interface at boot time" as well as select "DHCP" as "Interface
|
|
configuration protocol"</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
When you are finished go the <link linkend=nameserver>last step</link>.
|
|
</para>
|
|
</sect2>
|
|
|
|
|
|
<sect2>
|
|
<title>RedHat 4.x and Caldera OpenLinux 1.1/1.2</title>
|
|
<para>
|
|
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:
|
|
</para>
|
|
|
|
<para>
|
|
<ulink
|
|
url="ftp://ftp.redhat.com/pub/redhat/redhat-4.2/i386/RedHat/RPMS/dhcpcd-0.6-2.i386.rpm">ftp://ftp.redhat.com/pub/redhat/redhat-4.2/i386/RedHat/RPMS/dhcpcd-0.6-2.i386.rpm</ulink>
|
|
</para>
|
|
|
|
<para>
|
|
Install it with <command>rpm -i dhcpcd-0.6-2.i386.rpm</command>.
|
|
</para>
|
|
|
|
<para>
|
|
Alternatively you can compile your own version by following the steps
|
|
outlined in the <link linkend=slackware
|
|
endterm="slackware.title"></link>.
|
|
</para>
|
|
|
|
<para>
|
|
The following information was provided to me by nothing
|
|
<email>nothing@cc.gatech.edu</email>.
|
|
</para>
|
|
|
|
<blockquote>
|
|
<para>
|
|
Removed my static ip and name from
|
|
<filename>/etc/resolv.conf</filename>. However, I did leave in the
|
|
search line and my two nameserver lines (for some reason my dhcpcd never
|
|
creates a <filename>/etc/dhcpc/resolv.conf</filename>, so I have to use
|
|
a static <filename>/etc/resolv.conf</filename>).
|
|
</para>
|
|
<para>
|
|
In <filename>/etc/sysconfig/network</filename> I removed the HOSTNAME
|
|
and GATEWAY entries. I left the other entries as is (NETWORKING,
|
|
DOMAINNAME, GATEWAYDEV).
|
|
</para>
|
|
<para>
|
|
In <filename>/etc/sysconfig/network-scripts/ifcfg-eth0</filename> I
|
|
removed the IPADDR, NETMASK, NETWORK, and BROADCAST entries. I left
|
|
DEVICE and ONBOOT as is. I changed the BOOTPROTO line to
|
|
BOOTPROTO=dhcp.
|
|
</para>
|
|
<para>
|
|
Save the file. Reboot your computer.
|
|
</para>
|
|
</blockquote>
|
|
|
|
<para>
|
|
When you are finished go the <link linkend=nameserver>last step</link>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 id="debian">
|
|
<title id="debian.title">Debian</title>
|
|
<para>
|
|
There is a deb package of DHCPcd (make sure it starts with dhcpcd) at:
|
|
</para>
|
|
|
|
<para>
|
|
<ulink
|
|
url="http://ftp.debian.org/debian/dists/slink/main/binary-i386/net/">http://ftp.debian.org/debian/dists/slink/main/binary-i386/net/</ulink>
|
|
</para>
|
|
|
|
<para>
|
|
Or, follow the <link linkend=slackware endterm="slackware.title"></link> installation instructions.
|
|
</para>
|
|
|
|
<para>
|
|
To unpack the deb package type <command>dpkg -i /where/ever/your/debian/packages/are/dhcpcd*deb</command>.
|
|
</para>
|
|
|
|
<para>
|
|
It appears that there isn't a need for any DHCPcd configuration because:
|
|
</para>
|
|
|
|
<blockquote>
|
|
<attribution>From: Heiko Schlittermann
|
|
<email>heiko@os.inf.tu-dresden.de</email></attribution>
|
|
<para>
|
|
The dhcpcd package installs it's startup script as usual for debian
|
|
packages in
|
|
<filename>/etc/init.d/<replaceable>package_name</replaceable></filename>,
|
|
here as <filename>/etc/init.d/dhcpcd</filename>,
|
|
and links this to the various <filename
|
|
class="directory">/etc/rc?.d/</filename> directories.
|
|
</para>
|
|
</blockquote>
|
|
|
|
<para>
|
|
The contents of the <filename class="directory">/etc/rc?.d/</filename> dirs is then executed at boot time.
|
|
</para>
|
|
|
|
<para>
|
|
If you don't reboot after installing you should consider starting
|
|
the daemon manually: <command>/etc/init.d/dhcpcd start</command>.
|
|
</para>
|
|
|
|
<para>
|
|
When you are finished go the <link linkend=nameserver>last step</link>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>LinuxPPC and MkLinux</title>
|
|
<para>
|
|
Following section has been written by R. Shapiro
|
|
</para>
|
|
|
|
<para>
|
|
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
|
|
<link linkend=redhat6 endterm="redhat6.title"></link>.
|
|
</para>
|
|
|
|
<para>
|
|
The remaining problem is that Redhat 6 uses the 'pump' client for dhcp
|
|
by default, and 'pump' doesn't work reliably in Linuxppc. <anchor
|
|
id="linuxppc-rh6">To get around this, you should install the latest
|
|
dhcpcd from Sergei Viznyuk, and then edit
|
|
<filename>/sbin/ifup</filename> to use <command>dhcpcd</command>
|
|
instead of <command>pump</command>.
|
|
</para>
|
|
|
|
<para>
|
|
Change
|
|
</para>
|
|
|
|
<programlisting>
|
|
if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp ]; then
|
|
PUMP=true
|
|
fi
|
|
|
|
if [ -n "$PUMP" ]; then
|
|
</programlisting>
|
|
|
|
<para>
|
|
with
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
and a coresponding changes for <command>ifdown</command>. Change
|
|
</para>
|
|
|
|
<programlisting>
|
|
if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp ]; then
|
|
....
|
|
fi
|
|
</programlisting>
|
|
|
|
<para>
|
|
with
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
A working ppc rpm for dhcpcd is included on the Linuxppc 1999 cd; a
|
|
slightly later rpm is available in the contrib directory on
|
|
<ulink url="ftp://ftp.linuxppc.org/">ftp://ftp.linuxppc.org/</ulink>.
|
|
Sources, which compile out of the box in Linuxppc 1999, are available
|
|
from <ulink
|
|
url="ftp://ftp.phystech.com/pub/dhcpcd-1.3.17-pl9.tar.gz">ftp://ftp.phystech.com/pub/dhcpcd-1.3.17-pl9.tar.gz</ulink>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 id="nameserver">
|
|
<title id="nameserver.title">Tying it all together</title>
|
|
<para>
|
|
After your machine reboots your network interface should be configured.
|
|
Type: <command>ifconfig</command>.
|
|
</para>
|
|
|
|
<para>
|
|
You should get something like this:
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
If you have some normal number under <literal>inet addr</literal> you are set. If you see
|
|
0.0.0.0 don't despair, it is a temporary setting before
|
|
<command>dhcpcd</command> acquires
|
|
the IP address. If even after few minutes you are seeing 0.0.0.0 please
|
|
check out <link linkend=troubleshooting
|
|
endterm="troubleshooting.title"></link>. 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
|
|
<filename>/var/adm/syslog</filename>, RedHat/OpenLinux
|
|
<filename>/var/log/syslog</filename>).
|
|
</para>
|
|
|
|
<para>
|
|
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
|
|
<filename>/etc/resolv.conf</filename> or DHCPcd will obtain
|
|
the list from the DHCP server and will build a
|
|
<filename>resolv.conf</filename> in <filename
|
|
class="directory">/etc/dhcpc</filename>.
|
|
</para>
|
|
<para>
|
|
I decided to use DHCPcd's <filename>resolv.conf</filename> by doing the following:
|
|
</para>
|
|
|
|
<para>
|
|
Back up your old <filename>/etc/resolv.conf</filename>: <command>mv /etc/resolv.conf
|
|
/etc/resolv.conf.OLD</command>
|
|
</para>
|
|
|
|
<para>
|
|
If directory <filename class="directory">/etc/dhcpc</filename> doesn't
|
|
exist create it: <command>mkdir /etc/dhcpc</command>
|
|
</para>
|
|
|
|
<para>
|
|
Make a link from <filename>/etc/dhcpc/resolv.conf</filename> to
|
|
<filename>/etc/resolv.conf</filename>: <command>ln -s
|
|
/etc/dhcpc/resolv.conf /etc/resolv.conf</command>
|
|
</para>
|
|
|
|
<para>
|
|
If that doesn't work try this (fix suggested by
|
|
<email>nothing@cc.gatech.edu</email> with a little amendment by Henrik
|
|
Stoerner):
|
|
</para>
|
|
|
|
<anchor id="error3">
|
|
<para>
|
|
This last step I had to perform only because my dhcpcd doesn't
|
|
create an <filename>/etc/dhcpc/resolv.conf</filename>. In <filename
|
|
class="directory">/etc/sysconfig/network-scripts/ifup</filename> I
|
|
made the following changes (which are a very poor hack, but they work
|
|
for me):
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
I changed to:
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<note>
|
|
<para>
|
|
Notice the ! (bang) in <literal>if [ ! -f
|
|
/var/run/dhcp-wait-${DEVICE}.pid ];</literal>
|
|
</para>
|
|
</note>
|
|
|
|
<para>
|
|
Now sit back and enjoy :-).
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2>
|
|
<title>Various notes</title>
|
|
<para>
|
|
Following step(s) are not necessary but might be useful to some people:
|
|
</para>
|
|
|
|
<orderedlist numeration="loweralpha">
|
|
<listitem>
|
|
<para>
|
|
If you need network connectivity only occasionally you can
|
|
start <command>dhcpcd</command> from the command line (you have to be
|
|
root to do this) with: <command>/usr/sbin/dhcpcd</command>.
|
|
</para>
|
|
<para>
|
|
When you need to down (turn off) the network type
|
|
<command>/usr/sbin/dhcpcd -k</command>.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="troubleshooting">
|
|
<title id="troubleshooting.title">Troubleshooting</title>
|
|
<para>
|
|
If you have followed the steps outlined above and you are unable to access
|
|
the network there are several possible explanations:
|
|
</para>
|
|
|
|
<sect3>
|
|
<title>Your network card is not configured properly</title>
|
|
<para>
|
|
During the boot up process your Linux will probe your network card and should say something along these lines:
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
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).
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>Your DHCP server supports RFC 1541/My DHCP server is Windows
|
|
NT</title>
|
|
<para>
|
|
Try running <command>dhcpcd</command> by typing <command>dhcpcd -r</command>.
|
|
</para>
|
|
|
|
<para>
|
|
Use <command>ifconfig</command> to check if your network interface is
|
|
configured (wait few seconds for the configuration process, initally it
|
|
will say <literal>Inet.addr=0.0.0.0</literal>)
|
|
</para>
|
|
|
|
<para>
|
|
If this solves your problem add the "-r" flag to the boot up scripts,
|
|
ie: instead of <command>/sbin/dhcpcd</command> you will have
|
|
<command>/sbin/dhcpcd -r</command>.
|
|
</para>
|
|
|
|
<para>
|
|
For example under RedHat edit script
|
|
<filename>/etc/sysconfig/network-scripts/ifup</filename>
|
|
and change the following:
|
|
</para>
|
|
|
|
<programlisting>
|
|
IFNAME=$[ {DEVICE} \
|
|
"/sbin/dhcpcd -r -c /etc/"- etc etc.
|
|
</programlisting>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>During bootup I get error message "Using DHCP for eth0 ...
|
|
failed" but my system works fine.</title>
|
|
<para>
|
|
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 <link linkend=error3>here</link> and check how to fix it.
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>My network works for few minutes and then stops
|
|
responding</title>
|
|
<para>
|
|
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 with: <command>ps -auxww | grep gate</command>.
|
|
</para>
|
|
|
|
<para>
|
|
If it is try removing it with RedHat's RPM manager or removing the entry
|
|
in <filename class="directory">/etc/rc.d/</filename>.
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>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.</title>
|
|
<para>
|
|
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.
|
|
</para>
|
|
|
|
<programlisting>
|
|
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
|
|
</programlisting>
|
|
|
|
<para>
|
|
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.
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>My DHCP client broadcasts requests but no one answers
|
|
(Contributed by Peter Amstutz)</title>
|
|
<para>
|
|
On some systems, you need to include some hostname for your machine as
|
|
part of the request. With dhcpcd, do this with <command>dhcpcd -h
|
|
<replaceable>foohost</replaceable></command>
|
|
Probably the hostname wanted will be your account username on the network.
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>I have followed all the steps but still my machine is not able to
|
|
connect</title>
|
|
<para>
|
|
The 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.
|
|
</para>
|
|
|
|
<para>
|
|
You have firewall rules (ipfwadm rules) that disallow port 67/68
|
|
traffic used by DHCP to distribute configuration info. Check your firewall
|
|
rules carefully.
|
|
</para>
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>I have MediaOne Express service and I still can't
|
|
connect.</title>
|
|
<para>
|
|
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:
|
|
</para>
|
|
<programlisting>
|
|
DHCP received an unknown option 067 of length 005. The raw option data is
|
|
given below.
|
|
|
|
0000: 62 61 73 69 63 basic
|
|
</programlisting>
|
|
|
|
<para>
|
|
If this is the problem go to
|
|
<ulink
|
|
url="ftp://vanbuer.ddns.org/pub/">ftp://vanbuer.ddns.org/pub/</ulink>
|
|
and either download a binary or get the source for the change.
|
|
</para>
|
|
</sect3>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Alternative DHCP client (ISC dhclient)</title>
|
|
<para>
|
|
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 <link linkend=dhcpserver>here</link>.
|
|
When you are done with it please return to this section to configure
|
|
the client.
|
|
</para>
|
|
|
|
<note>
|
|
<para>
|
|
Following information has been provided by
|
|
Ted Lemon <email>mellon@isc.org</email>
|
|
one of the authors of dhclient.
|
|
</para>
|
|
</note>
|
|
|
|
<para>
|
|
With the current version of the DHCP client,
|
|
you don't actually need a <filename>dhclient.conf</filename>. All you
|
|
have to do is invoke dhclient e.g.: <command>/sbin/dhclient</command>.
|
|
</para>
|
|
|
|
<para>
|
|
This will configure all broadcast interfaces. If this doesn't
|
|
work or you want to specify only one interface create a
|
|
<filename>/etc/dhclient.conf</filename> file with this example
|
|
configuration.
|
|
</para>
|
|
|
|
<programlisting>
|
|
interface "eth0" {
|
|
send dhcp-client-identifier 1:xx:xx:xx:xx:xx:xx;
|
|
send dhcp-lease-time 86400;
|
|
}
|
|
</programlisting>
|
|
|
|
<para>
|
|
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.
|
|
</para>
|
|
|
|
</sect2>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>DHCP Server Setup</title>
|
|
|
|
<sect2 id="dhcpserver">
|
|
<title id="dhcpserver.title">DHCP server for UNIX</title>
|
|
<para>
|
|
There are several DHCP servers available for U*X-like OSes,
|
|
both commercial and free. One of the more popular free DHCP servers
|
|
is Paul Vixie/ISC DHCPd. Currently the latest version is 2.0 (suggested
|
|
for most users) but 3.0 is in beta testing. You can get them from
|
|
</para>
|
|
|
|
<para>
|
|
<ulink
|
|
url="ftp://ftp.isc.org/isc/dhcp/">ftp://ftp.isc.org/isc/dhcp/</ulink>
|
|
</para>
|
|
|
|
<para>
|
|
Some of the distributions provide binary packages for dhcpd so
|
|
skip the following section if you got it installed that way.
|
|
</para>
|
|
|
|
<para>
|
|
After you download unpack it. After you do cd into the
|
|
distribution directory and type: <command>./configure</command>
|
|
</para>
|
|
|
|
<para>
|
|
It will take some time to configure the settings. After it is done type:
|
|
<command>make</command> and <command>make install</command>.
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>DHCP server configuration</title>
|
|
<para>
|
|
When done with installation type <command>ifconfig -a</command>. You
|
|
should see something like this:
|
|
</para>
|
|
|
|
<programlisting>
|
|
eth0 Link encap:10Mbps Ethernet HWaddr 00:C0:4F:D3:C4:62
|
|
inet addr:183.217.19.43 Bcast:183.217.19.255 Mask:255.255.255.0
|
|
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
|
RX packets:2875542 errors:0 dropped:0 overruns:0
|
|
TX packets:218647 errors:0 dropped:0 overruns:0
|
|
Interrupt:11 Base address:0x210
|
|
</programlisting>
|
|
|
|
<para>
|
|
If it doesn't say MULTICAST you should reconfigure your
|
|
kernel and add multicast support. On most systems you will not
|
|
need to do this.
|
|
</para>
|
|
|
|
<para>
|
|
Next step is to add route for 255.255.255.255. Quoted from DHCPd README:
|
|
</para>
|
|
|
|
<blockquote>
|
|
<para>
|
|
"In order for dhcpd to work correctly with picky DHCP clients
|
|
(e.g., Windows 95), it must be able to send packets with an
|
|
IP destination address of 255.255.255.255. Unfortunately,
|
|
Linux insists on changing 255.255.255.255 into the local
|
|
subnet broadcast address (here, that's 192.5.5.223). This
|
|
results in a DHCP protocol violation, and while many DHCP
|
|
clients don't notice the problem, some (e.g., all Microsoft
|
|
DHCP clients) do. Clients that have this problem will appear
|
|
not to see DHCPOFFER messages from the server."
|
|
</para>
|
|
</blockquote>
|
|
|
|
<para>
|
|
Type: <command>route add -host 255.255.255.255 dev eth0</command>
|
|
</para>
|
|
|
|
<para>
|
|
If you get a message "<literal>255.255.255.255: Unknown host</literal>",
|
|
you should try adding the following entry to your
|
|
<filename>/etc/hosts</filename> file:
|
|
</para>
|
|
|
|
<programlisting>
|
|
255.255.255.255 all-ones
|
|
</programlisting>
|
|
|
|
<para>
|
|
Then, try:
|
|
</para>
|
|
|
|
<programlisting>
|
|
route add -host all-ones dev eth0
|
|
</programlisting>
|
|
|
|
<para>
|
|
or
|
|
</para>
|
|
|
|
<programlisting>
|
|
route add 255.255.255.0 dev eth0
|
|
</programlisting>
|
|
|
|
<para>
|
|
<literal>eth0</literal> is of course the name of the network device you
|
|
are using. If it differs change appropriately.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Options for DHCPd</title>
|
|
<para>
|
|
Now you need to configure DHCPd. In order to do this you
|
|
will have to create or edit <filename>/etc/dhcpd.conf</filename>. There
|
|
is a graphical interface for dhcpd configuration under KDE ( <ulink
|
|
url="http://www.kde.org/">http://www.kde.org/</ulink> ) called kcmdhcpd
|
|
that is very similar to the DHCP configurator on Windows NT. When KDE
|
|
2.0 comes out it should come with kcmdhcpd or you could get it directly
|
|
from:
|
|
</para>
|
|
|
|
<para>
|
|
<ulink
|
|
url="ftp://ftp.us.kde.org/pub/kde/unstable/apps/network/">ftp://ftp.us.kde.org/pub/kde/unstable/apps/network/</ulink>
|
|
</para>
|
|
|
|
<para>
|
|
If you want to configure it by hand follow instructions below.
|
|
</para>
|
|
|
|
<para>
|
|
Most commonly what you want to do is assign IP addresses randomly. This
|
|
can be done with settings as follows:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# Sample /etc/dhcpd.conf
|
|
# (add your comments here)
|
|
default-lease-time 600;
|
|
max-lease-time 7200;
|
|
option subnet-mask 255.255.255.0;
|
|
option broadcast-address 192.168.1.255;
|
|
option routers 192.168.1.254;
|
|
option domain-name-servers 192.168.1.1, 192.168.1.2;
|
|
option domain-name "mydomain.org";
|
|
|
|
subnet 192.168.1.0 netmask 255.255.255.0 {
|
|
range 192.168.1.10 192.168.1.100;
|
|
range 192.168.1.150 192.168.1.200;
|
|
}
|
|
</programlisting>
|
|
|
|
<para>
|
|
This will result in DHCP server giving a client an IP address
|
|
from the range 192.168.1.10-192.168.1.100 or
|
|
192.168.1.150-192.168.1.200. It will lease an IP address for
|
|
600 seconds if the client doesn't ask for specific time
|
|
frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The
|
|
server will also "advise" the client that it should use 255.255.255.0 as
|
|
its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as
|
|
the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers.
|
|
</para>
|
|
|
|
<para>
|
|
If you need to specify a WINS server for your Windows clients you
|
|
will need to include the <literal>netbios-name-servers</literal> option e.g.
|
|
</para>
|
|
|
|
<programlisting>
|
|
option netbios-name-servers 192.168.1.1;
|
|
</programlisting>
|
|
|
|
<para>
|
|
You can also assign specific IP addresses based on clients
|
|
ethernet address e.g.
|
|
</para>
|
|
|
|
<programlisting>
|
|
host haagen {
|
|
hardware ethernet 08:00:2b:4c:59:23;
|
|
fixed-address 192.168.1.222;
|
|
}
|
|
</programlisting>
|
|
|
|
<para>
|
|
This will assign IP address 192.168.1.222 to a client with ethernet
|
|
address 08:00:2b:4c:59:23.
|
|
</para>
|
|
|
|
<para>
|
|
You can also mix and match e.g. you can have certain clients getting
|
|
"static" IP addresses (e.g. servers) and others being alloted
|
|
dynamic IPs (e.g. mobile users with laptops). There are a number of other
|
|
options e.g. nis server addresses, time server addresses etc., if you
|
|
need any of those options please read the
|
|
<filename>dhcpd.conf</filename> man page.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
|
|
|
<sect2>
|
|
<title>Starting the server</title>
|
|
<para>
|
|
There is only one thing to do before starting the server. In most cases
|
|
DHCP installation doesn't create a <filename>dhcpd.leases</filename>
|
|
files. This file is used by DHCPd to store information about current
|
|
leases. It is in the plain text form so you can view it during the
|
|
operation of DHCPd. To create <filename>dhcpd.leases</filename> type:
|
|
|
|
<programlisting>
|
|
touch /var/state/dhcp/dhcpd.leases
|
|
</programlisting
|
|
|
|
</para>
|
|
|
|
<para>
|
|
This will create an empty file (file size = 0).
|
|
Some of the older version of dhcpd 2.0 placed the file in
|
|
<filename>/etc/dhcpd.leases</filename>. You do not need to make any
|
|
changes to the leases file it will be manipulated by the dhcpd. If you
|
|
get a message saying that file exists simply ignore it and go to the
|
|
next step.
|
|
</para>
|
|
|
|
<para>
|
|
You can now invoke the DHCP server. Simply type (or include in the bootup
|
|
scripts)
|
|
</para>
|
|
|
|
<programlisting>
|
|
/usr/sbin/dhcpd
|
|
</programlisting>
|
|
|
|
<para>
|
|
This will invoke dhcpd on eth0 device. If you want to invoke it
|
|
on another device simply supply it on the command line e.g.
|
|
</para>
|
|
|
|
<programlisting>
|
|
/usr/sbin/dhcpd eth1
|
|
</programlisting>
|
|
|
|
<para>
|
|
To verify that everything is working fine you
|
|
should first turn on the debugging mode and put the server
|
|
in foreground. You can do this by typing
|
|
</para>
|
|
|
|
<programlisting>
|
|
/usr/sbin/dhcpd -d -f
|
|
</programlisting>
|
|
|
|
<para>
|
|
Then boot up one of your clients and check out the console of your server.
|
|
You will see a number of debugging messages come up. If everything works out
|
|
fine you are done :-). Quit dhcpd and start it without the
|
|
<command>-d</command> <command>-f</command> and arguments. If you want
|
|
dhcpd to start at boot-up include dhcpd in e.g.
|
|
</para>
|
|
|
|
<programlisting>
|
|
/etc/rc.d/rc.local
|
|
</programlisting>
|
|
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Other interesting documents</title>
|
|
<para>
|
|
Linux Magazine has a pretty good article in their April issue called
|
|
<ulink url="http://www.linux-mag.com/2000-04/networknirvana_01.html">Network
|
|
Nirvana: How to make Network Configuration as easy as DHCP</ulink> that
|
|
discusses the set up for DHCP.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
|
</sect1>
|
|
|
|
</article>
|