First modify the NIC configuration information as a DHCP server
[Email protected] ~]# cat/etc/sysconfig/network-scripts/ifcfg-ens192
Type=ethernet
Bootproto=static
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=no
ipaddr=15.1.1.1
netmask=255.255.255.0
name=ens192
device=ens192
Onboot=yes
Installing httpd tftp-server DHCP Syslinux xinetd
[[email protected] ~]# yum install httpd tftp-server DHCP syslinux xinetd–y
Modify the DHCP configuration file to make a broadcast server
[Email protected] ~]# vim/etc/dhcp/dhcpd.conf
Ddns-update-style Interim;
Ignore client-updates;
authoritative;
Allow booting;
Allow BOOTP;
Subnet 15.1.1.0 netmask 255.255.255.0 #指定网段
{option routers 15.1.1.1; #指定网关
Option Subnet-mask 255.255.255.0;
Range DYNAMIC-BOOTP 15.1.1.2 15.1.1.200; #分配地址池
Next-server 15.1.1.1; #DHCP服务器地址
FileName "pxelinux.0"; #PXE所需文件
Default-lease-time 21000;
Max-lease-time 43200;
Option time-offset-18000;
}
Modify the TFTP configuration to change the Disable option from Yes to No
[Email protected] ~]# 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
Disable = no
Per_source = 11
CPS = 100 2
Flags = IPV4
}
Copy and install all required CFG files
[Email protected] ~]# cp/root/anaconda-ks.cfg/var/www/html/ks.cfg
[Email protected] ~]# chmod 555/var/www/html/ks.cfg
Modifying a CFG file
[Email protected] ~]# vim/var/www/html/ks.cfg
#version =RHEL7
# Install OS instead of upgrade
Install
# System Authorization Information
Auth--enableshadow--passalgo=sha512
# Use CDROM installation media
URL--url "Http://15.1.1.1/centos" #安装源修改为网络路径
# Use graphical Install
Graphical
# Run The Setup Agent on first boot
Firstboot--enable
Ignoredisk--ONLY-USE=SDA
# Keyboard Layouts
Keyboard--vckeymap=us--xlayouts= ' US '
Reboot
# System Language
Lang en_US. UTF-8
# Firewall Configuration
Firewall--disabled
# SELinux Configuration
SELinux--disabled
# Network Information
Network--bootproto=dhcp--device=ens160--onboot=off--ipv6=auto
Network--hostname=localhost.localdomain
# Root Password
ROOTPW--iscrypted $6$athuq/r7eacq4m4t$ j17qu0sg1dwo2vyoyomattyqslrjpd.pw0mrj92.oxwb9ujyafx.cp9sjqwyazebpd1kn4lq8csygwzrzw610/
# System TimeZone
TimeZone Asia/shanghai--ISUTC--NONTP
# System Bootloader Configuration
Bootloader--append= "Crashkernel=auto"--location=mbr--BOOT-DRIVE=SDA
Autopart--TYPE=LVM
# Partition Clearing Information
Clearpart--none--initlabel
%packages
@core
Kexec-tools
%end
%addon com_redhat_kdump--enable--reserve-mb= ' auto '
%end
Creating the installation source and installation files
[Email protected] ~]# Mkdir/var/www/html/centos
[Email protected] ~]# Mkdir/var/www/html/centos
[Email protected] ~]# mount/dev/cdrom/mnt/
[Email protected] ~]# cp-r/mnt/*/var/www/html/centos/
[email protected] ~]# Yum install Tree–y
[Email protected] ~]# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/
[Email protected] ~]# mkdir/var/lib/tftpboot/pxelinux.cfg
[Email protected] ~]# Cp/var/www/html/centos/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default
[Email protected] ~]# cp/var/www/html/centos/images/pxeboot/{vmlinuz,initrd.img}/var/lib/tftpboot/
[Email protected] ~]# Cp/var/www/html/centos/isolinux/{vesamenu.c32,boot.msg,splash.png}/var/lib/tftpboot/
[Email protected] ~]# Tree-al 2/var/www/html/
/var/www/html/
├──centos
│├──centos_buildtag
│├──efi
│├──eula
│├──gpl
│├──images
│├──isolinux
│├──liveos
│├──packages
│├──repodata
│├──rpm-gpg-key-centos-7
│├──rpm-gpg-key-centos-testing-7
│└──trans. TBL
└──ks.cfg
7 Directories, 7 files
Modify the default file
[Email protected] ~]# Vim/var/lib/tftpboot/pxelinux.cfg/default
Default Vesamenu.c32
Timeout 60
Display Boot.msg
# Clear The screen when exiting the menu, instead of leaving the menu displayed.
# for Vesamenu, this means the graphical background is still displayed without
# The menu itself for as long as the remains in graphics mode.
Menu Clear
Menu Background Splash.png
Menu Title CentOS 7
Menu Vshift 8
Menu Rows 18
Menu Margin 8
#menu Hidden
Menu Helpmsgrow 15
Menu Tabmsgrow 13
# Border Area
Menu Color Border * #00000000 #00000000 None
# Selected Item
Menu Color sel 0 #ffffffff #00000000 None
# Title Bar
Menu Color title 0 #ff7ba3d0 #00000000 None
# Press [TAB] Message
Menu Color tabmsg 0 #ff3a6496 #00000000 None
# unselected menu item
Menu Color Unsel 0 #84b8ffff #00000000 None
# Selected Hotkey
Menu Color Hotsel 0 #84b8ffff #00000000 None
# unselected Hotkey
Menu Color Hotkey 0 #ffffffff #00000000 None
# Help Text
Menu Color Help 0 #ffffffff #00000000 None
# A ScrollBar of some type? Not sure.
Menu Color scrollbar 0 #ffffffff #ff355594 None
# Timeout MSG
Menu Color Timeout 0 #ffffffff #00000000 None
Menu Color timeout_msg 0 #ffffffff #00000000 None
# Command Prompt Text
Menu Color Cmdmark 0 #84b8ffff #00000000 None
Menu Color CmdLine 0 #ffffffff #00000000 None
# do not display the actual menu unless the user presses a key. All this is displayed a timeout message.
Menu Tabmsg Press Tab for full configuration options on menu items.
Menu Separator # Insert an empty line
Menu Separator # Insert an empty line
Label Linux
Menu Label ^install CentOS 7
Kernel Vmlinuz
Menu default
#append initrd=initrd.img inst.stage2=hd:label=centos\x207\x20x86_64 Quiet
Append initrd=initrd.img inst.ks=http://15.1.1.1/ks.cfg quiet
Label check
Menu Label Test this ^media & install CentOS 7
Menu default
Kernel Vmlinuz
#append initrd=initrd.img inst.stage2=hd:label=centos\x207\x20x86_64 Rd.live.check quiet
Append initrd=initrd.img inst.ks=http://15.1.1.1/ks.cfg quiet
Menu Separator # Insert an empty line
# Utilities Submenu
Menu Begin ^troubleshooting
Menu Title Troubleshooting
Label VESA
Menu Indent Count 5
Menu Label Install CentOS 7 in ^basic graphics mode
Text Help
Try This option out if you're having trouble installing
CentOS 7.
Endtext
Kernel Vmlinuz
Append initrd=initrd.img inst.stage2=hd:label=centos\x207\x20x86_64 xdriver=vesa nomodeset quiet
Label Rescue
Menu Indent Count 5
Menu Label ^rescue a CentOS system
Text Help
If the system won't boot, this lets you access files
and edit config files to try to get it booting again.
Endtext
Kernel Vmlinuz
Append initrd=initrd.img inst.stage2=hd:label=centos\x207\x20x86_64 Rescue quiet
Label Memtest
Menu Label Run a ^memory test
Text Help
If your system is has issues, a problem with your
System ' s memory May is the cause. Use this utility to
See if the memory is working correctly.
Endtext
Kernel memtest
Menu Separator # Insert an empty line
Label Local
Menu label Boot from ^local Drive
Localboot 0xFFFF
Menu Separator # Insert an empty line
Menu Separator # Insert an empty line
Label Returntomain
Menu Label Return to ^main menu
Menu exit
Menu End
[Email protected] ~]# tree/var/lib/tftpboot/
/var/lib/tftpboot/
├──boot.msg
├──initrd.img
├──pxelinux.0
├──pxelinux.cfg
│└──default
├──splash.png
├──vesamenu.c32
└──vmlinuz
1 directory, 7 files
Turn on the service and check the service opening situation
[[email protected] ~]# systemctl start httpd dhcpd tftp xinetd
[[email protected] ~]# systemctl enable httpd dhcpd tftp xinetd
Created symlink From/etc/systemd/system/multi-user.target.wants/httpd.service to/usr/lib/systemd/system/ Httpd.service.
Created symlink From/etc/systemd/system/multi-user.target.wants/dhcpd.service to/usr/lib/systemd/system/ Dhcpd.service.
Created symlink from/etc/systemd/system/sockets.target.wants/tftp.socket To/usr/lib/systemd/system/tftp.socket.
[Email protected] ~]# NETSTAT-TUPLN
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2385/dnsmasq
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1079/sshd
TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1077/cupsd
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1758/master
TCP6 0 0::: $:::* LISTEN 5884/httpd
TCP6 0 0::: $:::* LISTEN 1079/sshd
TCP6 0 0:: 1:631:::* LISTEN 1077/CUPSD
TCP6 0 0:: 1:25:::* LISTEN 1758/master
UDP 0 0 0.0.0.0:43741 0.0.0.0:* 5890/DHCPD
UDP 0 0 192.168.122.1:53 0.0.0.0:* 2385/dnsmasq
UDP 0 0 0.0.0.0:67 0.0.0.0:* 5890/DHCPD
UDP 0 0 0.0.0.0:67 0.0.0.0:* 2385/dnsmasq
UDP 0 0 0.0.0.0:69 0.0.0.0:* 5897/xinetd
UDP 0 0 0.0.0.0:123 0.0.0.0:* 6105/ntpdate
UDP 0 0 127.0.0.1:323 0.0.0.0:* 742/chronyd
UDP 0 0 0.0.0.0:5353 0.0.0.0:* 779/avahi-daemon:r
UDP 0 0 0.0.0.0:1282 0.0.0.0:* 779/avahi-daemon:r
UDP6 0 0::: 55402:::* 5890/DHCPD
UDP6 0 0::: more:::* 1/systemd
UDP6 0 0::: 123:::* 6105/ntpdate
UDP6 0 0:: 1:323:::* 742/chronyd
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/83/70/wKiom1dzc7DiepCGAACyBojciK0064.png "title=" [9o2 ( jx7[' 4j3v74f3{{1il.png "alt=" Wkiom1dzc7diepcgaacybojcik0064.png "/>
PXE automated installation server in CENTOS7