default-lease-time 600; 全局设租期
max-lease-time 7200;//最大租期
option domain-name "example.org";//设置DNS域
option domain-name-servers ns1.example.org, ns2.example.org;//设置DNS服务器地址
# Use this to send dhcp log messages to a different log file (you also have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the DHCP server to understand the network topology.
这个空网段虽然不能提供地址分配,却相当于一个地址定义机制,用于告诉DHCP SERVER具体的拓扑接口地址情况
//设置子网与子网掩码
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
一个基本的DHCP网段
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.80;//地址池
option router 192.168.1.1; //设置客户端默认网关
option broadcast-address 10.5.5.31;//设置广播地址
default-lease-time 600;
max-lease-time 7200;
option domain-name "internal.example.org";
option domain-name-servers ns1.internal.example.org;
}
如果想给某IP分配固定的IP地址,修改host 那一项,把网卡的Mac地址和IP进行绑定,就是最后那一段,改为相应的就可以了。
host fantasia {
hardware ethernet 08:00:07:26:c0:a5; 注意此处是client的硬件MAC地址
fixed-address 10.99.7.2;
}
也可以不设fixed-address IP地址,这样绑定到client MAC的就不是IP地址了,而是一些其他的属性
IP地址不绑定,就仍遵循动态分配
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
filename "vmunix.passacaglia";
server-name "toccata.fugue.com";
}
Bootp dhcp,很少用
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}
按client某种类型分组DHCP,而不是按物理接口网段
例子: SUN 分配地址段10.17.224.0/24
非SUN的主机,分配地址段10.0.29.0/24
定义一个class foo
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
定义vendor-class-identifier
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
subnet段,不设range,即只描述接口
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool { 符合class 的,分配一个range
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool { 不合class 的,分配一个range
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}