TITLE:		DHCP client daemon
LFS VERSION:	2.4.3
AUTHOR:		Thinus Pollard <thinusp@olienhout.org.za>

SYNOPSIS:
	How to setup a DHCP client daemon. This is used with cable modems and some (most?) networks.

HINT:
I've got a DHCP based network, and after installing the 
DHCP client deamon according to Simon Perreault's <nomis80@videotron.ca> hint, 
I discovered a few things that makes it much better.

How to install and configure the DHCP client daemon according to the LFS 
standards. This works for a network card, I'm not sure about the cable 
modems. Gimme a shout if it doesn't work for you. I think the deamon goes 
and look for your network interface (compiled into the kernel) and sets it 
up accordingly. I don't know, i've only got one network card and no modems ;)

1. Get dhcpcd-1.3.19-pl2.tar.gz at ftp://ftp.phystech.com/pub/ . Unpack.

2. Execute the following in the source directory:

The archive contains some cache file that plays havoc with an LFS install ;) 
(or at least it did on mine)

    rm config.cache

Configure it:

    ./configure --prefix=/usr

There is now a bug in the Makefile that installs the config file directory 
to /usr/etc and the deamon wants it in /etc, so.......
	
    sed "s/\${prefix}\/etc/\/etc/" Makefile > Makefile2
    mv Makefile2 Makefile
	
Make and install it:
	
    make
    make install
	
As Simon said before, the deamon wants the /etc/dhcpc directory, not the 
/etc/dhcpcd dir that's created during install... (and we all know what 
happens when Simon says)

    mv /etc/dhcpcd /etc/dhcpc
	
3. And now for the magic.... by executing /usr/sbin/dhcpcd it automagically 
sets up your network card without any help from /etc/init.d/ethnet or 
/etc/sysconfig/network or  /etc/sysconfig/network-scripts/ifcfg-eth0 
or whatever
   
Create the /etc/init.d/dhcpcd script containing the following:
   
    #!/bin/sh
    # Begin /etc/init.d/dhcpcd

    source /etc/init.d/functions
   
    case "$1" in
        start)
            echo -n "Starting DHCP client deamon..."
            loadproc /usr/sbin/dhcpcd
            ;;
        stop)
            echo -n "Stopping DHCP client deamon..."
            killproc /usr/sbin/dhcpcd
            ;;
        restart)
            $0 stop
            /usr/bin/sleep 1
            $0 start
            ;;
        status)
            statusproc /usr/sbin/dhcpcd
            ;;
        *)
            echo "Usage: $0 {start|stop|restart|status}"
            exit 1
            ;;
    esac
   
    # End /etc/init.d/dhcpcd
   
4. Execute:

    chmod 754 /etc/init.d/dhcpcd
	
    cd /etc/rc0.d
    ln -s ../init.d/dhcpcd K80dhcpcd
    cd /etc/rc1.d
    ln -s ../init.d/dhcpcd K80dhcpcd
    cd /etc/rc2.d
    ln -s ../init.d/dhcpcd K80dhcpcd
    cd /etc/rc3.d
    ln -s ../init.d/dhcpcd S05dhcpcd
    cd /etc/rc4.d
    ln -s ../init.d/dhcpcd S05dhcpcd
    cd /etc/rc5.d
    ln -s ../init.d/dhcpcd S05dhcpcd
    cd /etc/rc6.d
    ln -s ../init.d/dhcpcd K80dhcpcd

5. Remove all the ethnet symlinks you can find in the rc?.d directories

6. Alas, i still don't know what to do with /etc/hosts. I've noticed 
that SuSE sets it up like this:

    127.0.0.1 localhost.localdomain localhost
    127.0.0.2 <your hostname>.<your domain> <your hostname>
	
    Everything seems to be working
   
7. I don't know what else depends on /etc/sysconfig/network (except the 
network boot scripts) Your ethernet interface doesn't need it anymore ;)

8. This is actually a pretty neat way of doing things. after you've 
run dhcpcd, take a look at ifconfig and route. You should see your setup 
in a working order if your dhcp server is set up correctly. Now kill 
the deamon and have another look... you should only see your loopback 
interface. Pretty nifty...
   
I hope this helps somebody out there ;) My thanks to Simon for the 
original version of the DHCP hint. Please let me know what you 
think/suggestions by mailing to thinusp@olienhout.org.za


