一、需求

1. 创建一个基于 192.168.10.88/26 网段的 DHCP 服务器

2. 地址池为本子网网段的所有有效地址

3. 网关为本子网网段的最大 IP 地址

4. 保留主机,主机名 www ,其 IP 地址为 192.168.10.68 ,其 MAC 地址为:11:14:56:38:D3:ED

二、实验配置文件

1./etc/dhcpd.conf

2./usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample

3./etc/sysconfig/dhcpd

三、配置主配置文件

[root@linux etc]# ipcalc -bmn 192.168.10.88/26

NETMASK=255.255.255.192

BROADCAST=192.168.10.127

NETWORK=192.168.10.64

[root@linux etc]#vi /etc/dhcpd.conf

[root@linux etc]# grep -v "#" /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.10.64 netmask 255.255.255.192 {

option routers 192.168.10.126;

#默认网关

option subnet-mask 255.255.255.192;

#子网掩码

option domain-name "gd-linux.com";

#域名

option domain-name-servers 192.168.10.7;

#域名服务器ip地址

range dynamic-bootp 192.168.10.65 192.168.10.126;

#可获得的ip地址范围

default-lease-time 21600;

#默认释放时间(秒)

max-lease-time 43200;

#默认最大释放时间(秒)

host www{

#保留主机名

  hardware ethernet 11:14:56:38:D3:ED;

  fixed-address 192.168.10.68;

#保留主机的mac和ip地址

}

}

 

四、启动dhcp服务

[root@linux etc]# vi /etc/sysconfig/dhcpd

[root@linux etc]# cat /etc/sysconfig/dhcpd

# Command line options here

DHCPDARGS="eth0"

[root@linux etc]#ifconfig eth0 192.168.10.67 netmask 255.255.255.192

[root@linux etc]# service dhcpd start

启动 dhcpd [ 确定 ]

[root@linux etc]# ps -aux |grep dhcpd

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ root 7780 0.0 0.2 4024 1524 ? Ss 13:37 0:00 /usr/sbin/dhcpd eth0 root 7804 0.0 0.1 5564 692 pts/1 R+ 13:43 0:00 grep dhcpd

[root@linux etc]# netstat -anup |grep :67

udp 0 0 0.0.0.0:67 0.0.0.0:* 7780/dhcpd

 

五、在linux客户端测试

[root@localhost ~]# dhclient

[root@localhost dhcp]# cat /var/lib/dhcp/dhclient.leases

lease {

interface "eth0";

fixed-address 192.168.10.125;

option subnet-mask 255.255.255.192;

option routers 192.168.10.126;

option dhcp-lease-time 21600;

option dhcp-message-type 5;

option domain-name-servers 192.168.1.7;

option dhcp-server-identifier 192.168.1.7;

option domain-name "gd-linux.com";

renew 1 2013/4/10 11:28:13;

rebind 1 2013/4/10 13:45:39;

expire 1 2013/4/10 14:30:39;

}