How To Configure A PXE Server On CentOS 5.5



Configuring a PXE Server will help to automate an unattended installation on linux systems.

For this demo, I'm using a CentOS 5.5 machine to configure PXE Server
Server IP: 192.168.1.1
Server Name : server.example.com

Copy the contents of the CentOS 5.5 DVD to /var/www/html/centos
# mkdir /var/www/html/centos 
(If you get any error in creating the directory use the option -p, i.e.mkdir -p /var/www/html/centos)

# cp -r /media/CentOS_5.5_Final/*  /var/www/html/centos/

Configuring a local YUM repository
# mv /etc/yum.repos.d/* /tmp

# vim /etc/yum.repos.d/centos.repo
[centos]
name=CentOS 5.5 Repository
baseurl=file:///var/www/html/centos
gpgcheck=0
enabled=1

# yum repolist

Requirements for the PXE Server Configuration:
  • Clients can retrieve the packages from the PXE Server either from HTTP or FTP. We can use any one of them. Here I'm Using HTTP in my demo.
  • Clients should recieve an IP address automatically, so we configure DHCP on our Server as well. 
  • Also it requires (not mandatory) an answer file for automatic installation of the OS. So we install another package called as system-config-kickstart for creating answer files.
# yum install httpd dhcp system-config-kickstart -y

Configure the answer file use the default anaconda-ks.cfg as base and configure according to your requirement
# cp /root/anaconda-ks.cfg  /var/www/html/centos/ks.cfg

Open the ks.cfg file using kickstart utility
# system-config-kickstart

Configure the DHCP server
# cp /usr/share/doc/dhcp-3.0.5/dhcp.sample.conf /etc/dhcp/dhcpd.conf

# vim /etc/dhcp/dhcpd.conf
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
                option subnet-mask 255.255.255.0;
                option domain-name "example.com";
                range dynamic-bootp 192.168.1.225 192.168.1.254;
                default-lease-time 600;
                max-lease-time 7200;
                ### PXE Server IP Address ###
                next-server 192.168.1.1;
                filename "pxelinux.0";
}

# service dhcpd start

# chkconfig dhcpd on

Install the tftp-server and syslinux packages
# yum install tftp-server syslinux -y

# mkdir -p /tftpboot/{images,pxelinux.cfg}

# cp /var/www/html/centos/images/pxeboot/vmlinuz /tftpboot/images

# cp /var/www/html/centos/images/pxeboot/initrd.img /tftpboot/images

# vim /etc/xinetd.d/tftp
                server_args = -s /tftpboot
                disable = no

# service xinetd restart

# chkconfig tftp on

# cp /usr/lib/syslinux/menu.c32 /tftpboot/

# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

# vim /tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 100
MENU TITLE Operating System Selection
LABEL CentOS 5.5 x86 Edition
MENU LABEL CentOS 5.5 x86 Editon
KERNEL images/vmlinuz
append initrd=images/initrd.img linux ks=http://192.168.1.1/centos/ks.cfg

# system-config-securitylevel
Click on other ports and add 67 UDP for DHCP, 69 UDP for TFTP and also 80 TCP for Web Server to trusted ports.

Set the SELinux Mode to Permissive temporarily
To check the SELinux mode
#  getenforce

To set SELinux mode to Permissive
# setenforce 0

Post a Comment

Mới hơn Cũ hơn