Build a PXE Boot Server¶
- Author:
Dimitry Dukhovny
Installing a pre-boot execution environment (PXE) in your network takes some planning and should only exist in your DHCP sandbox, not in production.
Required packages under Centos/RHEL/Fedora¶
1yum -y install httpd xinetd syslinux tftp-server mtools
2# Do not forget SELinux
3setsebool -P tftp_anon_write 1
4setsebool -P tftp_home_dir 1
httpd is the Apache web server
xinetd is the extended inetd that will trigger the tftp server
syslinux is a boot loader bundling ISO, PXE, and EXT Linux boots
tftp-server is the trivial file transfer protocol server
mtools is an MSDOS disk management suite
Stage OS disk¶
For this example, we will use Centos7 from the DVD ISO.
1mount -o loop /mnt/images/Centos7-DVD.iso /mnt/pxe/centos7
Web server¶
1Alias /centos7 /mnt/pxe/centos7
2<Directory /mnt/pxe/centos7>
3Options Indexes FollowSymLinks
4Order Deny,Allow
5Allow from all
6<Directory>
Then, bounce Apache.
OS stage¶
Copy boot loaders to TFTP server location
1mkdir /var/lib/tftpboot
2ln -s /usr/share/syslinux/* /var/lib/tftpboot/
3mkdir /var/lib/tftpboot/centos7
4ln -s /mnt/pxe/centos7/images/pxeboot/* /var/lib/tftpboot/centos7/
5mkdir /var/lib/tftpboot/pxelinux.cfg
6touch /var/lib/tftpboot/pxelinux.cfg/default
1default menu.c32
2prompt 0
3timeout 300
4ONTIMEOUT 1
5
6menu title CentOS 7 PXE Menu
7
8label 1
9menu label ^1) Install CentOS 7
10menu default
11kernel centos7/vmlinuz
12append initrd=centos7/initrd.img method=http://10.168.123.11/centos7 devfs=nomount
13
14label 2
15menu label ^2) Boot from local drive
16localboot 0
Services¶
Set “disable=yes” to be “disable=no” in xinetd.d/tftp
1service tftp
2{
3 socket_type = dgram
4 protocol = udp
5 wait = yes
6 user = root
7 server = /usr/sbin/in.tftpd
8 server_args = -s /var/lib/tftpboot
9 disable = no
10 per_source = 11
11 cps = 100 2
12 flags = IPv4
13}
1[Unit]
2Description=Tftp Server
3
4[Service]
5ExecStart=/usr/sbin/in.tftpd -c -s /tftpboot
6StandardInput=socket
7
8[Install]
9WantedBy=multi-user.target
1systemctl restart xinetd
2systemctl enable xinetd
3systemctl restart httpd
4systemctl enable httpd
5# Open port 80 for fetching Linux bits
6firewall-cmd --permanent --add-service=http
7# Open port 69 for TFTP itself
8firewall-cmd --permanent --add-port=69/udp
9firewall-cmd --permanent --add-port=69/tcp
10firewall-cmd --reload