Home Info Meetings Mail List Board HOWTOs Links

DHCP Client at Winthrop HOWTO

Warren Dukes, zzdukesj@pobox.winthrop.edu

A tutorial on how to setup a DHCP client at Winthrop University, so that Dorm residents who use linux can have access to the Network.


Table of Contents

1. Introduction

2. Client Setup
2.1 RedHat 6.x and Mandrake 6.x and 7.0
2.2 Other Distros using 2.2.x

3. Name Resolution Issues
3.1 Update /etc/hosts
3.3 Free DNS Service Configuration
3.3.1 Configuring penguinpowered.com
3.3.2 Configuring ddns.org

4. Samba
4.1 Accessing Birdnest
4.1.1 Using smbclient
4.1.2 Using smbmount
4.2 Configuring SMB Server

5. Troubleshooting
5.1 Make Sure Your Ethernet Card Is Working
5.2 If you are using Red Hat or Mandrake...
5.3 Troubleshooting with dhcpxd


1. Introduction

DHCP is the protocal used by Winthrop University to dynmaically assign IPs to Dorm residents. One of the pitfalls of the DHCP implementation at Winthrop is that it appears an NT server is used to assign the addresses and/or DHCP client implementation in Linux has only recently begun to mature.

This howto, assumes your ethernet card is working and operates properly in linux. For help on configuring an ethernet card, Ethernet-Howto.

If you have any suggestions, inqueries, corrections or comments email, one of the authors.


2. Client Setup

2.1 RedHat 6.x and Mandrake 6.x and 7.0

First, get pump-0.7.4-1.i386.rpm.

Then install pump-0.7.4-1.i386.rpm as root:
rpm -Uvh pump-0.7.4-1.i386.rpm

Now, create or edit /etc/pump.conf so that it contains:
------------------------------------------------------
retries 30
------------------------------------------------------

Now, to check to see if it works, execute:
/sbin/ifup eth0

If it did not give you a failure everything is good. If it did not work check out Troubleshooting.

Now, execute:
/etc/rc.d/init.d/network restart

Finally, to make sure that networking will start on startup, execute:
/usr/sbin/setup
Go to System Services and make sure Network is enabled.

Now everyting should work.

Note: If you have any problems getting an IP address and you know your ethernet card is working, see Troubleshooting 5.2. Note also, most of the time pump works, but occasionally it will not, again see Troubleshooting 5.2.

2.2 Other Distros using 2.2.x

First, download dhcpxd-1.0.3.tar.gz.

Then, download dhcpclient.cpp.patch.

Now, uncompress and untar the dhcpxd--1.0.3.tar.gz:
tar zxvf dhcpxd--1.0.3.tar.gz

Change to the dhcpxd directory you just made:
cd dhcpxd--1.0.3

Copy the patch to dhcpxd-1.0.3:
cp ../dhcpclient.cpp.patch .

Apply the patch:
patch dhcpclient.cpp dhcpclient.cpp.patch

Now make dhcpxd:
make

And install dhcpxd:
make install

Create a script(dhcpxd.script) to run dhcpxd with the contents of:
------------------------------------------------------
#!/bin/sh

DHCP_TRIES=1
until ( [ $DHCP_TRIES -eq "30" ] || (/sbin/dhcpxd -t eth0 | grep DHCPOFFER) ) do
echo "Attepmt $DHCP_TRIES Failed"
DHCP_TRIES=$[$DHCP_TRIES + 1]
done
if [ $DHCP_TRIES -lt "30" ] ; then
if (/sbin/dhcpxd eth0) ; then
echo "Success"
else
echo "Fail"
fi
else
echo "Fail"
fi
------------------------------------------------------

Now make the script executible:
chmod 700 dhcpxd.script

And run the script:
./dhcpxd

Hopefully it works, if not check out troubleshooting.

Note: I don't know anything about distros other than RedHat, so if you could fill in the details about a specific distro and how to get dhcp to work on startup, send an email.


3. Name Resolution Issues

The DHCP clients correctly set the nameservers, however the linux box's hostname is not entered into the DNS.

This can be worked around for localhost issues by updating the /etc/hosts file when the ip is assigned. However updating /etc/hosts will not allow other computers to resolve your hostname, only localhost.

One semi-workaround, is to start the smb server daemon, which can report the ip that was update in /etc/hosts to the WINS server. This will allow windows boxes on the campus network to resolve you hostname, but non-Windows machines will not be able to resolve your hostname.

Another workaround is to use a free DNS service. I suggest www.justlinux.com, which will allow you to have a name and dns entry in the penguinpowered.com domain. Also, another free DNS service is ddns.org, where your domain would be ddns.org.

3.1 Update /etc/hosts

To update the /etc/hosts dynamically, open your favorite editor, and compose a script(updateHosts) that contains(where myhost is your hostname):
------------------------------------------------------
#!/bin/sh

echo "127.0.0.1 localhost.localdomain.com localhost" > /etc/hosts
/sbin/ifconfig eth0 | awk '/inet addr/ {sub(/:/," "); \
print $3 " myhost.winthrop.edu myhost"}' >> /etc/hosts
------------------------------------------------------

Make the script executable:
chmod 700 updateHosts

Now execute the script and your /etc/hosts file should contain your current IP address:
./updateHosts

You will want to execute the script everytime you reboot your computer or bring up your ethernet device.

Note: There is a chance that the DHCP server may give you a new/different IP address when your DHCP client renews the lease to your current IP address. To solve this problem you can add a cron job to root's crontab, and have it execute the above script every 2 hours, 6 hours, or whatever.

3.2 Free DNS Service Configuration

3.2.1 Configuring penguinpowered.com

First, you need to go to http://my.justlinux.com and open an account.

Then, go to My Control Panel, login(if you are not already), and go to "Dynamic DNS services."

Now click add and enter your desired hostname, and press "Save."

Now download jlclient-1.1.tar.gz, or get the latest version from here.

Now unzip and unarchive jlclient-1.1.tar.gz:
tar zxvf jlclient-1.1.tar.gz

Now change to the jlclient-1.1 directory:
cd jlclient-1.1

Now (make sure you are root), copy jlclient.pl to /sbin/:
cp jlclient.pl /sbin/

Now create a config file(as root), following the prompts:
/sbin/jlclient.pl -c

Open your favorite editor and compose a script(dns.penuinpowered or append to updateHosts):
------------------------------------------------------
#!/bin/sh

mv /root/.jldyndns /root/.jldyndns.tmp
head -n 5 /root/.jldyndns.tmp > /root/.jldyndns
/sbin/ifconfig eth0 | awk '/inet addr/ {sub(/:/," "); print "IP=" $3}' >> /root/.jldyndns
rm /root/.jldyndns.tmp
/sbin/jlclient.pl
------------------------------------------------------

Then, make the script executable(if you did not append to updateHosts):
chmod 700 dns.penuinpowered

Then, execute the script(if you appended to updateHosts, obv. execute that):
./dns.penuinpowered

You will want to execute the script everytime you reboot your computer or bring up your ethernet device.

Note: There is a chance that the DHCP server may give you a new/different IP address when your DHCP client renews the lease to your current IP address. To solve this problem you can add a cron job to root's crontab, and have it execute the above script every 2 hours, 6 hours, or whatever.

3.2.2 Configuring ddns.org

Coming

4. Samba

4.1 Accessing Birdnest

To access Birdnest(or access Samba(WFW) shares), make sure that you have smbfs compiled into your kernel or available as a module.

The methods for accessing Birdnest, should be exactly the same for any other Samba(Windows For Workgroups/Network Neighborhood) service/share.

4.1.1 Using smbclient

You can access Birdnest via, smbclient by:
smbclient //birdnest/username -W ACC -U username

You will then be prompt for your password.

Now you should be logged on and greeted with a "smb:\>" prompt. Type help at the prompt to get a list of commands. The commands are very similar to generic "ftp", so you should feel at home.

4.1.2 Using smbmount

smbmount is a tool to mount Samba(WFW) services/shares as you would any other filesystem under Linux.

To mount your Birdnest account(where /mnt/smb is your mount point):
smbmount //birdnest/username /mnt/smb -W ACC -U username

You will then be prompt for your password.

To umount the your Birdnest account:
smbumount /mnt/smb

If you would like to be able to mount Birdnest without being root, make sure you have smbmount, smbumount, and smbmnt setuid root:
chmod 4755 smbmount smbumount smbmnt
or where ever you have the samba binaries installed.

4.2 Samba Server Configuration

You should take a look at SMB-HOWTO.

Tips for /etc/smb.conf:
Under [global] section
set: workgroup = WORKGROUP
set: encrypt passwords = yes
set: smb passwd file = /etc/smbpasswd
set: preserve case = yes
set: case sensitive = no
set: null passwords = no
set: allow hosts = 10.1.
set: security = user

If you would like users to have access to their directories:
under [home] section, set: writable = yes

If you want to have a public share:
under [public] section, set: path = /home/public
under [public] section, set: public = yes
under [public] section, set: writable = no

Note: In order to access shares make sure 95/98/NT are using encrypted passwords. Also, in order to access user shares in 95/98, it will be necessary to set the Network login/usrname in the registry.

5. Troubleshooting

5.1 Make Sure Your Ethernet Card Is Working

To ensure that your eithernet card is working, while attempting to obtain an IP address via pump or dhcpxd, run /sbin/ifconfig repeatedly to ensure your ethernet card is able to send(TX packets:) and receive(RX packets:) packets.

5.2 If you are using Red Hat, or Mandrake...

With Red Hat or Mandrake, sometimes pump seems to have a problem getting an ip address. For more reliable results use dhcpxd following the instructions in section 2.2 Other Distros using 2.2.x.

5.3 Troubleshooting with dhcpxd

dhcpxd has many options, run dhcpxd --help to see what they are. Particularly useful is the "-t" option.


Modified: Thu Feb 3 21:35:39 EST 2000
For more info and comments: winulug-info@feynman.winthrop.edu