DHCP服务的配置
一、配置文件的建立:/etc/dhcpd.conf
1、文件结构
         全局配置
 
         作用域配置
 
         a、全局配置
                   ddns-update-style interim;定义所支持的DNS动态更新类型;
                   ignore|allow client-updates;忽略|允许DNS客户端动态更新;
         b、作用域配置--subnet命令
                   subnet 网络号 netmask 子网掩码 {
                声明与选项;
                   }
 
                   subnet 192.168.16.0 netmask 255.255.255.0 {
                   range 起始IP 结束IP;(range声明作用域的IP范围)
                   option subnet-mask 255.255.255.0;(定义子网掩码)
                   }
 
                   ddns-update-style interim;
                   ignore client-updates;
 
                   subnet 192.168.16.0 netmask 255.255.255.0 {
                   range 192.168.16.11 192.168.16.21;
                   option subnet-mask 255.255.255.0;
                   }
二、DHCP配置
1、设置IP作用域
         subnet 网络号 netmask 子网掩码 {
         range 起始IP 结束IP;
         option subnet-mask 子网掩码;
         }
   在一个作用域中支持多个range,每个range设置的IP范围不同。
         range 192.168.16.11 192.168.16.21;
         range 192.168.16.32 192.168.16.42;
2、设置DNS服务器地址
         option domain-name-servers 192.168.16.1,61.144.56.100;
3、设置默认网关
         option routers 192.168.16.254;
4、设置广播地址
         option broadcast-address 192.168.16.255;
5、设置租期
         default-lease-time 86400(秒);设置默认租期
         max-lease-time 172800(秒);设置最大租期
6、DHCP保留
         host 保留名 { 定义DHCP保留
                   hardware ethernet 00:00:00:00:00:01;(定义网卡MAC)
                   fixed-address 192.168.16.32;(定义保留地址)
                   option 选项;
         }
7、地址池的分配信息:/var/lib/dhcpd/dhcpd.lease
         生成IP地址分配列表
三、超级作用域
         shared-network 超级作用域名 {
         作用域选项
 
         subnet 作用域1 netmask 子网掩码 {
         作用域声明/选项
         }
        
         subnet 作用域2 netmask 子网掩码 {
         作用域声明/选项
        }
         }
 
 
 
 
                                     DHCP配置示例
全局配置:
 
ddns-update-style interim;
ignore client-updates;
 
超级作用域配置:
 
shared-network apple (作用域名) {
                                     option subnet-mask 255.255.255.0;
                                     option routers 192.168.16.1;
                                     option domain-name-servers 192.168.16.1;
                                     default-lease-time 86400;
                                     max-lease-time 172800;
作用域配置:
subnet 192.168.16.0 netmask 255.255.255.0 {
range 192.168.16.11 192.168.16.21;
range 192.168.16.31 192.168.16.41;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.16.2,61.144.56.100;
option routers 192.168.16.254;
option broadcast-address 192.168.16.255;
default-lease-time 86400;
max-lease-time 172800;
 
DHCP保留配置: host officel {
hardware ethernet 00:00:00:00:00:01 (定义 MAC)
fixed-address 192.168.16.1; (定义保留ip地址)
option routers 192.1683.16.1; (定义网关)
}
}
超级作用域第二个作用域配置
 
subnet 192.1683.17.0 netmask 255.255.255.0 {
range 192.168.17.1 192.168.17.100;
option routers 192.168.17.1;
}
}