*** From dhcp-server -- To unsubscribe, see the end of this message. ***

Here's how I'm doing it today.  Any suggestions for improvement are welcome.

Server Master runs dhcpd 24/7.  Server Slave has dhcpd installed but not
running.  These are both redhat intel linux 5.1 with ISC dhcpd 2 pl 6.

Master

Master runs a cron job every 5 minutes to enable Slave to copy its
/etc/dhcpd.leases and /etc/dhcpd.conf files.  Here is the script:

cp -af /etc/dhcpd.conf /tftpboot
cp -af /etc/dhcpd.leases /tftpboot
cp -af /etc/dhcpd.leases~ /tftpboot

Note that I have tftpd running as user nobody, and that this tftpd is
restricted to one directory tree.

Slave

Slave runs a cron job every 5 minutes to:
a) copy the /etc/dhcpd.leases and /etc/dhcpd.conf files from Master, and
b) to test the functionality of Master's dhcpd server, and 
c) to turn on or off Slave's dhcpd server when needed.

The script that copies the files from Master:

cat tftp.cmds | tftp
chmod 0644 dhcpd.conf
[ -s dhcpd.conf ] && cp -af dhcpd.conf /etc/dhcpd.conf
rm -f dhcpd.conf
chmod 0664 dhcpd.leases
[ -s dhcpd.leases ] && cp -af dhcpd.leases /etc/dhcpd.leases
rm -f dhcpd.leases
chmod 0664 dhcpd.leases~
[ -s dhcpd.leases~ ] && cp -af dhcpd.leases~ /etc/dhcpd.leases~
rm -f dhcpd.leases~

Note that tftp will create 0 length files when attempting to get files from a
downed server, therefore the file size checking above.  The tftp.cmds referred
to above:

connect Master
get dhcpd.conf
get dhcpd.leases
get dhcpd.leases~
quit

The script that tests Master's dhcpd server via a bootp request and that
controls Slave's dhcpd server:

#!/bin/sh
#
# load status function
. /etc/rc.d/init.d/functions

# define some vars
DEV=eth0
RIF="--returniffail"
NOMESSAGE="Bootp failed."
YESMESSAGE="Bootp succeeded."
TMPFILE=/tmp/bootp-results.$$
BOOTPC=/sbin/bootpc
IFCONFIG='echo ifconfig'
ROUTE='echo route'
BINHOST='echo hostname'
RCONF=/tmp/resolv.conf
EHOSTS=/tmp/hosts
LHOSTS=/dev/null
ASKSERVER="12.27.58.17"
TW="--timeoutwait 30"

# Perform the bootp client attempt
if ${BOOTPC} --dev ${DEV} --server ${ASKSERVER} ${RIF} ${TW} > ${TMPFILE}
then # bootpc succeeded and got an ip num from Master
  rm -f ${TMPFILE}
  echo ${YESMESSAGE}
  # if dhcpd is running, stop it.
  status /usr/sbin/dhcpd && /etc/rc.d/init.d/dhcpd stop
else # bootpc failed to get an ip num from Master
  echo ${NOMESSAGE}
  # if dhcpd is not running, start it.
  status /usr/sbin/dhcpd || /etc/rc.d/init.d/dhcpd start
fi
exit 0

Note that ASKSERVER above is the IP number of the Master server.  The
/etc/rc.d/init.d/dhcpd script referred to above (and used on both servers):

#!/bin/sh
#
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/sbin/dhcpd ] || exit 0
[ -f /etc/dhcpd.conf ] || exit 0
[ -f /etc/dhcpd.leases ] || exit 0
# See how we were called.
case "$1" in
  start)
        # Start daemons.
        echo -n "Starting dhcpd: "
        /usr/sbin/dhcpd
        echo
        touch /var/lock/subsys/dhcpd
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down dhcpd: "
        killproc /usr/sbin/dhcpd
        echo
        rm -f /var/lock/subsys/dhcpd
        ;;
  status)
        status /usr/sbin/dhcpd
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: dhcpd {start|stop|restart|status}"
        exit 1
esac

exit 0

Sincerely,
Leo Wierzbowski
[EMAIL PROTECTED]



------------------------------------------------------------------------------
To unsubscribe from this list, please visit http://www.fugue.com/dhcp/lists
If you are without web access, or if you are having trouble with the web page,
please send mail to [EMAIL PROTECTED]   Please try to use the web
page first - it will take a long time for your request to be processed by hand.
------------------------------------------------------------------------------

Reply via email to