使用Dnsmasq 部署GPXE 安装 Centos7
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Dnsmasq 部署GPXE 安装 Centos7相关的知识,希望对你有一定的参考价值。
实验环境 1台Centos7.6的虚拟机 ip: 192.168.148.17/24 配置PXE环境;新建一台虚拟机作为测试机
本次实验采用 dnsmasq作为dhcp、tftp服务器; vsftpd 提供安装源
# 关闭防火墙
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
#syslinux 提供pxe启动的引导文件
[[email protected] ~]# yum -y install dnsmasq vsftpd syslinux
[[email protected] ~]# mkdir /var/ftp/pub/centos7
[[email protected] ~]# systemctl enable dnsmasq vsftpd
[[email protected] ~]# systemctl start vsftpd
[[email protected] ~]# mkdir /var/ftp/pub/centos7
[[email protected] ~]# mount /dev/sr0 /var/ftp/pub/centos7/
# 创建tftp服务目录
[[email protected] ~]# mkdir /var/lib/dnsmasq/tftpboot/
[[email protected] ~]# cd /var/lib/dnsmasq/tftpboot/
[[email protected] tftpboot]# cp /usr/share/syslinux/{menu.c32,gpxelinux.0} .
[[email protected] tftpboot]# mkdir pxelinux.cfg
[[email protected] tftpboot]# cp /var/ftp/pub/centos7/isolinux/isolinux.cfg pxelinux.cfg/default
# 编辑default文件最终内容如下 Gpxe除了支持传统的tftp还支持ftp,http方式下载文件
default menu.c32
timeout 600
menu title CentOS 7
label 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服务器地址和引导文件;文件内容如下:
[[email protected] ~]# cat /etc/dnsmasq.d/pxe.conf
dhcp-range=192.168.148.50,192.168.148.100,255.255.255.0,12h
enable-tftp
dhcp-boot=/var/lib/dnsmasq/tftpboot/gpxelinux.0,192.168.148.17
[[email protected] ~]# systemctl start dnsmasq
# 检测ipv4 监听的udp端口
[[email protected] ~]# ss -4 -unl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 *:53 *:*
UNCONN 0 0 *:67 *:*
UNCONN 0 0 *:69 *:*
# 所需端口都正常开启
# 如果需要开启防火墙 需要添加对应的服务
[[email protected] ~]# systemctl enable firewalld
[[email protected] ~]# systemctl start firewalld
[[email protected] ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
[[email protected] ~]# firewall-cmd --permanent --add-service=ftp
[[email protected] ~]# firewall-cmd --permanent --add-service=tftp
[[email protected] ~]# firewall-cmd --permanent --add-service=dhcp
[[email protected] ~]# firewall-cmd --reload
[[email protected] ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0 eth1
sources:
services: ssh dhcpv6-client dhcp ftp tftp
启动另一台新的虚拟默认从网络启动进行系统安装
以上是关于使用Dnsmasq 部署GPXE 安装 Centos7的主要内容,如果未能解决你的问题,请参考以下文章