实验环境
镜像:CentOS-7-x86_64-Minimal-2009.iso
镜像下载地址:https://mirrors.tuna.tsinghua.edu.cn/
Centos7镜像:https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
服务端:server IP:192.168.110.11 网卡模式:NAT 内存:2048MB
客户端:client IP: 网卡模式:NAT 内存:2048MB
实验过程:
1.配置yum源
[root@server ~]# mv /etc/yum.repos.d/C* /media/
[root@server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
2.挂载镜像
[root@server ~]# mkdir /media/cdrom
[root@server ~]# mount /dev/sr0 /media/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载
3.配置DHCP
[root@server ~]# yum install -y dhcp
[root@server ~]# vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
allow booting;
allow bootp;
subnet 192.168.110.0 netmask 255.255.255.0{
option subnet-mask 255.255.255.0;
range 192.168.110.100 192.168.110.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.110.11;
filename "pxelinux.0"; # 引导文件位置,这边表示TFTP根目录(/var/lib/tftpboot/)下的pxelinux.0文件
}
[root@server ~]# systemctl start dhcpd
[root@server ~]# systemctl enable dhcpd
[root@server ~]# ss -nulp | grep dhcp
UNCONN 0 0 *:67 *:* users:(("dhcpd",pid=1452,fd=7))
4.配置TFTP
[root@server ~]# yum install -y xinetd tftp-server
[root@server ~]# 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 -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@server ~]# systemctl restart xinetd
[root@server ~]# systemctl restart tftp
[root@server ~]# ss -nulp | grep 69
UNCONN 0 0 *:69 *:* users:(("xinetd",pid=1468,fd=5))
5.SYSLinux服务程序
[root@server ~]#yum install syslinux -y
[root@server ~]#cd /var/lib/tftpboot/
[root@server tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@server tftpboot]# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} .
[root@server tftpboot]# mkdir pxelinux.cfg
[root@server tftpboot]# cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default
[root@server tftpboot]# vi pxelinux.cfg/default
6.vsftpd服务
[root@server ~]# yum install -y vsftpd
[root@server ~]# systemctl start vsftpd
[root@server ~]# cp -r /media/* /var/ftp/
7.关闭防火墙&&临时禁用selinux
[root@server ~]# systemctl disable firewalld
[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0
8.Kickstart应答文件
这里你可以按需求自己去安装
[root@server ~]# cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@server ~]# chmod 777 /var/ftp/pub/ks.cfg
[root@server ~]# vim /var/ftp/pub/ks.cfg
1 #version=DEVEL
2 # System authorization information
3 auth --enableshadow --passalgo=sha512
4 # Use CDROM installation media
5 #cdrom
6 url --url=ftp://192.168.110.11/cdrom
7 # Use graphical install
8 #graphical
9 text
10 # Run the Setup Agent on first boot
11 firstboot --enable
12 ignoredisk --only-use=sda
13 # Keyboard layouts
14 keyboard --vckeymap=us --xlayouts='us'
15 # System language
16 lang en_US.UTF-8
17
18 # Network information
19 network --bootproto=dhcp --device=ens32 --onboot=yes --ipv6=auto --no-activate
20 network --hostname=server1
21
22 # Root password
23 rootpw --iscrypted $6$zYGvbEuQ7XhWzs7/$KvjfF.5csk53KTxYd4Hh0m/2mI/0XE9MmbXmL7T1IdiSd8lji1bH2oeZRBn0e06L5Mz9MvFGALI3e0TneTOgE0
24 # System services
25 services --enabled="chronyd"
26 # System timezone
27 timezone Asia/Shanghai --isUtc --nontp
28 # System bootloader configuration
29 bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
30 autopart --type=lvm
31 # Partition clearing information
32 clearpart --none --initlabel
33
34 reboot
35 %packages
36 @^minimal
37 @core
38
39
40 %end
41
42 %post
43
44 useradd server1
45 echo 123456 | passwd --sdtin server1
46
47 %end
48
49 %anaconda
50 pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
51 pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
52 pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
53 %end
9.结果