本文共 2897 字,大约阅读时间需要 9 分钟。
# 关闭防火墙[root@localhost ~]# systemctl stop firewalld[root@localhost ~]# systemctl disable firewalld#syslinux 提供pxe启动的引导文件[root@localhost ~]# yum -y install dnsmasq vsftpd syslinux[root@localhost ~]# mkdir /var/ftp/pub/centos7[root@localhost ~]# systemctl enable dnsmasq vsftpd [root@localhost ~]# systemctl start vsftpd [root@localhost ~]# mkdir /var/ftp/pub/centos7[root@localhost ~]# mount /dev/sr0 /var/ftp/pub/centos7/# 创建tftp服务目录[root@localhost ~]# mkdir /var/lib/dnsmasq/tftpboot/[root@localhost ~]# cd /var/lib/dnsmasq/tftpboot/[root@localhost tftpboot]# cp /usr/share/syslinux/{menu.c32,gpxelinux.0} .[root@localhost tftpboot]# mkdir pxelinux.cfg[root@localhost tftpboot]# cp /var/ftp/pub/centos7/isolinux/isolinux.cfg pxelinux.cfg/default# 编辑default文件最终内容如下 Gpxe除了支持传统的tftp还支持ftp,http方式下载文件default menu.c32timeout 600menu title CentOS 7label linux menu label ^Install CentOS 7 kernel ftp://192.168.148.17/pub/centos7/isolinux/vmlinuz append initrd=ftp://192.168.148.17/pub/centos7/isolinux/initrd.img inst.repo=ftp://192.168.148.17/pub/centos7/label local menu label Boot from ^local drive menu default localboot 0xffff# 在/etc/dnsmasq.d/ 创建pxe.conf ;指定 dhcp地址池的范围,启用tftp功能,指定tftp服务器地址和引导文件;文件内容如下:[root@localhost ~]# cat /etc/dnsmasq.d/pxe.conf dhcp-range=192.168.148.50,192.168.148.100,255.255.255.0,12henable-tftpdhcp-boot=/var/lib/dnsmasq/tftpboot/gpxelinux.0,192.168.148.17[root@localhost ~]# systemctl start dnsmasq# 检测ipv4 监听的udp端口[root@localhost ~]# ss -4 -unlState Recv-Q Send-Q Local Address:Port Peer Address:Port UNCONN 0 0 *:53 *:* UNCONN 0 0 *:67 *:* UNCONN 0 0 *:69 *:* # 所需端口都正常开启# 如果需要开启防火墙 需要添加对应的服务[root@localhost ~]# systemctl enable firewalld[root@localhost ~]# systemctl start firewalld[root@localhost ~]# firewall-cmd --list-allpublic (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: ssh dhcpv6-client ports: protocols: [root@localhost ~]# firewall-cmd --permanent --add-service=ftp[root@localhost ~]# firewall-cmd --permanent --add-service=tftp[root@localhost ~]# firewall-cmd --permanent --add-service=dhcp[root@localhost ~]# firewall-cmd --reload[root@localhost ~]# firewall-cmd --list-allpublic (active) target: default icmp-block-inversion: no interfaces: eth0 eth1 sources: services: ssh dhcpv6-client dhcp ftp tftp
转载于:https://blog.51cto.com/1012682/2382324