二、操作
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#setenforce 0
[root@localhost ~]#yum install dhcp -y
[root@localhost ~]#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y
[root@localhost ~]#cd /etc/dhcp/
[root@localhost dhcp]#ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts
[root@localhost dhcp]#vim dhcpd.conf
32 subnet 192.168.174.0 netmask 255.255.255.0 {
33 range 192.168.174.10 192.168.174.50;
34 option routers 192.168.174.2;
35 next-server 192.168.174.100;
36 filename "pxelinux.0";
37 }
[root@localhost dhcp]#systemctl start dhcpd
[root@localhost dhcp]#yum install tftp-server.x86_64 -y
[root@localhost dhcp]#rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot
[root@localhost dhcp]#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
}
[root@localhost dhcp]#systemctl start tftp
[root@localhost dhcp]#cd /var/lib/tftpboot
[root@localhost tftpboot]#pwd
/var/lib/tftpboot
[root@localhost tftpboot]#mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost tftpboot]#ls /mnt
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[root@localhost tftpboot]#cd /mnt/isolinux
[root@localhost isolinux]#ls
boot.cat boot.msg grub.conf initrd.img isolinux.bin isolinux.cfg memtest splash.png TRANS.TBL vesamenu.c32 vmlinuz
[root@localhost /]#cd /var/lib/tftpboot
[root@localhost tftpboot]#cp /mnt/isolinux/vmlinuz /var/lib/tftpboot
[root@localhost tftpboot]#cp /mnt/isolinux/initrd.img /var/lib/tftpboot
[root@localhost tftpboot]#ls
initrd.img vmlinuz
[root@localhost tftpboot]#yum install syslinux -y
[root@localhost tftpboot]#rpm -ql syslinux | grep pxelinux
/usr/share/doc/syslinux-4.05/pxelinux.txt
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/gpxelinuxk.0
/usr/share/syslinux/pxelinux.0
[root@localhost tftpboot]#cp /usr/share/syslinux/pxelinux.0 .
[root@localhost tftpboot]#ls
initrd.img pxelinux.0 vmlinuz
[root@localhost tftpboot]#yum install vsftpd -y
[root@localhost tftpboot]#cd /var/ftp
[root@localhost ftp]#ls
pub
[root@localhost ftp]#mkdir centos7
[root@localhost ftp]#ls
centos7 pub
[root@localhost ftp]#mount /dev/sr0 centos7/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ftp]#ls centos7/
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[root@localhost ftp]#cd -
/var/lib/tftpboot
[root@localhost tftpboot]#mkdir pxelinux.cfg
[root@localhost tftpboot]#ls
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
[root@localhost tftpboot]#cd pxelinux.cfg
[root@localhost pxelinux.cfg]#ls
[root@localhost pxelinux.cfg]#vim default
default linux
timeout 600
label linux
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.174.100/centos7 ks=ftp://192.168.174.100/ks.cfg
label rescue
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.174.100/centos7 ks=ftp://192.168.174.100/ks.cfg
label test
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.174.100/centos7 ks=ftp://192.168.174.100/ks.cfg
[root@localhost pxelinux.cfg]#systemctl start vsftpd
[root@localhost pxelinux.cfg]#yum install system-config-kickstart -y
- 首先关闭服务器的防火墙和selinux