DHCP服务器搭建案例(多作用域环境)
一、案例环境
dhcp主服务器: dhcp.example.com 192.168.32.31 gateway:192.168.32.254
中继代理服务器1:d1.example.com 192.168.40.31 gateway:192.168.40.254
中继代理服务器2:d2.example.com 192.9.210.31 gateway: 192.9.210.254
二、dhcp主服务器配置
1、安装和启动
[root@dhcp ~]#yum install dhcp.i386
[root@dhcp ~]#yum install dhcp-devel.i386
[root@dhcp ~]#chkconfig dhcpd on
[root@dhcp ~]#service dhcpd start
2、dhcp服务配置
[root@dhcp ~]#vi /etc/sysconfig/dhcpd
DHCPDARGS=eth0 #指定接收dhcp客户端DHCPDiscover包的网络接口
[root@dhcp ~]#cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
[root@dhcp ~]#vi /etc/dhcpd.conf
#全局参数配置
option domain-name-servers 192.168.32.31;
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;
ddns-update-style interim;
#指定支持DNS动态更新方式,none:不支持、interim:DNS互动模式、ad-doc:特殊DNS更新方式,默认interim或none,无需修改
ignore client-updates;
#网段192.168.32.0/24的dhcp参数配置
subnet 192.168.32.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.32.254; #网关
option subnet-mask 255.255.255.0; #子网掩码
option nis-domain "notexample"; #NIS域
option domain-name "kvm.com";
option domain-name-servers 192.168.32.31;
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.32.41 192.168.32.44;
#IP地址分配访问,可多个range
default-lease-time 21600; #指定默认租约时间,单位秒
max-lease-time 43200; #最长租约时间,单位秒
next-server 192.168.32.31;
#指定客户端初始启动文件存放服务器,如无在为dhcp服务器本身,pxe网络安装需要此参数
filename "/pxelinux.0";
#指定客户端启动要载入的初始启动文件(一般在tftp服务器主目录下),pxe网络安装或无盘工作站需要此参数
# we want the nameserver to appear at a fixed address
host rche{ #为特定主机保留IP
next-server rhce.kvm.com;
hardware ethernet 54:52:00:28:6D:78; #特定主机的MAC地址
fixed-address 192.168.32.41;
option domain-name-servers 202.106.0.20
option domain-name-servers 202.106.196.115
}
shared-network trains { #指定超级作用域
group { #组选项,为特定范围指定参数
option domain-name-servers 192.168.32.31;
option time-offset -18000; # Eastern Standard Time
option ntp-servers 192.168.3.1;
subnet 192.9.210.0 netmask 255.255.255.0 {
option routers 192.9.210.254;
option subnet-mask 256.255.255.0;
option time-offset -18000;
range dynamic-bootp 192.9.210.20 192.9.210.30;
default-lease-time 21600;
max-lease-time 43200;
}
subnet 192.168.40.0 netmask 255.255.255.0 {
option routers 192.168.40.254;
option subnet-mask 255.255.255.0;
option time-offset -18000;
range dynamic-bootp 192.168.40.41 192.168.40.50
range dynamic-bootp 192.168.40.61 192.168.40.70
default-lease-time 21600;
max-lease-time 43200;
}
}
三、中继代理服务器配置
1、安装和启动(d1和d2配置完全相同)
[root@d1 ~]#yum install dhcp.i386
[root@d1 ~]#yum install dhcp-devel.i386
[root@d1 ~]#chkconfig dhcrelay on
[root@d1 ~]#service dhcrelay start
2、中继代理服务配置
[root@d1 ~]#vi /etc/sysconfig/dhcrelay
INTERFACES=eth0 #指定接收dhcp客户端DHCPDiscover包的网络接口
DHCPSERVERS=“192.168.32.31” #指定dhcp服务器
[root@d1 ~]#vi /etc/sysctl.conf
net.ipv4.ip_forward = 1 #开启ip数据转发
[root@d1 ~]#sysctl -p
四、客户端配置
这个大家都会,就不再多说了。
本文转自netsword 51CTO博客,原文链接:http://blog.51cto.com/netsword/497343