dhcp  动态主机配置协议


option time-offset


default-lease-time                       默认租期
max-lease-time                           最大租期(秒)

声明子网
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers                 网关
option subnet-mask         掩码

范例:
[root@lamp ~]# more /etc/dhcpd.conf
ddns-update-style none;
#ignore client-updates;

subnet 1.1.1.0 netmask 255.255.255.0 {
        option routers                  1.1.1.1;
        option subnet-mask              255.255.255.0;
        option domain-name              "lamp.com";
        option domain-name-servers      192.168.1.1;

        range 1.1.1.10 1.1.1.20;
        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;
        }
}

subnet 192.168.18.0 netmask 255.255.255.0 {

        option routers                  192.168.18.1;
        option subnet-mask              255.255.255.0;

        option domain-name              "lamp.com";
        option domain-name-servers      192.168.1.1;

        range   192.168.18.10 192.168.18.20;

        default-lease-time 21600;
        max-lease-time 43200;
}



range         范围
host{         #保留区域
hardware Ethernet  mac  地址
fixed-address ip        地址
}
 


-------------------------------------------------------------------------------
dhcprelay  dhcp中继

 

客户端
vim /etc/sysconfig/dhcrelay
INTERFACES=""   #监听网卡
DHCPSERVERS=""  #DHCP服务器ip地址

在network文件中加  networking=yes

 

服务端

echo 1 > /proc/sys/net/ipv4/ip_foward
在主配置文件中添加相应的作用域

**注意**:dhcp配置文件dhcpd.conf文件中必须有与本地网卡在同网段的subnet声明!