DHCP server deployment

1. Introduction
DHCP (Dynamic Host Configuration Protocol) is a network protocol for local area network. The main function is to centrally manage and allocate IP addresses, so that the hosts in the LAN can dynamically obtain information such as IP addresses, Gateway addresses, DNS server addresses, etc., and can improve the utilization rate of addresses. Since DHCP is a UDP protocol, it runs more efficiently.
2. Deployment
1. Install the software package
yum install -y dhcp
2. Modify the configuration
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/ dhcpd.conf

#具体DNS服务器
option domain-name-servers 8.8.8.8, 114.114.114.114;
#声明DNS服务器
default-lease-time 7200;  #定义默认租约时间7200s
max-lease-time 10800;       #定义最大租约时间10800s
authoritative;  #拒绝不正确的IP地址的要求
log-facility local7;    #定义日志
#作用域相关设置指令
#shared-network部署一个超级作用域
#suppber超级作用域名称,随便起
#subnet 定义一个作用域
#netmask 定义作用域的掩码
#range 允许发放的IP范围
#option routers 指定网关地址
#option domain-name-servers 指定DNS服务器地址
#option broadcast-address 广播地址

shared-network supper {
subnet 172.16.120.0 netmask 255.255.255.0 {
  range 172.16.120.100 172.16.120.200;
  option routers 172.16.120.1;
  option broadcast-address 172.16.120.255;
  default-lease-time 7200;
  max-lease-time 10800;
}
subnet 172.16.10.0 netmask 255.255.255.0 {
  range 172.16.10.100 172.16.10.200;
  option routers 172.16.10.1;
  option broadcast-address 172.16.10.255;
  default-lease-time 7200;
  max-lease-time 10800;
}
}
#host为指令,samba是个名字,随便起
#option host-name指定名称,需要删除/etc/hostname和/etc/sysconfig/network中的hostname字段清除
#hardware ethernet指以太网网卡MAC地址
#fixed-address指要绑定的IP地址
host samba {
  option host-name "samba.blpwdev.com";
  hardware ethernet ;00:0c:29:63:52:c7
  fixed-address 192.168.11.252;
}

3. Start the service
systemctl start dhcpd
systemctl enable dhcpd

Guess you like

Origin blog.51cto.com/7965676/2601999