1. sed -i "s#=enforcing#=disabled#g"        /etc/selinux/config  #关闭selinux
    setenforce  0                                                 #禁止selinux
    service iptables stop                                         #禁止防火墙
    yum install  dhcp tftp-server syslinux httpd system-config-kickstart  -y         #安装软件包

    -------------------------------------------------------------------------------------------------
    2.
    编辑dhcp的配置文件:
      yum -y install vim
      vim /etc/dhcp/dhcpd.conf

    ddns-update-style none;
    default-lease-time 259200;
    max-lease-time 518400;
    option routers 172.16.0.1;
    option domain-name-servers 172.16.0.1;
    subnet 172.16.0.0 netmask 255.255.255.0 {
            range 172.16.0.80 172.16.0.89;
            option subnet-mask 255.255.255.0;
            next-server 172.16.0.70;      获取这个pxelinux.0 文件的tftp服务器地址
            filename "pxelinux.0";
    }

    service   dhcpd restart
    netstat -antup | grep dhcpd
    chkconfig  dhcpd on
    service  dhcpd  start
    lsof -i udp:67

    ----------------------------------------------------------------------------------------------
    3.
    编辑tftp的配置文件
    vim /etc/xinetd.d/tftp
    将配置文件中的
    disable = no
    service  xinetd  restart
    cat /etc/services | grep tftp
    netstat -anplut | grep  :69
    chkconfig xinetd on
    ----------------------------------------------------------------------------------------------
    4.

    rm -rf /var/lib/tftpboot/*
    mkdir /var/lib/tftpboot/pxelinux.cfg
    mount /dev/sr0 /mnt
    cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
    cp /mnt/isolinux/* /var/lib/tftpboot/
    cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    chmod 644 /var/lib/tftpboot/pxelinux.cfg/default

    ----------------------------------------------------------------------------------------------
    5.
    vim /var/lib/tftpboot/pxelinux.cfg/default

    timeout 600
    改为
    timeout 10
    搜索:
    label linux

    append initrd=initrd.img
    改为
    append  initrd=initrd.img ks=http://172.16.0.70/ks.cfg
    6.
    启动 httpd
    /etc/init.d/httpd start
    chkconfig --level 35 httpd on
    mkdir /var/www/html/centos6
    mount /dev/cdrom /var/www/html/centos6
    service   httpd start
    lsof -i tcp:80;netstat -anplut| grep httpd
    7.
    yum groupinstall "X Window System"
    yum groupinstall "GNOME Desktop Environment"
    startX
    system-config-kickstart
    生成ks.cfg文件保存至/var/www/html 目录下
    这里给出一个ks.cfg示例文件

    centos7   PXE装机

    1.
    setenforce 0
    systemctl stop firewalld
    yum install -y dhcp tftp-server syslinux httpd system-config-kickstart
    ----------------------------------------------------------------------------------------------
    2.编辑dhcp的配置文件:

      vim /etc/dhcp/dhcpd.conf

      subnet 172.16.0.0 netmask 255.255.255.0 {
      range 172.16.0.140 172.16.0.150;
      option domain-name-servers 172.16.0.1;
      option routers 172.16.0.1;
      option broadcast-address 172.16.0.255;
      default-lease-time 3600;
      max-lease-time 7200;
      next-server 172.16.0.61;  #寻找tftp服务器 /pxelinux.0
      filename "/pxelinux.0";
    }
    systemctl restart dhcpd
    netstat -antup | grep dhcpd
    systemctl enable dhcpd
    systemctl start dhcpd
    lsof -i udp:67
    ----------------------------------------------------------------------------------------------
    3.编辑tftp的配置文件

    vim /etc/xinetd.d/tftp
    将配置文件中的
    disable = no
    systemctl restart xinetd
    cat /etc/services | grep tftp
    netstat -anplut | grep  :69
    ----------------------------------------------------------------------------------------------
    4.
    rm -rf /var/lib/tftpboot/*
    mkdir /var/lib/tftpboot/pxelinux.cfg/
    cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
    mount /dev/sr0 /mnt
    cp -a /mnt/isolinux/* /var/lib/tftpboot/
    cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    chmod 644 /var/lib/tftpboot/pxelinux.cfg/default
    ----------------------------------------------------------------------------------------------
    5.
    vim /var/lib/tftpboot/pxelinux.cfg/default

    default vesamenu.c32
    timeout 600
    改为
    default linux
    timeout 60
    搜索:
    label linux

    append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0\x20Server.x86_64 rd.live.check quiet
    改为
    append initrd=initrd.img ks=http://192.168.20.61/ks.cfg  inst.repo=http://192.168.20.61/rhel7  quiet

    6.启动 httpd
    mkdir -v /var/www/html/rhel7
    mount /dev/cdrom /var/www/html/rhel7
    systemctl enable httpd
    systemctl start httpd
    lsof -i tcp:80
    systemctl umask httpd;systemctl restart httpd;systemctl enable  httpd;netstat -anplut| grep httpd

    7.用system-config-kickstart生成ks.cfg文件放到/var/www/html下
    本文提供一个ks.cfg文件供测试使用