Linux centos PXE无人值守安装 DHCP+TFTP+HTTPD+Kickstart

网络模式:

NAT模式(共享主机的IP地址)

DHCP / TFTP IP:192.168.220.137

HTTP / FTP / NFS IP:192.168.220.137


环境搭建:

yum install -y tftp-server dhcp system-config-kickstart httpd xinetd syslinux

1.挂载ISO文件,复制光盘全部内容至http 的根目录/var/www/html/ 下

mkdir /mnt/cdrom

mount /dev/cdrom /mnt/cdrom

cp -r /mnt/cdrom/ /var/www/html/

2.配置TFTP

 vi /etc/xinetd.d/tftp

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 }

3.配置支持PXE的启动程序

cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/

cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot/

chmod 777 -Rf /var/lib/tftpboot/

mkdir /var/lib/tftpboot/pxelinux.cfg

cp /var/www/html/cdrom/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default

vi /var/lib/tftpboot/pxelinux.cfg/default

default ks

prompt 1

timeout 6

display boot.msg

F1 boot.msg

F2 options.msg 

F3 general.msg 

F4 param.msg 

F5 rescue.msg 

label linux

kernel vmlinuz

append initrd=initrd.img

label text 

kernel vmlinuz 

append initrd=initrd.img text 

label ks 

kernel vmlinuz 

append ks=http://192.168.220.137/ks.cfg initrd=initrd.img 

label local 

localboot 1 

label memtest86 

kernel memtest 

append -

4.配置DHCP

vim /etc/dhcp/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.220.0 netmask 255.255.255.0 {

        allow booting;

        allow bootp;

        allow unknown-clients;

        option routers                  192.168.222.137;

        option subnet-mask              255.255.255.0;

        option domain-name-servers      192.168.220.2;

        option time-offset              -18000; # Eastern Standard Time

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

        range dynamic-bootp 192.168.220.140 192.168.220.150;

        default-lease-time 21600;

        max-lease-time 43200;


        next-server  192.168.220.137;

        filename "pxelinux.0";

}

5.生成ks.cfg 文件

在桌面环境下配置Kickstart

vim /var/www/html/ks.cfg

#platform=x86, AMD64, 或 Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url --url="http://192.168.220.137/cdrom"

# Root password

rootpw --iscrypted $1$cWoyK/RZ$4mca7VVTDACquj0bE6aSR1

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone  Asia/Chongqing

# Network information

network  --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part /boot --fstype="ext4" --size=100

part swap --fstype="swap" --size=512

part / --fstype="ext4" --grow --size=1

%packages

@debugging

@legacy-unix

@network-file-system-client

@web-server

%end

测试:

servcei iptables stop

setenforce 0

service dhcpd start

service xinetd start

service vsftpd start



你可能感兴趣的:(http,TFTP,httpd,DHCP,pxe,kickstart)