搭建DHCP Server(原创)
作者: 曲文庆 日期: 2008-10-31 11:32
以前一直使用静态ip建网,但是如果来人,现分配ip毕竟很麻烦,决定建立一个DHCP Server。
操作系统:CentOS 5
DHCP:DHCP 4.1.0a2 (http://ftp.isc.org/isc/dhcp/dhcp-4.1.0a2.tar.gz)
安装DHCP Server:
#wget http://ftp.isc.org/isc/dhcp/dhcp-4.1.0a2.tar.gz
#tar zxvf dhcp-4.1.0a2.tar.gz
#cd dhcp-4.1.0a2
#./configure --prefix=/usr/local/dhcp --disable-dhcpv6
#make
#make install
配置DHCP Server:
#cd /usr/local/dhcp/etc
#ln -s /usr/local/dhcp/etc/dhcpd.conf /etc/dhcpd.conf
#vi dhcpd.conf
option domain-name-servers 219.146.0.130, 219.150.32.132;
default-lease-time 86400;
max-lease-time 86400;
option time-offset -18000;
log-facility local7;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.130;
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
option time-offset -18000;
}
呵呵,是不是很简单?
创建启动脚本:
#vi /etc/init.d/dhcpd
#!/bin/sh
#
#
# chkconfig: 2345 07 93
#
# description: DHCPD
#
# Script Author: Qu WenQing
state=$1
PREFIX=/usr/local/dhcp
DHCPDARGS="eth0"
PIDF=/var/run/dhcpd.pid
CONFIG=/etc/dhcpd.conf
LEASE=/var/db/dhcpd.leases
START ()
{
if [ ! -f ${LEASE} ]; then
touch ${LEASE}
fi
if [ -f ${PREFIX}/sbin/dhcpd ]; then
echo "Starting the ISC DHCP server"
${PREFIX}/sbin/dhcpd -cf ${CONFIG} -lf ${LEASE} ${DHCPDARGS}
fi
}
STOP ()
{
if [ -f ${PIDF} ]; then
PID=`cat ${PIDF}`
if [ -d /proc/$PID ]; then
echo "Stopping the ISC DHCP server"
kill $PID
fi
fi
}
case $state in
start)
START
;;
stop)
STOP
;;
restart)
STOP
START
;;
esac
exit 0
保存,设置为可执行
#service dhcpd start
Starting the ISC DHCP server
Internet Systems Consortium DHCP Server 4.1.0a2
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Wrote 2 leases to leases file.
Listening on LPF/eth0/00:10:dc:71:d0:c5/192.168.0.0/24
Sending on LPF/eth0/00:10:dc:71:d0:c5/192.168.0.0/24
Sending on Socket/fallback/fallback-net
OK,启动成功。
Nginx配置PHP的一个关键注意点 (2009-02-02 17:20)
今冬第一雪 (2008-12-21 16:13)
油价终于下调了 (2008-12-19 09:25)
SSH连接慢问题解决 (2008-12-02 16:37)
Linux下的Memcache安装 (2008-12-02 16:26)
搭建Lighttpd的SSL模块(原创) (2008-11-05 16:32)
让PHP5支持java(原创) (2008-11-04 20:35)
yum Could not find any working storages 问题处理(原创) (2008-11-04 20:23)
让CentOS支持4G以上内存(原创) (2008-11-04 20:05)