服务器之05DHCP

1安装DHCP

yum -y install dhcp


2把范例CP到配置文件里


cp /usr/share/doc/dhcp-****/dhcpd.conf.sample /etc/dhcp/dhcpd.conf


3备份并去掉注解空行

cd /etc/dhcp

cp dhcpd.conf dhcpd.conf.bak

grep -v "^#" dhcpd.conf.bak | grep -v "^$" > dhcpd.conf


4内容详解:


vim /etc/dhcp/dhcpd.conf


-----------------------------------------------


ddns-update-style none;

log-facility local7;

default-lease-time 259200; 

max-lease-time 518400;

option domain-name "centos.com";

option domain-name-servers 192.168.1.202;


allow booting;

allow bootp;


subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.20 192.168.1.30;

option routers 192.198.3.1;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

#next-server 192.168.1.202;

#filename "pxelinux.0";

}


#host boos{

#hardware ethernet 00:0C:29:6C:A6:F8;

#fixed-address 192.168.1.10; 

#}


-----------------------------------------------


ddns

log-facility local7;

default  租约时间秒

max 最大时间秒

option dns 域名

option dns IP




子网动态IP分配设定


subnet  网络  掩码{

range 地址池范围;

option routers 网关;

option subnet-mask 子网掩码;

option broadcast-address 广播地址


做网络引导服务器用下面2个内容

#filename "pxelinux.0"; 知名启动文件

#next-server 192.168.1.202 引导服务器IP地址 TFTP


}


保留地址(固定IP)


host 名称{

MAC

地址池外的保留地址


}

-----------------------------------------------

测试:重启并 服务器开启67端口

service dhcpd restart

netstat -lunp |grep dhcpd


显示:

udp        0      0 0.0.0.0:67                  0.0.0.0:*  


设置开机自启动


你可能感兴趣的:(服务器之05DHCP)