dhcp配置文件位置:/etc/dhcp/dhcpd.conf
[root@pxe1 yum.repos.d]# cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.example # see dhcpd.conf(5) man page subnet 192.168.56.0 netmask 255.255.255.0 { range 192.168.56.10 192.168.56.20; default-lease-time 600; max-lease-time 7200; filename "pxelinux.0"; next-server 192.168.56.14; } # subnet 192.168.56.0 netmask 255.255.255.0 服务端IP网段及掩码 # range 192.168.56.10 192.168.56.20; dhcp分发的地址范围,最好将本机IP包含在内。 # default-lease-time 600;max-lease-time 7200; IP地址租约时间。 # filename "pxelinux.0"; 指定引导文件位置,这里是TFTP根目录下的pxelinux.0。 # next-server 192.168.56.14; TFTP服务器地址。 3.3 启动dhcp服务 [root@pxe1 yum.repos.d]# systemctl restart dhcpd [root@pxe1 yum.repos.d]# systemctl enable dhcpd Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service. [root@pxe1 yum.repos.d]# systemctl status dhcpd ● dhcpd.service - DHCPv4 Server Daemon Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2017-05-25 11:00:26 CST; 26s ago Docs: man:dhcpd(8) man:dhcpd.conf(5) Main PID: 11849 (dhcpd) Status: "Dispatching packets..." CGroup: /system.slice/dhcpd.service └─11849 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid May 25 11:00:26 pxe1 dhcpd[11849]: No subnet declaration for virbr0 (192.168.122.1). May 25 11:00:26 pxe1 dhcpd[11849]: ** Ignoring requests on virbr0. If this is not what May 25 11:00:26 pxe1 dhcpd[11849]: you want, please write a subnet declaration May 25 11:00:26 pxe1 dhcpd[11849]: in your dhcpd.conf file for the network segment May 25 11:00:26 pxe1 dhcpd[11849]: to which interface virbr0 is attached. ** May 25 11:00:26 pxe1 dhcpd[11849]: May 25 11:00:26 pxe1 dhcpd[11849]: Listening on LPF/enp0s3/08:00:27:43:c1:1d/192.168.56.0/24 May 25 11:00:26 pxe1 dhcpd[11849]: Sending on LPF/enp0s3/08:00:27:43:c1:1d/192.168.56.0/24 May 25 11:00:26 pxe1 dhcpd[11849]: Sending on Socket/fallback/fallback-net May 25 11:00:26 pxe1 systemd[1]: Started DHCPv4 Server Daemon. [root@pxe1 yum.repos.d]# netstat -nulp | grep dhcp udp 0 0 0.0.0.0:67 0.0.0.0:* 11849/dhcpd udp 0 0 0.0.0.0:16465 0.0.0.0:* 11849/dhcpd udp6 0 0 :::31651 :::* 11849/dhcpd注意:如果启动dhcp服务报错,请查看/var/log/messages日志,会有明显的错误提示,多数是配置文件格式或内容错误造成的。
3.4 验证DHCP服务配置dhcp服务器配置完成后,便可启动之前准备的客户端虚拟机查看是否可以获取到IP地址,能正常获取IP则说明配置正常,如下:
至此,dhcp服务器配置完成。
4. TFTP服务器配置TFTP服务器主要为客户端提供内核文件和引导文件。
4.1 安装TFTP服务器