案例一 :单一区域的管理
需求分析:
在一个局域网中搭建dhcp服务器并为该网段分配各网关参数
示意图:

实现步骤:
dhcpserver 的搭建 选择vmnet3网卡
1:安装dhcp-3.0.5-21.el5.i386.rpm
[root@zzu ~]# mount /dev/cdrom /mnt/cdrom/
[root@zzu ~]# cd /mnt/cdrom/Server/
[root@zzu Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
warning: dhcp-3.0.5-21.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
2: 查询dhcp的配置文件的所在的位置
[root@zzu Server]# rpm -qc dhcp
/etc/dhcpd.conf
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcrelay
/var/lib/dhcpd/dhcpd.leases
3:修改dhcp的配置文件
[root@zzu Server]# vim /etc/dhcpd.conf 在这里我们可以参考dhcp的模板配置文件
:r /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample(底行模式下执行)
1 #
2 ddns-update-style interim;
3 ignore client-updates; 动态的刷新客户端的信息
4
5 subnet 192.168.10.0 netmask 255.255.255.0 {
6
7 # --- default gateway
8 option routers 192.168.10.254; 网关地址
9 option subnet-mask 255.255.255.0; 子网掩码
10
11 option domain-name "www.test.com"; 域名
12 option domain-name-servers 222.88.88.88,222.85.85.85; 域名服务器的地址,注意两个ip地址之间需要要逗号分隔开才行
13
14 option time-offset -18000; # Eastern Standard Time
15 # option ntp-servers 192.168.1.1;
16 # option netbios-name-servers 192.168.1.1;
17 # --- Selects point-to-point node (default is hybrid). Don't change this unless
18 # -- you understand Netbios very well
19 # option netbios-node-type 2;
20
21 range dynamic-bootp 192.168.10.1 192.168.10.253; ip的范围
22 default-lease-time 21600;默认的租约时间为6小时
23 max-lease-time 43200;最大的租约时间为12小时
24
25 # we want the nameserver to appear at a fixed address ip地址的绑定
26 host ns {
27 {ext-server marvin.RedHat.com;
28 hardware ethernet 12:34:56:78:AB:CD;
29 fixed-address 207.175.42.254;
30 }
31 }
32 # DHCP Server Configuration file.
--
21,47-54 71
33 # see /usr/share/doc/dhcp*/dhcpd.conf.sample
4:重启dhcp服务
[root@zzu Server]# service dhcpd configtest 检测dhcpd.conf的语法是否正确
[root@zzu Server]# service dhcpd restart 重启dhcp服务
.. dhcpd [ok]
[root@zzu Server]# netstat -tupln |grep dhcpd
udp 0 0 0.0.0.0:67 0.0.0.0:*
[root@zzu ~]# chkconfig dhcpd on 设置dhcpd为自动启动
[root@zzu ~]# chkconfig --list|grep dhcp dhcpd 查看dhcp在各个运行级别中的自启动状态
0:off 1:off 2:on 3:on 4:on 5:on 6:off
5:在客户端进行验证 在这里我们将dhcp server 和客户机均放在vmnet 3 区域


6:客户端的查看 我们已经得到了相应的ip地址参数,以及相应的域名

后续;实现对ip地址的绑定 ,是的特定的主机总是得到同样的ip地址
我们只需要最/etc/dhcpd.conf进行修改即可
[root@zzu ~]# vim /etc/dhcpd.conf
1 #
2 ddns-update-style interim;
3 ignore client-updates;
4
5 subnet 192.168.10.0 netmask 255.255.255.0 {
6
7 # --- default gateway
8 option routers 192.168.10.254;
9 option subnet-mask 255.255.255.0;
10 option domain-name "test.com";
10 option domain-name "test.com";
11 option domain-name-servers 222.88.88.88,222.85.85.85;
12
13 option time-offset -18000;
14 # Eastern Standard Time
15 # option ntp-servers 192.168.1.1;
16 # option netbios-name-servers 192.168.1.1;
12
13 option time-offset -18000;
14 # Eastern Standard Time
15 # option ntp-servers 192.168.1.1;
16 # option netbios-name-servers 192.168.1.1;
17 # --- Selects point-to-point node (default is hybrid). Don't change this unless
18 # -- you understand Netbios very well
19 # option netbios-node-type 2;
20
21 range dynamic-bootp 192.168.10.1 192.168.10.111;
range dynamic-bootp 192.168.10.113 192.168.10.253;
22 default-lease-time 21600;
23 max-lease-time 43200;
24
25 # we want the nameserver to appear at a fixed address
26 host test {
27 next-server marvin.redhat.com;
28 hardware ethernet 00:0c:29:18:30:8b; 客户端的mac地址
29 fixed-address 192.168.10.112;
30 }
31 host ns {
32 next-server marvin.redhat.com;
33 hardware ethernet 12:34:56:78:AB:CD;
34 fixed-address 202.196.64.1;
35 }
36 }
37 # DHCP Server Configuration file.
38 # see /usr/share/doc/dhcp*/dhcpd.conf.sample
-- INSERT --
[root@zzu ~]# service dhcpd restart 重新启动该服务
再次测试

查看错误时,经常查看相关的日志
/var/log/message /var/lib/dhcpd/dhcp.release
