基于linux7.2系统的PXE搭建(自动化运维,系统安装)

一.软件安装。(系统版本: Linux7.2 ,IP:192.168.10.252)
(1)需要安装的软件:
dnsmasq,syslinux, tftp-server,vsftpd,tftp, xinetd, dhcp, system-config-kickstart 。

(2)安装软件(本地yum方式安装,本地yum搭建可参考上一篇博文)

yum -y install dnsmasq syslinux tftp-server vsftpd tftp xinetd dhcp system-config-kickstart

(3)配置文件修改:
(3.1). dnsmasq.conf。

vi /etc/dnsmasq.conf
interface=eno16777736,lo
#bind-interfaces
domain=linux7.2
# DHCP range-leases
dhcp-range= eno16777736,192.168.10.10,192.168.10.250,255.255.255.0,9h
# PXE
dhcp-boot=pxelinux.0,pxeserver,192.168.10.252
# Gateway
dhcp-option=3,192.168.10.254
# DNS
dhcp-option=6,192.168.10.254, 8.8.8.8
server=8.8.4.4
# Broadcast Address
dhcp-option=28,10.0.0.255
# NTP Server
dhcp-option=42,0.0.0.0
 
pxe-prompt="Press F8 for menu.", 5
pxe-service=x86PC, "Install linux7.2 from network server 192.168.10.252", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot

(3.2) default文件修改。

[root@center ~]#cp -r /usr/share/syslinux/* /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default

vim /var/lib/tftpboot/pxelinux.cfg/default

default vesamenu.c32
prompt 0
timeout 1
ONTIMEOUT local
 
menu title ########## PXE Boot Menu ##########
 
label 1
menu label ^1) Install linux7.2  x64 
kernel linux7.2/vmlinuz
append initrd=linux7.2/initrd.img inst.repo=ftp://192.168.10.252/pub inst.ks=ftp://192.168.10.252/ks.cfg 

label 2
menu label ^2) Install linux7.2  shoudong
kernel linux7.2/vmlinuz
append initrd=linux7.2/initrd.img method=ftp://192.168.10.252/pub devfs=nomount

label 3
menu label ^3) Boot from local drive

(3.3) dhcpd.conf文件修改。
vim /etc/dhcp/dhcpd.conf

ddns-update-style interim;
ignore client-updates;
allow booting;   
allow bootp;   
next-server 192.168.10.252; 
filename "pxelinux.0";   
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers                  192.168.10.254;  
option subnet-mask              255.255.255.0;   
range dynamic-bootp 192.168.10.10 192.168.10.250;  
default-lease-time 21600;
max-lease-time 43200;
}

(3.4) tftp文件修改。
vim /etc/xinetd.d/tftp

  # default: off
# description: The tftp server serves files using the trivial file transfer \
#	protocol.  The tftp protocol is often used to boot diskless \
#	workstations, download configuration files to network-aware printers, \
#	and to start the installation process for some operating systems.
service tftp
{
	socket_type		= dgram
	protocol		= udp
	wait			= yes
	user			= root
	server			= /usr/sbin/in.tftpd
	server_args		= -s /var/lib/tftpboot -c
	disable			= no
	per_source		= 11
	cps			= 100 2
	flags			= IPv4
}

(4)系统镜像中文件拷贝。

#mkdir /var/lib/tftpboot/linux7.2
#cp /mnt/cdrom/images/pxeboot/vmlinuz  /var/lib/tftpboot/linux7.2/
 #cp /mnt/cdrom/images/pxeboot/initrd.img  /var/lib/tftpboot/linux7.2/
#cp -r /mnt/cdrom/*  /var/ftp/pub/
# chmod -R 755 /var/ftp/pub

二.配置无人值守软件包,配置ks.cfg文件
(1)本地yum设置,选软件包需要。
[root@center yum.repos.d]# vi /etc/yum.repos.d/rhel-media.repo

[development]
name=Red Hat Enterprise Linux7.2                               
baseurl=file:///var/ftp/pub                                     
enabled=1 
gpgcheck=0 

[root@center ~]# yum clean all
[root@center ~]# yum makecache

在系统内终端界面输入命令:system-config-kickstart根据需求设置。
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

注意: cp ks.cfg /var/ftp/

(2)程序启动,开机自动启动。
chkconfig dhcpd on
systemctl enable dhcpd.service
systemctl restart dhcpd.service
systemctl status dhcpd.service

chkconfig xinetd on
systemctl start xinetd.service
lsof -i :69

systemctl start dnsmasq
systemctl status dnsmasq
systemctl start vsftpd
systemctl status vsftpd
systemctl enable dnsmasq
systemctl enable vsftpd

netstat -tulpn
firewall-cmd --add-service=ftp --permanent ## Port 21
firewall-cmd --add-service=dns --permanent ## Port 53
firewall-cmd --add-service=dhcp --permanent ## Port 67
firewall-cmd --add-port=69/udp --permanent ## Port for TFTP
firewall-cmd --add-port=4011/udp --permanent ## Port for ProxyDHCP
firewall-cmd --reload ## Apply rules

tailf /var/log/messages

(linux6.5启动命令:)
chkconfig dhcpd on
service dhcpd restart
chkconfig xinetd on
service xinetd start
service xinetd restart
service vsftpd restart
chkconfig vsftpd on
chkconfig tftp on

/etc/init.d/iptables stop

(3)测试:FTP网页登录。
ftp://192.168.10.252/pub

至此以配置完成,可测试安装系统。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值