DHCP (Dynamic Host Configuration Protocol) Server
# tar -zxvf dhcp-latest.tar.gz # cd dhcp-latest # ./configure # make # make install # touch /var/state/dhcp/dhcpd.leases #
/var/state/dhcp
/etc/dhcpd.conf
##
## dhcpd.conf
##
server-identifier yui.mine.nu; #
option domain-name "yui.mine.nu"; #
option domain-name-servers yui.mine.nu; # DNS
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 { #
option routers 192.168.1.1; #
option subnet-mask 255.255.255.0; #
option broadcast-address 192.168.1.255; #
default-lease-time 21600; #
max-lease-time 43200; #
range 192.168.1.100 192.168.1.200; # IP
}
/usr/sbin/dhcpd eth0
#!/bin/sh
#
# dhcpd This shell script takes care of starting and stopping dhcpd.
#
# chkconfig: 2345 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
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting dhcpd: "
route add -host 255.255.255.255 dev eth1
daemon /usr/sbin/dhcpd eth1
echo
touch /var/lock/subsys/dhcpd
;;
stop)
# Stop daemons.
echo -n "Shutting down dhcpd: "
route del -host 255.255.255.255 dev eth1
killproc dhcpd
echo
rm -f /var/lock/subsys/dhcpd
;;
restart)
$0 stop
$0 start
;;
status)
status dhcpd
;;
*)
echo "Usage: dhcpd {start|stop|restart|status}"
exit 1
esac
exit 0