[oclug] Configuring DHCP Server to issue addresses on only on e
interface
Jonathan Earle
jearle at nortelnetworks.com
Thu Jan 18 12:32:54 EST 2001
Here's my dhcpd setup. The config file is fairly straightforward, and the
script just calls the binary with the eth port as it's sole argument. This
setup allowed me to get my Windows and Linux machines running throughout the
house with no pain.
Further, you mentioned two script fragments. There is in fact, only one
script that James posted. The 'EOF' which you believe starts the 2nd
fragment is a marker that matches the 'cat << EOF' which resides in what you
believe to be the 1st fragment. The result of this 'cat << EOF .... EOF' is
that the text (represented in my example by ....) is printed on the screen.
It saves the scriptwriter a whole lot of 'echo ...' statements and forced
formatting.
----------8<-- /etc/dhcpd.conf -----------
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.40;
default-lease-time 86400;
max-lease-time 172800;
authoritative;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option routers 192.168.10.1;
option domain-name "domainname.com";
# option domain-name-servers 24.2.9.33, 24.2.9.34;
option domain-name-servers 192.168.10.1;
}
----------8<------------------------------
----------8<-- /etc/rc.d/init.d/dhcpd ----
#!/bin/sh
#
# dhcpd This shell script takes care of starting and stopping
# dhcpd.
#
# chkconfig: - 65 35
# description: dhcpd provide access to Dynamic Host Control Protocol.
# 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
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting dhcpd: "
daemon /usr/sbin/dhcpd eth0
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
;;
stop)
# Stop daemons.
echo -n "Shutting down dhcpd: "
killproc dhcpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcpd
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
status dhcpd
RETVAL=$?
;;
*)
echo "Usage: dhcpd {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
----------8<------------------------------
Cheers!
Jon
> Is that all? :-) Seriously though, (and please pardon my
> newbie-ness) I see
> two script fragments here. I way I see it, script fragment
> #1 (the one
> beginning with #! /bin/sh) goes into the /etc/init.d/dhcp,
> then I edit
> /etc/dhcpd.conf, and then I add script fragment #2 (the one
> that begins with
> EOF(?)) to /etc/init.d/dhcp. Is this the process you are
> suggesting, or did
> some things end up a bit jumbled. Or is it my brain that is
> a bit jumbled
> (which would be an improvement)?
>
> Second, could you indicate exactly where I would add the
> desired interface
> (which happens to be eth0) over which DHCP will do its thing?
>
> Thanks for clarifying,
> BB
>
>
> >From: James Leigh <james.leigh at ottawa.com>
> >Reply-To: oclug at lists.oclug.on.ca
> >To: oclug at lists.oclug.on.ca
> >Subject: RE: [oclug] Configuring DHCP Server to issue
> addresses on only on
> >e interface
> >Date: Wed, 17 Jan 2001 18:07:48 -0500
> >
> >Brian,
> >
> >I stick this argument into the /etc/init.d/dhcp startup
> script (see below).
> > Works for me! :)
> >
> >james
> >
> >
> >On Wed, 17 Jan 2001 16:55:08 Jonathan Earle wrote:
> > > IIRC, you just give the eth interface as an arg to dhcpd.
> > >
> > > # dhcpd eth0
> > >
> > > Jon
> > >
> >#! /bin/sh
> >#
> ># Start or stop dhcpd daemon
> >#
> >
> ># Add all interfaces you want dhcpd to handle here
> >
> >test -x /usr/sbin/dhcpd || exit 0
> >
> ># Set run_dhcpd to 1 to start dhcpd at boot or 0 to disable it.
> >run_dhcpd=1
> >
> ># interfaces to run on
> >IF="eth1"
> >
> >if [ $run_dhcpd = 0 ]; then
> > cat <<EOF
> >
> >Please edit the file /etc/dhcpd.conf according to your
> needs. The current
> >/etc/dhcpd.conf is just the sample file that is provided
> with the DHCP
> >package from the Internet Software Consortium, so it will
> not be useful
> >at all for you.
> >
> >After you have edited /etc/dhcpd.conf you will have to edit
> >/etc/init.d/dhcp as well. There you will have to set the variable
> >run_dhcpd to 1, and then type "/etc/init.d/dhcp start" to start the
> >dhcpd daemon.
> >
> >EOF
> > exit 0
> >fi
> >
> >DHCPDPID=/var/run/dhcpd.pid
> >
> >case "$1" in
> > start)
> > start-stop-daemon --start --quiet --pidfile $DHCPDPID \
> > --exec /usr/sbin/dhcpd -- -q $IF
> > ;;
> > stop)
> > start-stop-daemon --stop --quiet --pidfile $DHCPDPID
> > ;;
> > restart)
> > start-stop-daemon --stop --quiet --pidfile $DHCPDPID
> > sleep 2
> > start-stop-daemon --start --quiet --pidfile $DHCPDPID \
> > --exec /usr/sbin/dhcpd -- -q $IF
> > ;;
> > *)
> > echo "Usage: /etc/init.d/dhcp {start|stop|restart}"
> > exit 1
> >esac
> >
> >exit 0
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tux.oclug.on.ca/pipermail/oclug/attachments/20010118/bff65b15/attachment.htm
More information about the OCLUG
mailing list