環境:linux
Centos 6.8服務器一臺,提供FTP、DHCP和鏡像安裝源vim
未安裝系統的客戶機一臺服務器
步驟:app
一、關閉Selinux、firewallless
[root@localhost ~]# vi /etc/selinux/config dom
SELINUX=enforcing ###將enforcing 修改成disablesocket
[root@localhost ~]# service iptables stop ###中止防止牆服務ide
[root@localhost ~]# chkconfig iptables off ###關閉開機自啓this
二、關閉NetworkMangerspa
[root@localhost ~]# service NetworkManager stop ###中止NetworkManger服務
[root@localhost ~]# chkconfig NetworkManager off ###禁止NetworkManger開機自動
三、安裝DHCP服務並配置
配置好YUM源
[root@localhost yum.repos.d]# yum install -y dhcp
[root@localhost ~]# cp -p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp:是否覆蓋"/etc/dhcp/dhcpd.conf"?
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 192.168.1.1;
next-server 192.168.1.11;
filename 「pxelinux.0」;
default-lease-time 86400;
max-lease-time 86400;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.100;
option routers 192.168.1.1;
}
[root@localhost dhcp]# service dhcpd restart
正在啓動 dhcpd: [肯定]
[root@localhost dhcp]# chkconfig dhcpd on
四、安裝ftp服務並配置
[root@localhost /]# yum install -y tftp-server xinetd vsftpd
[root@localhost /]# 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 ####此處將原來的yes改成no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@localhost /]# service xinetd start
正在啓動 xinetd: [肯定]
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# service vsftpd start
爲 vsftpd 啓動 vsftpd: [肯定]
[root@localhost /]# chkconfig vsftpd on
五、安裝syslinux、system-config-kickstart
syslinux 提供pxenux.0軟件
system-config-kickstart 提供kickstart 軟件
[root@localhost /]# yum install -y syslinux system-config-kickstart
六、拷貝相應文件並建立pxlinux.cfg文件
[root@localhost /]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost /]# cp /mnt/cdrom/isolinux/vmlinuz /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/initrd.img /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/boot.cat /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/boot.msg /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/vesamenu.c32 /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/splash.jpg /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/isolinux.bin /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/memtest /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/TRANS.TBL /var/lib/tftpboot/
[root@localhost /]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
vmlinuz:內核,提供驅動和識別代碼
initrd.img:提供根鏡像底部命令
boot.cat:菜單格式
boot.msg:菜單消息
vesamenju.c32:菜單顏色
splash.jgp:菜單背景
isolinux.bin:GRUB引導程序的前身
memtest:內存檢測
TRANS.TBL:
pxelinux.0:pxeclient用於提供給pxelinux.0作程序交接
[root@localhost /]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost /]# cp -p /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot//pxelinux.cfg/default
[root@localhost /]# vi /var/lib/tftpboot//pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 600 ####此處爲啓動菜單等待操做時間,默認爲60S
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.8!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.1.11/ks/s.cfg #### ks配置文件存放位置
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
[root@localhost /]# chmod 777 /var/lib/tftpboot/pxelinux.cfg/default
七、配置kickstart應答文件並配置
[root@localhost /]# system-config-kickstart
[root@localhost /]# mount /dev/cdrom /var/ftp/pub
[root@localhost /]# mkdir /var/ftp/ks
[root@localhost /]# cp /root/ks.cfg /var/ftp/ks/
[root@localhost /]# chmod 777 /var/ftp/ks/ks.cfg
[root@localhost /]# cat /var/lib/tftpboot/pxelinux.cfg/default | grep ks
append initrd=initrd.img ks=ftp://192.168.1.11/ks/ks.cfg
八、客戶機開機