这一篇介绍了一下RHEL DHCP服务器配置,从DHCP服务器软件的安装开始。
[root@bys dhcp]# rpm -e dhcp #卸载DHCP相关的软件 提示无法卸载。是与另一文件关联
error: Failed dependencies:
dhcp = 12:3.0.5-23.el5 is needed by (installed) dhcp-devel-3.0.5-23.el5.i386
[root@bys dhcp]# rpm -e dhcp-devel #先卸载dhcp-devel
[root@bys dhcp]# rpm -e dhcp #再卸载dhcp
[root@bys dhcp]# rpm -qa\grep dhcp
rpmq: one type of query/verify may be performed at a time
[root@bys dhcp]# rpm -qa|grep dhcp #查询下与dhcp关联的软件
dhcpv6-client-1.0.10-18.el5
[root@bys dhcp]# rpm -e dhcpv6-client #继续卸载
[root@bys dhcp]# rpm -qa|grep dhcp #再查询一下
[root@bys dhcp]# ls #安装文件是通过从系统安装盘CP过来的。
dhcp-3.0.5-23.el5.i386.rpm
dhcp-devel-3.0.5-23.el5.i386.rpm
dhcpv6-1.0.10-18.el5.i386.rpm
[root@bys dhcp]# rpm -ivh dhcp-3.0.5-23.el5.i386.rpm #进行软件安装,这几个相关软件安装不分先后
warning: dhcp-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
[root@bys dhcp]# rpm -ivh dhcp-devel-3.0.5-23.el5.i386.rpm
warning: dhcp-devel-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp-devel ########################################### [100%]
[root@bys dhcp]# ls
dhclient-3.0.5-23.el5.i386.rpm
dhcp-3.0.5-23.el5.i386.rpm
dhcp-devel-3.0.5-23.el5.i386.rpm
dhcpv6-1.0.10-18.el5.i386.rpm
dhcpv6-client-1.0.10-18.el5.i386.rpm
[root@bys dhcp]# rpm -ivh dhcpv6-client-1.0.10-18.el5.i386.rpm
warning: dhcpv6-client-1.0.10-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcpv6-client ########################################### [100%]
[root@bys dhcp]# rpm -ivh dhclient-3.0.5-23.el5.i386.rpm
warning: dhclient-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package dhclient-3.0.5-23.el5.i386 is already installed
[root@bys dhcp]# rpm -ivh dhcpv6-1.0.10-18.el5.i386.rpm
warning: dhcpv6-1.0.10-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcpv6 ########################################### [100%]
[root@bys dhcp]# rpm -qa|grep dhcp
dhcp-3.0.5-23.el5
dhcpv6-1.0.10-18.el5
dhcpv6-client-1.0.10-18.el5
dhcp-devel-3.0.5-23.el5
[root@bys ~]# cd /usr/share/doc/dhcp-3.0.5
[root@bys dhcp-3.0.5]# ls
api+protocol RELNOTES
dhcpd.conf.sample rfc1542.txt
draft-ietf-dhc-authentication-14.txt rfc2131.txt
draft-ietf-dhc-dhcp-dns-12.txt rfc2132.txt
draft-ietf-dhc-failover-07.txt rfc2485.txt
IANA-arp-parameters rfc2489.txt
ja_JP.eucJP rfc951.txt
README
[root@bys etc]# rm -f dhcpd.conf #将/etc/dhcpd.conf删除
[root@bys etc]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sam
ple /etc/dhcpd.conf #将示例文件CP为/etc/dhcpd.conf
[root@bys etc]# vi dhcpd.conf # 编辑/etc/dhcpd.conf
ddns-update-style interim; # 动态DNS。可以设置为none.这里是默认设置,未作更改
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 { #设置IP作用域为192.168.0.0/24
# --- default gateway
option routers 192.168.0.1; #设置网关
option subnet-mask 255.255.255.0; #设置掩码
option nis-domain "bys.com"; #设置为与主机同样的域名
option domain-name "bys.com"; #设置为与主机同样的域名
option domain-name-servers 202.102.224.68,202.102.227.68; #设置DNS服务器IP(河南的)中间逗号隔开
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.0.5; #设置NTP服务器IP
# option netbios-name-servers 192.168.0.5; #设置NETBIOS服务器IP
# --- 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.0.20 192.168.0.30; #设置地址池范围
default-lease-time 600; #设置地址的租期
max-lease-time 1200; #设置地址的最大租期
# we want the nameserver to appear at a fixed address
host ns { #用于为特定主机指定固定IP
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD; #特定主机MAC
fixed-address 207.175.42.254; #指定的IP
}
}
[root@bys etc]# dhcpd #启动dhcpd进程
Internet Systems Consortium DHCP Server V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
WARNING: Host declarations are global. They are not limited to the scope you declared them in.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 1 leases to leases file.
Listening on LPF/eth0/00:0c:29:88:4e:9c/192.168.0/24
Sending on LPF/eth0/00:0c:29:88:4e:9c/192.168.0/24
Sending on Socket/fallback/fallback-net
[root@bys ~]# service dhcpd status #查看DHCPD 服务状态
dhcpd (pid 4913) is running...
[root@bys etc]# ps -eaf|grep dhcp #查看进程是否启动
root 3506 1 0 07:23 ? 00:00:00 dhcpd
root 3510 3452 0 07:24 pts/1 00:00:00 grep dhcp
[root@bys etc]# netstat -an|grep :67 #查看67端口是否已经开始监听
udp 0 0 0.0.0.0:67 0.0.0.0:*
[root@bys ~]# tail -n 30 /var/log/messages 查看日志文件的输出,-n显示最近3条
附:租约文件dhcpd.leases部分内容,RHTL5中文件在/var/lib/dhcpd/dhcpd.leases
[root@bys dhcpd]# more 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.0.30 {
starts 2 2011/06/28 01:02:53;
ends 2 2011/06/28 01:05:52;
tstp 2 2011/06/28 01:05:52;
binding state free;
hardware ethernet 00:a0:e8:09:01:17;
uid "\001\000\240\350\011\001\027";
}
lease 192.168.0.29 {
starts 2 2011/06/28 07:33:13;
ends 2 2011/06/28 07:43:13;
tstp 2 2011/06/28 07:43:13;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:1c:36:f8;
uid "\001\000\014)\0346\370";
client-hostname "bestbys";
}
lease 192.168.0.30 {
starts 2 2011/06/28 07:37:14;
ends 2 2011/06/28 07:47:14;
binding state active;
next binding state free;
hardware ethernet 00:a0:e8:09:01:17;
uid "\001\000\240\350\011\001\027";
client-hostname "bys";
}
lease 192.168.0.30 {
starts 2 2011/06/28 07:37:17;
ends 2 2011/06/28 07:47:17;
binding state active;
next binding state free;
hardware ethernet 00:a0:e8:09:01:17;
uid "\001\000\240\350\011\001\027";
client-hostname "bys";
RHEL 5客户端启动DHCP方法:修改配置文件/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static 这个地方改成dhcp ,重启网络服务HWADDR=00:0C:29:88:4E:9C
ONBOOT=yes
DHCP_HOSTNAME=bys.com
IPADDR=192.168.0.5
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
本文转自 还不算晕 51CTO博客,原文链接:http://blog.51cto.com/haibusuanyun/598582