放入ISO镜像,如下执行即可成功搭建一个DHCP服务器。
进入光盘rpm安装包所在目录。
[root@searu ~]cd /media/CentOS_5.5_Final/CentOS/
查看所有已安装dhcp相关包。
[root@searu CentOS]# rpm -qa |grep dhcp
dhcpv6-client-1.0.10-18.el5
安装dhcp包,首先可以查看下目录下的dhcp包,# ls | grep dhcp。
[root@searu CentOS]# rpm -ih dhcp-3.0.5-23.el5.i386.rpm
##########################################[100%]
########################################### [100%]
[root@searu CentOS]# rpm -qa |grep dhcp
dhcp-3.0.5-23.el5
dhcpv6-client-1.0.10-18.el5
可以了解下dhcp软件包安装到系统的文件。
[root@searu CentOS]# rpm -ql dhcp
/etc/dhcpd.conf
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcrelay
/usr/bin/omshell
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-3.0.5
/usr/share/doc/dhcp-3.0.5/IANA-arp-parameters
/usr/share/doc/dhcp-3.0.5/README
/usr/share/doc/dhcp-3.0.5/RELNOTES
/usr/share/doc/dhcp-3.0.5/api+protocol
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-authentication-14.txt
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-dhcp-dns-12.txt
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-failover-07.txt
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient-script.8
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.8
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.conf.5
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.leases.5
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhcp-eval.5
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhcp-options.5
/usr/share/doc/dhcp-3.0.5/rfc1542.txt
/usr/share/doc/dhcp-3.0.5/rfc2131.txt
/usr/share/doc/dhcp-3.0.5/rfc2132.txt
/usr/share/doc/dhcp-3.0.5/rfc2485.txt
/usr/share/doc/dhcp-3.0.5/rfc2489.txt
/usr/share/doc/dhcp-3.0.5/rfc951.txt
/usr/share/man/man1/omshell.1.gz
/usr/share/man/man5/dhcp-eval.5.gz
/usr/share/man/man5/dhcp-options.5.gz
/usr/share/man/man5/dhcpd-eval.5.gz
/usr/share/man/man5/dhcpd-options.5.gz
/usr/share/man/man5/dhcpd.conf.5.gz
/usr/share/man/man5/dhcpd.leases.5.gz
/usr/share/man/man8/dhcpd.8.gz
/usr/share/man/man8/dhcrelay.8.gz
/var/lib/dhcpd
/var/lib/dhcpd/dhcpd.leases
[root@searu CentOS]# cd ~
建一个配置文件,你可以拷贝这个dhcpd.conf.sample,当然熟悉的话可以手动直接建立一个。
[root@searu ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp: overwrite `/etc/dhcpd.conf’? y
配置一下dhcpd.conf配置文件。
[root@searu ~]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
# — default gateway
option routers 192.168.1.22;
option subnet-mask 255.255.255.0;
option nis-domain “searu.org”;
option domain-name “searu.org”;
option domain-name-servers 192.168.1.22;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# — Selects point-to-point node (default is hybrid). Don’t change this unless
# — you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.1.10 192.168.1.30;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
开启dhcpd服务。
[root@searu ~]# service dhcpd restart
Starting dhcpd: [ OK ]
查看已分配的动态地址。
[root@searu ~]# cat /var/lib/dhcpd/dhcpd.leases
# All times in this file are in UTC (GMT), not your local timezone. This is
# not a bug, so please don’t ask about it. There is no portable way to
# store leases in the local timezone, so please don’t request this as a
# feature. If this is inconvenient or confusing to you, we sincerely
# apologize. Seriously, though – don’t ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0.5-RedHat
lease 192.168.1.30
{
starts 0 2011/07/03 12:22:40;
ends 0 2011/07/03 18:22:40;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:87:0e:2f;
uid “\001\000\014)\207\016/”;
client-hostname “4161ed4a8d0d4b3″;
}
[root@searu ~]#
发表回复