关闭防火墙,SeLinux。 [root@kickstart ~]# iptables –F;systemctl disable firewalld.service [root@kickstart ~]# setenforce 0;sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 安装DHCP服务 [root@kickstart
关闭防火墙,SeLinux。
[root@kickstart ~]# iptables –F;systemctl disable firewalld.service
[root@kickstart ~]# setenforce 0;sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
安装DHCP服务
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package dhcpd available.
Error: Nothing to do
[root@kickstart ~]# yum install dhcp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-83.el7.centos.1 will be installed
--> Processing Dependency: dhcp-libs(x86-64) = 12:4.2.5-83.el7.centos.1 for package: 12:dhcp-4.2.5-83.el7.centos.1.x86_64
--> Processing Dependency: dhcp-common = 12:4.2.5-83.el7.centos.1 for package: 12:dhcp-4.2.5-83.el7.centos.1.x86_64
--> Running transaction check
---> Package dhcp-common.x86_64 12:4.2.5-82.el7.centos will be updated
--> Processing Dependency: dhcp-common = 12:4.2.5-82.el7.centos for package: 12:dhclient-4.2.5-82.el7.centos.x86_64
---> Package dhcp-common.x86_64 12:4.2.5-83.el7.centos.1 will be an update
---> Package dhcp-libs.x86_64 12:4.2.5-82.el7.centos will be updated
---> Package dhcp-libs.x86_64 12:4.2.5-83.el7.centos.1 will be an update
--> Running transaction check
---> Package dhclient.x86_64 12:4.2.5-82.el7.centos will be updated
---> Package dhclient.x86_64 12:4.2.5-83.el7.centos.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
dhcp x86_64 12:4.2.5-83.el7.centos.1 updates 515 k
Updating for dependencies:
dhclient x86_64 12:4.2.5-83.el7.centos.1 updates 286 k
dhcp-common x86_64 12:4.2.5-83.el7.centos.1 updates 177 k
dhcp-libs x86_64 12:4.2.5-83.el7.centos.1 updates 133 k
Transaction Summary
===========================================================================================================================
Install 1 Package
Upgrade ( 3 Dependent packages)
Total download size: 1.1 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): dhclient-4.2.5-83.el7.centos.1.x86_64.rpm | 286 kB 00:00:00
(2/4): dhcp-common-4.2.5-83.el7.centos.1.x86_64.rpm | 177 kB 00:00:00
(3/4): dhcp-4.2.5-83.el7.centos.1.x86_64.rpm | 515 kB 00:00:00
(4/4): dhcp-libs-4.2.5-83.el7.centos.1.x86_64.rpm | 133 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------
Total 4.4 MB/s | 1.1 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 12:dhcp-libs-4.2.5-83.el7.centos.1.x86_64 1/7
Updating : 12:dhcp-common-4.2.5-83.el7.centos.1.x86_64 2/7
Installing : 12:dhcp-4.2.5-83.el7.centos.1.x86_64 3/7
Updating : 12:dhclient-4.2.5-83.el7.centos.1.x86_64 4/7
Cleanup : 12:dhclient-4.2.5-82.el7.centos.x86_64 5/7
Cleanup : 12:dhcp-common-4.2.5-82.el7.centos.x86_64 6/7
Cleanup : 12:dhcp-libs-4.2.5-82.el7.centos.x86_64 7/7
Verifying : 12:dhcp-common-4.2.5-83.el7.centos.1.x86_64 1/7
Verifying : 12:dhcp-4.2.5-83.el7.centos.1.x86_64 2/7
Verifying : 12:dhcp-libs-4.2.5-83.el7.centos.1.x86_64 3/7
Verifying : 12:dhclient-4.2.5-83.el7.centos.1.x86_64 4/7
Verifying : 12:dhcp-common-4.2.5-82.el7.centos.x86_64 5/7
Verifying : 12:dhclient-4.2.5-82.el7.centos.x86_64 6/7
Verifying : 12:dhcp-libs-4.2.5-82.el7.centos.x86_64 7/7
Installed:
dhcp.x86_64 12:4.2.5-83.el7.centos.1
Dependency Updated:
dhclient.x86_64 12:4.2.5-83.el7.centos.1 dhcp-common.x86_64 12:4.2.5-83.el7.centos.1
dhcp-libs.x86_64 12:4.2.5-83.el7.centos.1
Complete!
配置DHCP服务
[root@kickstart dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts
[root@kickstart dhcp]# cat dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
[root@kickstart dhcp]# mv dhcpd.conf dhcpd.conf0622
[root@kickstart dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example dhcpd.conf
[root@kickstart dhcp]# ll
total 12
drwxr-xr-x. 2 root root 6 Jun 10 00:09 dhclient.d
drwxr-xr-x. 2 root root 28 Jun 22 10:51 dhclient-exit-hooks.d
-rw-r--r-- 1 root root 120 Jun 10 00:09 dhcpd6.conf
-rw-r--r-- 1 root root 3262 Jun 22 10:59 dhcpd.conf
-rw-r--r-- 1 root root 117 Jun 10 00:09 dhcpd.conf0622
drwxr-x--- 2 root dhcpd 28 Jun 22 10:51 scripts
在dhcpd.conf增加如下配置
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.101 192.168.20.200;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 192.168.20.254;
option broadcast-address 192.168.20.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.20.100;
filename "pxelinux.0";
}
开启服务,并设为开机自动启动;
[root@kickstart dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts
[root@kickstart dhcp]# cat dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
[root@kickstart dhcp]# mv dhcpd.conf dhcpd.conf0622
[root@kickstart dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example dhcpd.conf
[root@kickstart dhcp]# ll
total 12
drwxr-xr-x. 2 root root 6 Jun 10 00:09 dhclient.d
drwxr-xr-x. 2 root root 28 Jun 22 10:51 dhclient-exit-hooks.d
-rw-r--r-- 1 root root 120 Jun 10 00:09 dhcpd6.conf
-rw-r--r-- 1 root root 3262 Jun 22 10:59 dhcpd.conf
-rw-r--r-- 1 root root 117 Jun 10 00:09 dhcpd.conf0622
drwxr-x--- 2 root dhcpd 28 Jun 22 10:51 scripts
在dhcpd.conf增加如下配置
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.101 192.168.20.200;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 192.168.20.254;
option broadcast-address 192.168.20.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.20.100;
filename "pxelinux.0";
}
DHCP配置完成;
安装tftp-server服务;
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package tftp-server.x86_64 0:5.2-22.el7 will be installed
---> Package xinetd.x86_64 2:2.3.15-14.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
tftp-server x86_64 5.2-22.el7 base 47 k
xinetd x86_64 2:2.3.15-14.el7 base 128 k
Transaction Summary
===========================================================================================================================
Install 2 Packages
Total download size: 175 k
Installed size: 325 k
Is this ok [y/d/N]: y
Downloading packages:
(1/2): tftp-server-5.2-22.el7.x86_64.rpm | 47 kB 00:00:00
(2/2): xinetd-2.3.15-14.el7.x86_64.rpm | 128 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------
Total 868 kB/s | 175 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:xinetd-2.3.15-14.el7.x86_64 1/2
Installing : tftp-server-5.2-22.el7.x86_64 2/2
Verifying : tftp-server-5.2-22.el7.x86_64 1/2
Verifying : 2:xinetd-2.3.15-14.el7.x86_64 2/2
Installed:
tftp-server.x86_64 0:5.2-22.el7 xinetd.x86_64 2:2.3.15-14.el7
Complete!
开启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
}
[root@kickstart xinetd.d]# systemctl enable xinetd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/xinetd.service to /usr/lib/systemd/system/xinetd.service.
[root@kickstart xinetd.d]# systemctl enable xinetd.service –now
安装bootstrap,并配置tftp引导;
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package syslinux.x86_64 0:4.05-15.el7 will be installed
--> Processing Dependency: mtools for package: syslinux-4.05-15.el7.x86_64
--> Running transaction check
---> Package mtools.x86_64 0:4.0.18-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
syslinux x86_64 4.05-15.el7 base 990 k
Installing for dependencies:
mtools x86_64 4.0.18-5.el7 base 203 k
Transaction Summary
===========================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 1.2 M
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): mtools-4.0.18-5.el7.x86_64.rpm | 203 kB 00:00:00
(2/2): syslinux-4.05-15.el7.x86_64.rpm | 990 kB 00:00:01
---------------------------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 1.2 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mtools-4.0.18-5.el7.x86_64 1/2
Installing : syslinux-4.05-15.el7.x86_64 2/2
Verifying : mtools-4.0.18-5.el7.x86_64 1/2
Verifying : syslinux-4.05-15.el7.x86_64 2/2
Installed:
syslinux.x86_64 0:4.05-15.el7
Dependency Installed:
mtools.x86_64 0:4.0.18-5.el7
Complete!
[root@kickstart ~]# updatedb
[root@kickstart ~]# locate pxelinux.0
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0
[root@kickstart ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
拷贝系统安装文件到tftp;
mount: /dev/sr0 is write-protected, mounting read-only
[root@kickstart ~]# cd /media/
[root@kickstart media]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@kickstart media]# cd isolinux/
[root@kickstart isolinux]# ls
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vmlinuz
boot.msg initrd.img isolinux.cfg splash.png vesamenu.c32
[root@kickstart isolinux]# cp * -r /var/lib/tftpboot/
自定义安装引导菜单;
[root@kickstart isolinux]# cd /var/lib/tftpboot/
[root@kickstart tftpboot]# cp isolinux.cfg pxelinux.cfg/default
添加自定义菜单项到default文件
label linux-ks
menu label ^Install CentOS 7 Auto
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 ks=ftp://192.168.20.100/pub/ks/centos7-ks.cfg
Tftp配置完成;
安装FTP服务
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-29.el7_9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
vsftpd x86_64 3.0.2-29.el7_9 updates 173 k
Transaction Summary
===========================================================================================================================
Install 1 Package
Total download size: 173 k
Installed size: 353 k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-29.el7_9.x86_64.rpm | 173 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vsftpd-3.0.2-29.el7_9.x86_64 1/1
Verifying : vsftpd-3.0.2-29.el7_9.x86_64 1/1
Installed:
vsftpd.x86_64 0:3.0.2-29.el7_9
Complete!
开启FTP服务,并设置为开机启动;
[root@kickstart ~]# systemctl enable vsftpd.service --now
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
拷贝系统镜像到共享目录;
[root@kickstart ftp]# ls
pub
[root@kickstart ftp]# cd pub/
[root@kickstart pub]# ls
[root@kickstart pub]# mkdir ks
[root@kickstart pub]# mkdir centos7-iso
[root@kickstart pub]# cp /media/* -r centos7-iso/
FTP配置完成;
安装kickstart;
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package system-config-kickstart.noarch 0:2.9.7-1.el7 will be installed
--> Processing Dependency: system-config-keyboard >= 1.3.1 for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: pykickstart >= 1.78 for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: pygtk2 >= 1.99.11 for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: gtk2 >= 2.6 for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: gtk2 >= 2.6 for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: system-config-language for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: system-config-date for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: pygtk2-libglade for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Processing Dependency: hicolor-icon-theme for package: system-config-kickstart-2.9.7-1.el7.noarch
--> Running transaction check
---> Package gtk2.x86_64 0:2.24.31-1.el7 will be installed
--> Processing Dependency: pango >= 1.20.0-1 for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: libtiff >= 3.6.1 for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: libXrandr >= 1.2.99.4-2 for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: atk >= 1.29.4-2 for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: gtk-update-icon-cache for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: libpangoft2-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: libpangocairo-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64
--> Processing Dependency: libpango-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64
……
startup-notification.x86_64 0:0.12-8.el7 system-config-date.noarch 0:1.10.6-3.el7.centos
system-config-date-docs.noarch 0:1.0.11-4.el7 system-config-keyboard.noarch 0:1.4.0-5.el7
system-config-keyboard-base.noarch 0:1.4.0-5.el7 system-config-language.noarch 0:1.4.0-9.el7
trousers.x86_64 0:0.3.14-2.el7 usermode.x86_64 0:1.111-6.el7
usermode-gtk.x86_64 0:1.111-6.el7 webkitgtk4.x86_64 0:2.28.2-2.el7
webkitgtk4-jsc.x86_64 0:2.28.2-2.el7 xcb-util.x86_64 0:0.4.0-2.el7
xkeyboard-config.noarch 0:2.24-1.el7 xml-common.noarch 0:0.6.3-39.el7
yelp.x86_64 2:3.28.1-1.el7 yelp-libs.x86_64 2:3.28.1-1.el7
yelp-xsl.noarch 0:3.28.0-1.el7
Complete!
配置ks文件;
配置完成后,保存为.cfg文件;
[root@kickstart ~]# cp centos7-ks.cfg /var/ftp/pub/ks/