#CentOS 7 system installs dhcp server, tftp server server and web server
yum install -y dhcp tftp-server httpd
Daemon:/etc/sbin/dhcpd
Script:/etc/init.d/dhcpd
Port: 67 (bootps) server, 68 (bootpc) client
Configuration file:/etc/dhcp/dhcpd.conf
Lease information:/var/lib/dhcpd/dhcpd.leases
Configuration file: cp/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example/etc/dhcp/dhcpd.conf
Modify DHCP listening specific port vi /etc/sysconfig/dhcpd
#Edit DHCP Server Profile
vi /etc/dhcp/dhcpd.conf
default-lease-time six hundred ;
max-lease-time seven thousand and two hundred ;
log-facility local7;
subnet ten .53.220.0 netmask two hundred and fifty-five .255.255.0 {
range ten .53.220.41 ten .53.220.49;
option domain-name-servers ten .1.0.1, one hundred and fourteen .114.114.114; #DNS server IP address
option routers ten .53.220.1; #Gateway address
next-server ten .53.220.224; #Specify TFTP server address
filename "/mboot.efi" ; #Specify the network boot image file
}
#Binding IP address
host zhangfangzhou { #You can specify it at will, but it must be unique
hardware ethernet 00 :50:56:99:06:b7;
fixed-address ten .53.220.48;
}
Enable tftp service
vi /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 #TFTP Server Top Level Directory
disable = no #Change from yes to no
per_source = eleven
cps = one hundred two
flags = IPv4
}
#Create folders, mainly to download ESXi 7 and mount ESXi 7
mkdir -p /var/lib/tftpboot/{iso,ESXi70u2}
wget -P /var/lib/tftpboot/iso http://10.53.123.144/ISO/ESXi/VMware-VMvisor-Installer-7.0U2a-17867351.x86_64.iso
cd /var/lib/tftpboot
Mount/var/lib/tftpboot/iso/VMware-VMVisor-Installer-7.0U2a-17867351.x86_64.iso/var/lib/tftpboot/ESXi70u2 # You need to remount after restarting
#1. UEFI starts ESXi 7
Copy the boot image file specified by the above DHCP server to the specified directory. The above setting example is named "mboot. efi", so copy it to that name.
cd /var/lib/tftpboot/
cp -p /var/lib/tftpboot/ESXi70u2/efi/boot/bootx64.efi /var/lib/tftpboot/mboot.efi
Copy the file named boot.cfg directly under tftpboot, which describes the boot settings.
cp -p /var/lib/tftpboot/ESXi70u2/efi/boot/boot.cfg /var/lib/tftpboot/boot.cfg
#2. Traditional BIOS boot ESXi 7 If you want to use the old BIOS, you need the syslinux package version 3.86. From https://www.kernel.org/pub/linux/utils/boot/syslinux/ Download Package cd /tmp wget https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/3.xx/syslinux-3.86.tar.gz tar xvzf syslinux-3.86.tar.gz cp -p syslinux-3.86/core/mboot.efi /var/lib/tftpboot/ #3. Modify boot.cfg Delete the "/" of the file path in boot.cfg sed -i 's|/||g' boot.cfg
Change the Title and Prefix according to your environment. It is a good idea to use a descriptive name for "title", which is the title character displayed during automatic installation. Prefix specifies the directory where ESXi installers are stored. In this case, it will be ESXi70u2.
Modify title and prefix names Prefix=ESXi70u2 (ESXi70u2 is the folder of ESXi ISO file mount above)
# vi /var/lib/tftpboot/boot.cfg
bootstate = zero
title = Loading ESXi installer www.zhangfangzhou.cn
timeout = five prefix=ESXi70u2 kernel=b.b00 kernelopt=runweasel cdromBoot modules=jumpstrt.gz --- useropts.gz --- features.gz --- k.b00 --- uc_intel.b00 --- uc_amd.b00 --- uc_hygon.b00 --- procfs.b00 --- vmx.v00 --- vim.v00 --- tpm.v00 --- sb.v00 --- s.v00 --- atlantic.v00 --- bnxtnet.v00 --- bnxtroce.v00 --- brcmfcoe.v00 --- brcmnvme.v00 --- elxiscsi.v00 --- elxnet.v00 --- i40enu.v00 --- iavmd.v00 --- icen.v00 --- igbn .v00 --- irdman.v00 --- iser.v00 --- ixgben.v00 --- lpfc.v00 --- lpnic.v00 --- lsi_mr3.v00 --- lsi_msgp.v00 --- lsi_msgp.v01 --- lsi_msgp.v02 --- mtip32xx.v00 --- ne1000.v00 --- nenic.v00 --- nfnic.v00 --- nhpsa.v00 --- nmlx4_co.v00 --- nmlx4_en.v00 --- nmlx4_rd.v00 --- nmlx5_co.v00 --- nmlx5_rd.v00 --- ntg3.v00 --- nvme_pci.v00 --- nvmerdma.v00 - -- nvmxnet3.v00 --- nvmxnet3.v01 --- pvscsi.v00 --- qcnic.v00 --- qedentv.v00 --- qedrntv.v00 --- qfle3.v00 --- qfle3f.v00 --- qfle3i.v00 --- qflge.v00 --- rste.v00 --- sfvmk.v00 --- smartpqi.v00 --- vmkata.v00 --- vmkfcoe.v00 --- vmkusb.v00 --- vmw_ahci.v00 --- clusters.v00 --- crx.v00 --- elx_esx_.v00 --- btldr.v00 --- esx_dvfi.v00 --- esx_ui.v0 0 --- esxupdt.v00 --- tpmesxup.v00 --- weaselin.v00 --- loadesx.v00 --- lsuv2_hp.v00 --- lsuv2_in.v00 --- lsuv2_ls.v00 --- lsuv2_nv.v00 --- lsuv2_oe.v00 --- lsuv2_oe.v01 --- lsuv2_oe.v02 --- lsuv2_sm.v00 --- native_m.v00 --- qlnative.v00 --- vdfs.v00 --- vmware_e.v00 --- vsan.v00 --- vsanheal.v00 --- vsanmgmt.v00 --- tools.t00 --- xorg.v00 --- gc. v00 --- imgdb.tgz --- basemisc.tgz --- resvibs.tgz --- imgpayld.tgz build = seven .0.2-0.0.17867351
updated = zero
#Default website directory/var/www/html
systemctl enable httpd && systemctl start httpd ########Firewall settings firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent #Reload configuration firewall-cmd --reload Firewall cmd -- list all # View firewall rules and only display firewall policies in/etc/firewalld/zones/public.xml
The example kickstart file is stored in/etc/vmware/weasel/ks.cfg of ESXi. Copy this to/var/www/html on the http server
#Example 1: Kickstart file to configure static IP address for ESXi 7
vi /var/www/html/ks.cfg
#####################
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw P@ssw0rd
# The install media is in the CD-ROM drive
install --firstdisk --overwritevmfs
# Set the network on the first network adapter
network --bootproto = static --device = vmnic0 --ip = ten .53.220.199 --netmask = two hundred and fifty-five .255.255.0 --vlanid = zero --gateway = ten .53.220.1 --hostname = ten .53.220.199 --nameserver = ten .1.0.1
#vmserialnum
vmserialnum --esx = 5U4TK-DML1M-M8550-XK1QP-1A052
# reboot after install
reboot
# run the following command only on the firstboot
%firstboot --interpreter = busybox
sleep ten
# enable & start remote ESXi Shell (SSH)
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
sleep one
# enable & start ESXi Shell (TSM)
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
sleep one
# enable High Performance
esxcli system settings advanced set --option = /Power/CpuPolicy --string-value = "High Performance"
sleep one
#Disable ipv6
esxcli network ip set --ipv6-enabled = zero
sleep one
#Don't join the experience
esxcli system settings advanced set -o /UserVars/HostClientCEIPOptIn -i two
sleep one
#enable ntp
/bin/esxcli system ntp set --server = ntp.aliyun.com
sleep one
/bin/chkconfig ntpd on
sleep one
#Disable ShellWarning
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i one
sleep one
cat << EOF > /etc/ssh/keys-root/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA6PP8/RDdYIqUq6DE3zj9Qs8AF3uzfYH5lYrB + mMxxfI8kq2NIzQlsW1KDaH/fWYTkkK120lPUu97lWic9Li3Z3iFR6Nh4q6PVTfBNt4xOx754Ipqtpefk + 9sLZAYEPK8pnRP0QZv7CtDFv842tfUYIrVNnecRQTFfNtnGDcXnO1u2RE1kq6Tr5N3595PbPLDKczjOFnS + jy0MeKKHPJcZfYz7TUTSzTwTHYbPRRaQ8/0eihUwzpAmXRo9NYNle26qp6 + SlRsjGSBcUr0rh0wSe6r/C2btnpOUd//aFvcl8plhyb ++ nivlhB71v + 6I0UcPoSXOIVs/1QuHEMbv7Ircjb2emqHtZDpk8KSYhgV0ZdbAq9XOcux76eok//xtjbleKPAcDMY/KotIEh7QX4NLQxSJOm5gCLkn5kbrHfVx6nWlGzVVds1sDlcnSAWul5lFiI5ZkArXFKcnm + aCnStPpx5SSCpZpMUdZvt8ZA7vLx3xjMDFwv5HTuTFwB9mlZrdfqp5USC2mWC3eAAPE7GxDSfJv9epteIYywIP9NVT3Z4ng9z6jrcFfA4GFlfLrk8J71cnxZ/AWZXXUwp3ooE/Cp3jc473VpK7FZwjQ7Xz9PD8WQgMOO4xnGQhPWlxhRuoTYyQVa0xOBO9gh9Cuc6zq5FQgYQEcSB + /FBJ /YNDIc = www.zhangfangzhou.cn
EOF
sleep one
date > /finished.stamp
# Restart a last time
reboot
#Example 2 Kickstart file, ESXi 7 obtains IP address through DHCP server
vi /var/www/html/ks.cfg
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw P@ssw0rd
# The install media is in the CD-ROM drive
install --firstdisk --overwritevmfs
# Set the network on the first network adapter
network --bootproto = dhcp
#vmserialnum
vmserialnum --esx = 5U4TK-DML1M-M8550-XK1QP-1A052
# reboot after install
reboot
# run the following command only on the firstboot
%firstboot --interpreter = busybox
sleep ten
# enable & start remote ESXi Shell (SSH)
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
sleep one
# enable & start ESXi Shell (TSM)
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
sleep one
# enable High Performance
esxcli system settings advanced set --option = /Power/CpuPolicy --string-value = "High Performance"
sleep one
#Disable ipv6
esxcli network ip set --ipv6-enabled = zero
sleep one
#Don't join the experience
esxcli system settings advanced set -o /UserVars/HostClientCEIPOptIn -i two
sleep one
#enable ntp
/bin/esxcli system ntp set --server = ntp.aliyun.com
sleep one
/bin/chkconfig ntpd on
sleep one
#Disable ShellWarning
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i one
sleep one
cat << EOF > /etc/ssh/keys-root/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA6PP8/RDdYIqUq6DE3zj9Qs8AF3uzfYH5lYrB + mMxxfI8kq2NIzQlsW1KDaH/fWYTkkK120lPUu97lWic9Li3Z3iFR6Nh4q6PVTfBNt4xOx754Ipqtpefk + 9sLZAYEPK8pnRP0QZv7CtDFv842tfUYIrVNnecRQTFfNtnGDcXnO1u2RE1kq6Tr5N3595PbPLDKczjOFnS + jy0MeKKHPJcZfYz7TUTSzTwTHYbPRRaQ8/0eihUwzpAmXRo9NYNle26qp6 + SlRsjGSBcUr0rh0wSe6r/C2btnpOUd//aFvcl8plhyb ++ nivlhB71v + 6I0UcPoSXOIVs/1QuHEMbv7Ircjb2emqHtZDpk8KSYhgV0ZdbAq9XOcux76eok//xtjbleKPAcDMY/KotIEh7QX4NLQxSJOm5gCLkn5kbrHfVx6nWlGzVVds1sDlcnSAWul5lFiI5ZkArXFKcnm + aCnStPpx5SSCpZpMUdZvt8ZA7vLx3xjMDFwv5HTuTFwB9mlZrdfqp5USC2mWC3eAAPE7GxDSfJv9epteIYywIP9NVT3Z4ng9z6jrcFfA4GFlfLrk8J71cnxZ/AWZXXUwp3ooE/Cp3jc473VpK7FZwjQ7Xz9PD8WQgMOO4xnGQhPWlxhRuoTYyQVa0xOBO9gh9Cuc6zq5FQgYQEcSB + /FBJ /YNDIc = www.zhangfangzhou.cn
EOF
sleep one
date > /finished.stamp
# Restart a last time
reboot
# vi /var/lib/tftpboot/boot.cfg
bootstate = zero
title = Loading ESXi installer www.zhangfangzhou.cn
timeout = five
prefix = ESXi70u2
kernel = b.b00
kernelopt = ks = http://10.53.220.224/ks.cfg
modules=jumpstrt.gz --- useropts.gz --- features.gz --- k.b00 --- uc_intel.b00 --- uc_amd.b00 --- uc_hygon.b00 --- procfs.b00 --- vmx.v00 --- vim.v00 --- tpm.v00 --- sb.v00 --- s.v00 --- atlantic.v00 --- bnxtnet.v00 --- bnxtroce.v00 --- brcmfcoe.v00 --- brcmnvme.v00 --- elxiscsi.v00 --- elxnet.v00 --- i40enu.v00 --- iavmd.v00 --- icen.v00 --- igbn .v00 --- irdman.v00 --- iser.v00 --- ixgben.v00 --- lpfc.v00 --- lpnic.v00 --- lsi_mr3.v00 --- lsi_msgp.v00 --- lsi_msgp.v01 --- lsi_msgp.v02 --- mtip32xx.v00 --- ne1000.v00 --- nenic.v00 --- nfnic.v00 --- nhpsa.v00 --- nmlx4_co.v00 --- nmlx4_en.v00 --- nmlx4_rd.v00 --- nmlx5_co.v00 --- nmlx5_rd.v00 --- ntg3.v00 --- nvme_pci.v00 --- nvmerdma.v00 - -- nvmxnet3.v00 --- nvmxnet3.v01 --- pvscsi.v00 --- qcnic.v00 --- qedentv.v00 --- qedrntv.v00 --- qfle3.v00 --- qfle3f.v00 --- qfle3i.v00 --- qflge.v00 --- rste.v00 --- sfvmk.v00 --- smartpqi.v00 --- vmkata.v00 --- vmkfcoe.v00 --- vmkusb.v00 --- vmw_ahci.v00 --- clusters.v00 --- crx.v00 --- elx_esx_.v00 --- btldr.v00 --- esx_dvfi.v00 --- esx_ui.v0 0 --- esxupdt.v00 --- tpmesxup.v00 --- weaselin.v00 --- loadesx.v00 --- lsuv2_hp.v00 --- lsuv2_in.v00 --- lsuv2_ls.v00 --- lsuv2_nv.v00 --- lsuv2_oe.v00 --- lsuv2_oe.v01 --- lsuv2_oe.v02 --- lsuv2_sm.v00 --- native_m.v00 --- qlnative.v00 --- vdfs.v00 --- vmware_e.v00 --- vsan.v00 --- vsanheal.v00 --- vsanmgmt.v00 --- tools.t00 --- xorg.v00 --- gc. v00 --- imgdb.tgz --- basemisc.tgz --- resvibs.tgz --- imgpayld.tgz build = seven .0.2-0.0.17867351
updated = zero
Here, you can automatically install ESXi 7 through PXE based on DHCP, automatically set system password, automatically accept license, automatically add product key, automatically enable SSH service, automatically enable shell service, automatically set power mode to high performance, disable IPV6, not participate in (CEIP) customer experience improvement plan, automatically configure NTP, and automatically add private key.