yum install -y dhcp tftp-server xinetd syslinux httpd httpd-devel
vim /etc/dhcp/dhcpd.conf 
	#
	# DHCP Server Configuration file.
	#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
	#   see 'man 5 dhcpd.conf'
	ddns-update-style interim;
	ignore client-updates;
	option domain-name "kting.cn";
	option domain-name-servers 192.168.1.99;
	default-lease-time 43200;
	max-lease-time 86400;
	log-facility local7;
	subnet 192.168.1.0 netmask 255.255.255.0 {
	range 192.168.1.150 192.168.1.200;
	option routers 192.168.1.99;
	}
	next-server 192.168.1.99;
	filename="pxelinux.0";
/etc/init.d/dhcpd conftest
/etc/init.d/dhcpd configtest
/etc/init.d/dhcpd restart

rpm -ql tftp-server
vim /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	#指定tftp目录
        disable                 = no					#yes改为no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
/etc/init.d/xinetd	restart

mkdir /var/www/html/centos-6.4-x86_64
mount /dev/cdrom /var/www/html/centos-6.4-x86_64/
ll /var/www/html/centos-6.4-x86_64/
vim /var/www/html/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.1.99/centos-6.4-x86_64"
# Root password
rootpw www.kting.cn
# 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/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --append="crashkernel=auto crashkernel=auto rhgb rhgb quiet quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
#part /boot --fstype=ext4 --size=200
#part pv.008002 --size=81440
#volgroup vg0 --pesize=8192 pv.008002
#logvol / --fstype=ext4 --name=root --vgname=vg0 --size=60480
#logvol swap --name=swap --vgname=vg0 --size=1024
part /boot --fstype=ext4 --size=500
part / --fstype=ext4 --grow --asprimary --size=200
part swap --size=4096
%post
sed -i '1,$s@id:[0-9]:initdefault:@id:3:initdefault:@g' /etc/inittab
# Set the hostname
sed -i '/BOOTPROTO/ s/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '$ a\IPADDR=223.203.194.130\nNETMASK=255.255.255.240\nGATEWAY=223.203.194.129' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '$ a\nameserver 202.106.0.20' /etc/resolv.conf
IP=`ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F. '{print $NF}'`
sed -i "s@HOSTNAME=.*@HOSTNAME=web$IP.kting.cn@g" /etc/sysconfig/network
%end
#install  package
%packages
@additional-devel
@base
@compat-libraries
@console-internet
@core
@debugging
@development
@ftp-server
@large-systems
@legacy-unix
@nfs-file-server
@network-file-system-client
@network-tools
@performance
@perl-runtime
@server-platform
@server-platform-devel
@server-policy
@system-admin-tools
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libgnomeui-devel
libbonobo-devel
libXau-devel
libgcrypt-devel
popt-devel
libXrandr-devel
libxslt-devel
libglade2-devel
gnutls-devel
mtools
pax
sgpio
#device-mapper-persistent-data
systemtap-client
jpackage-utils
tcp_wrappers
perl-DBD-SQLite
%post
#sync time
echo '0 */2 * * * /usr/sbin/ntpdate 61.153.197.226 pool.ntp.org && /sbin/hwclock -w' >> /var/spool/cron/root
echo '/usr/sbin/ntpdate 61.153.197.226 pool.ntp.org && /sbin/hwclock -w' >> /etc/rc.local
%end

/etc/init.d/httpd start
cp /var/www/html/centos-6.4-x86_64/isolinux/{boot.msg,splash.jpg,vesamenu.c32} /var/lib/tftpboot/
cp /var/www/html/centos-6.4-x86_64/p_w_picpaths/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /var/www/html/centos-6.4-x86_64/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
chmod +w /var/lib/tftpboot/pxelinux.cfg/default 
vim /var/lib/tftpboot/pxelinux.cfg/default
label linux
  menu label ^Install an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.1.99/ks.cfg

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
chkconfig xinetd on
chkconfig dhcpd on
chkconfig httpd on