PXE

最後更新: 2018-03-07

介紹

 

PXE (abbreviation of preboot execution environment)

目錄

  • DHCP Setting (dnsmasq)
  • Data Disk (for boot PXE loader)
  • Configuring PXE server(tftpd-hpa)
  • Copying Ubuntu Installation files to the PXE Server
  • iPXE

 


DHCP Setting(dnsmasq)

 

/etc/dnsmasq.conf

# PXE Setting
conf-file=/etc/dnsmasq.pxe.conf

tftp

/etc/dnsmasq.pxe.conf

# dhcp-boot
# IPv4 only
# Specify the location of the boot-loader file required by PXE clients.
# Usage: dhcp-boot=FILE,ServerName,IP

# PXE
dhcp-boot=pxelinux.0,pxeserver,192.168.123.10

# Assign Static IPs
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.123.56

Test:

Client

dhclient eth0

cat /var/lib/dhcp/dhclient.leases

lease {
  filename "pxelinux.0";
  server-name "pxeserver";
)

只有拿 pxelinux.0 時才 ping 到

Remark

In order to use PXE, you must set option 66 (TFTP Boot Server Address) and option 67 (Bootfile name).

 * 此方法只適用於 DHCP 與 TFTP 是同一架機, 原時是設定唔到 "next-server"

next-server: address of the server to use in the next step of the client's bootstrap process'

66     Server-Name        # TFTP Server Name

67     Bootfile-Name      # Boot File Name

dhcp-option=66,192.168.123.10
dhcp-option=67,pxelinux.0

iscsi

dhcp-option=17,iscsi:192.168.123.10::::iqn.2018-03.local.home:u16
dhcp-option=203,iqn.2018-03.local.u16

17 = set root-path

203 = set initiators

 


Data Disk (for PXE boot loader)

 

/etc/fstab

#### PXE
UUID="5396c39d-c9c7-48db-8ab1-e81fb168e8d3" /home/pxe           ext4    noatime 0 0

mount -a

 


Configuring PXE server(tftpd-hpa)

 

apt-get install tftpd-hpa

/etc/default/tftpd-hpa

# /etc/default/tftpd-hpa

# --secure, -s             # Change root directory on startup.

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/pxe/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"

/etc/init.d/tftpd-hpa start

Test

# tftp = 69

netstat -al | grep tftp

udp        0      0 *:tftp                  *:*

Server:

touch /home/pxe/tftpboot/test.txt

Client:

atftp -g -r test.txt -l test.txt 192.168.123.10

echo $?

0

 


Copying Ubuntu Installation files to the PXE Server

 

# Ubuntu netboot ISO

http://cdimage.ubuntu.com/netboot/

# DL

cd /home/pxe/tftpboot

wget http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd...

# Unzip

tar -zxf netboot.tar.gz

 


ipxe

 

https://datahunter.org/ipxe

 


 

Creative Commons license icon Creative Commons license icon