[root@msi ~]# dnf install dhcp-server
[root@msi ~]# vim /etc/dhcp/dhcpd.conf
[root@msi ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
ddns-update-style none;
option space PXE;
subnet 192.168.1.0 netmask 255.255.255.0 {
class "PXE" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
option vendor-encapsulated-options 01:04:00:00:00:00:ff;
option boot-size 0x11;
filename "pxelinux.0";
# option tftp-server-name "deyu.wang";
option vendor-class-identifier "PXEClient";
vendor-option-space PXE;
}
# The following lines are standard all of the time.
option routers 192.168.1.254;
option subnet-mask 255.255.255.0;
option domain-name "deyu.wang";
option domain-name-servers 192.168.1.254,8.8.8.8,168.95.1.1,139.175.10.20;
default-lease-time 21600;
max-lease-time 43200;
# Assign IPs 101-100 to PXE clients
pool {
allow members of "PXE";
default-lease-time 12;
max-lease-time 18;
range 192.168.1.250 192.168.1.253;
}
pool {
deny members of "PXE";
range 192.168.1.100 192.168.1.199;
}
# The following lines are examples of kickstart directives.
next-server 192.168.1.254;
}
[root@msi ~]# grep example -A5 /etc/sysconfig/dhcpd # example: # $ cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/ # $ vi /etc/systemd/system/dhcpd.service # $ ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid <your_interface_name(s)> # $ systemctl --system daemon-reload # $ systemctl restart dhcpd.service
[root@msi ~]# cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/ [root@msi ~]# grep Exec /etc/systemd/system/dhcpd.service ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid $DHCPDARGS [root@msi ~]# tail -1 /etc/sysconfig/dhcpd DHCPDARGS=wlo1
[root@msi ~]# systemctl --system daemon-reload [root@msi ~]# systemctl restart dhcpd.service
[root@msi ~]# systemctl status dhcpd.service
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/etc/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2021-07-15 07:11:44 CST; 1min 1s ago
Docs: man:dhcpd(8)
man:dhcpd.conf(5)
Main PID: 4587 (dhcpd)
Status: "Dispatching packets..."
Tasks: 1 (limit: 48313)
Memory: 4.9M
CGroup: /system.slice/dhcpd.service
└─4587 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid wlo1