linux下DHCP服务的搭建
DHCP所使用的端口67,68
首先rpm -qa |grep dhcp*
检查系统是否安装如果没有,则:
所需软件包dhcp-3.0.5-21.el5.i386.rpm
可用yum来安装,当然前提是你的本地yum已经配置好:yum install dhcp -y来安装
安装完成DHCP的主配置文件在/etc/dhcpd.conf他的帮助配置文件在/usr/share/doc/dhcp*/dhcpd.conf.sample下我们可以把他复制过来
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
接下来我们就可以对配置文件进行修改了
ddns-update-style interim;
#DHCP指定DNS动态更新方式主要有以下几种(none|interim|ad_doc)
#none:不支持
#interim:DNS互动全新模式
#ad-hoc:特殊DNS更新模式
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
#此处规定一个作用域
# --- default gateway
option routers 192.168.0.1; #制定客户端默认网关
option subnet-mask 255.255.255.0; #指定客户端默认子网掩码
option nis-domain "domain.org"; #指定客户端NIS域名
option domain-name "domain.org"; #指定客户端DNS后辍
option domain-name-servers 192.168.1.1; #指定客户端DNS服务器IP地址,可以指明多个IP,中间用逗号隔开
range 192.168.0.128 192.168.0.254; #客户端可以讲求到的DNSIP地址范围
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;
}
#此处选项用于IP地址的绑定
}
DHCP作用域配置
1.单作用域配置
subnet 192.168.0.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
#可以加入一些选项,也可以全局配置
range 192.168.0.10-192.168.0.100;
range 192.168.0.150-192.168.0.200;
}
2.多作用域配置
subnet 192.168.0.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.0.9;
#可以加入一些选项,也可以全局配置
range 192.168.0.10-192.168.0.100;
range 192.168.0.150-192.168.0.200;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.1.9;
#可以加入一些选项,也可以全局配置
range 192.168.1.10-192.168.1.100;
range 192.168.1.150-192.168.1.200;
}
DHCP保留配置
host 主机名 {
hardware 网卡类型MAC地址;
fixed-address IP地址;
}
DHCP超级作用域配置
shared-network "name" {
subnet 192.168.0.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.0.9;
#可以加入一些选项,也可以全局配置
range 192.168.0.10-192.168.0.100;
range 192.168.0.150-192.168.0.200;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.1.9;
#可以加入一些选项,也可以全局配置
range 192.168.1.10-192.168.1.100;
range 192.168.1.150-192.168.1.200;
}
}
DHCP根据不同的类别分配IP
class "vmware" {
match if substring(hardware, 1, 3) = 00:0C:29 or
substring(hardware, 1, 3) = 00:0C:28;
}
class "micro-clients" {
match if substring(option vendor-class-identifier, 0, 4) = "MSFP";
}
pool {
allow members of "vmware";
range 192.168.0.10-192.168.0.100;
}
pool {
deny members of "vmware";
allow members of "micro-clients";
range 192.168.0.101-192.168.0.200;
}
pool {
deny members of "vmware";
deny members of "micro-clients";
range 192.168.0.201-192.168.0.254;
}
DHCP的启动
service dhcpd start
service dhcpd stop
service dhcpd restart
service dhcpd status
chkconfig dhcpd on #开机自动启动
阅读(1171) | 评论(0) | 转发(0) |