Step1: Yum install
#
[root@server1 ~]# yum -y install dhcp
Step2: modify config
#
[root@server1 ~]#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@server1 ~]#cat /etc/dhcp/dhcpd.conf
[root@server1 ~]# grep -v ^# /etc/dhcp/dhcpd.conf
option domain-name "xxxx.com";
option domain-name-servers x.x.x.x, x.x.x.x;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;
subnet 10.70.79.128 netmask 255.255.255.128 { <<<<< make sure the subnet same with you centos server's subnet, otherwise dhcp service start will has issue
option routers 10.70.79.254;
range 10.70.79.134 10.70.79.187;
}
host win11{
hardware ethernet 00:50:56:98:78:21;
fixed-address 10.70.79.x;
}
subnet 10.124.36.0 netmask 255.255.255.0 {
option routers 10.124.36.1;
range 10.124.36.109 10.124.36.111;
}
host 8201{
hardware ethernet xx:xx:xx:xx:xx;
fixed-address 10.124.36.x;
}
Step3: Other config files need pay attention to
#
[root@server1 ~]# grep -v ^# /etc/sysconfig/dhcpd
DHCPDARGS=eth32
[root@server1 ~]# cat /etc/systemd/system/dhcpd.service
[Unit]
Description=DHCPv4 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5)
Wants=network-online.target
After=network-online.target
After=time-sync.target
[Service]
Type=notify
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid ens32
[Install]
WantedBy=multi-user.target
Step4: start DHCP service
#
[root@server1 ~]#systemctl restart dhcpd.service
[root@server1 ~]#systemctl status dhcpd.service
Step 5: check dhcp server log
#
/var/log/messages <<<<
/var/lib/dhcpd/dhcpd.leases