Let’s Install and Configure PXE Server CentOS 6

Attention: open in a new window. PDFPrintE-mail

1. Install Packages For PXE Server

[root@foo1 ~]# yum install tftp-server syslinux httpd -y

2. Create TFTP Server Directory

Create a new directory where you want to store TFTP server files. Copy TFTP server configuration files into it.

[root@foo1 ~]# mkdir /tftpboot
[root@foo1 ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@foo1 ~]# cp /usr/share/syslinux/menu.c32 /tftpboot/
[root@foo1 ~]# cp /usr/share/syslinux/memdisk /tftpboot/
[root@foo1 ~]# cp /usr/share/syslinux/mboot.c32 /tftpboot/
[root@foo1 ~]# cp /usr/share/syslinux/chain.c32 /tftpboot/

3. Create PXE Server Configuration Directory

[root@foo1 ~]# mkdir /tftpboot/pxelinux.cfg

4. Edit TFTP Configuration File (/etc/xinetd.d/tftp)

Edit “server_args = -s /var/lib/tftpboot” line to point to the newly created TFTP server directory and “disable = yes” to no, to enable TFTP service.

[root@foo1 ~]# cat /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 /tftpboot
    disable          = no
    per_source       = 11
    cps              = 100 2
    flags            = IPv4

5. Create CentOS 6 Boot Image Directory

Create CentOS 6 (or other desired distribution) boot image directory and mount or copy the linux ISO image contents into it.

[root@foo1 ~]# mkdir -p /tftpboot/centos6/i386
[root@foo1 ~]# mount -o loop CentOS-6.4-i386-bin-DVD1.iso /tftpboot/centos6/i386/

6. Create PXE Server Apache Configuration File

Apache (httpd) is used to transfer CentOS 6 installation ISO files to PXE client since it is faster and more reliable then TFTP Edit the directory path and IP address to reflect your configuration.

[root@foo1 ~]# cat /etc/httpd/conf.d/pxeboot.conf
Alias /centos6/i386 /tftpboot/centos6/i386

<Directory /tftpboot/centos6/i386>
 Options Indexes FollowSymLinks
 Order Deny,Allow
 Deny from all
 Allow from 127.0.0.1 192.168.1.0/24
</Directory>

7. Create PXE Server Configuration File

Edit the directory path and HTTP path to reflect your configuration.

[root@foo1 ~]# cat /tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

menu title ########## PXE Boot Menu ##########

label 1
menu label ^1) Install CentOS 6 i386
kernel centos6/i386/images/pxeboot/vmlinuz
append initrd=centos6/i386/images/pxeboot/initrd.img method=http://192.168.1.5/centos6/i386 devfs=nomount

label 2 
menu label ^2) Boot from local drive localboot

8. Reconfigure DHCP Server

Append this at the end of your DHCP configuration file (/etc/dhcp/dhcpd.conf). Edit the IP address with your PXE Server IP address.

# GeekPeek.Net scripts - Added for PXE Server configuration
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server 192.168.1.5;
filename "pxelinux.0";

9. Restart/reload all services

[root@foo1 ~]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@foo1 ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@foo1 ~]# /etc/init.d/dhcpd restart
Shutting down dhcpd:                                       [  OK  ]
Starting dhcpd:                                            [  OK  ]

We have successfully installed and configured our PXE Server.