How to install pxe on ubuntu 24.04? How to configure TFTP and DHCP ?
1 Answers
Update your package manager
sudo apt update
Install the tftp service package
sudo apt install tftpd-hpa
create the /tftpboot directory in the root directory
sudo mkdir /tftpboot
Go to the location of the configuration file and configure it
sudo nano /etc/default/tftpd-hpa
TFTP_USERNAME="tftp" TFTP_DIRECTORY="/tftpboot" # place the target /tftpboot directory in the root directory TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="--secure"
restart the tftp service
sudo service tftp-hpa restart
install dnsmasq service
sudo apt install dnsmasq
Go to the location of the configuration file and configure it
sudo nano /etc/dnsmasq.conf
you need to configure the ip addresses according to your network
do not change the rest of the information
Note:
1.)You need to change which interface to listen to
2.) dhcp ip pool must change
3.)You need to change the default gateway and dns address
1. On which interface will we listen?
interface=enp2s0
2. To avoid infiltrating other interfaces when doing DHCP-only work
bind-interfaces
3. DHCP IP pool: 192.168.2.100-192.168.2.150, lease duration 12h
dhcp-range=192.168.2.100,192.168.2.150,12h
4. Default gateway and dns address
dhcp-option=3,192.168.2.1 dhcp-option=6,172.16.0.103
5. PXE bootloader for BIOS (Legacy)
dhcp-boot=pxelinux.0
6. Mapping according to customer architecture (DHCP option 93)
dhcp-match=peecees,option:client-arch,0 # x86 BIOS dhcp-match=efi32,option:client-arch,6 # UEFI IA32 dhcp-match=efi64,option:client-arch,7 # UEFI x86-64
7. PXE service according to customer architecture (pxe-service)
For Legacy BIOS
dhcp-boot=tag:peecees,/bios/pxelinux.0
For UEFI 32-bit
dhcp-boot=tag:efi32,/uefi/syslinux.efi
For UEFI 64-bit
dhcp-boot=tag:efi64,/uefi/syslinux.efi
restart the dnsmasq service
sudo service dnsmasq restart
create two different directories within the root directory /tftpboot
sudo mkdir /tftboot/bios
sudo mkdir /tftpboot/uefi
install the syslinux-common package
sudo apt install syslinux-common
Copy the three required legacy files into /tftboot/bios that you created in the root directory
sudo cp /lib/syslinux/modules/bios/ldlinux.c32 /tftboot/bios/.
sudo cp /lib/syslinux/modules/bios/libcom32.c32 /tftboot/bios/.
sudo cp /lib/syslinux/modules/bios/menu.c32 /tftboot/bios/.
Install the pxelinux package
sudo apt install pxelinux
Copy the pxelinux.0 legacy file to /tftboot/bios
sudo cp /usr/lib/PXELİNUX/pxelinux.0 /tftpboot/bios/.
Copy the three required legacy files into /tftboot/uefi that you created in the root directory
sudo cp /lib/syslinux/modules/efi64/ldlinux.e64 /tftpboot/uefi
sudo cp /lib/syslinux/modules/efi64/libutil.c32 /tftpboot/uefi
sudo cp /lib/syslinux/modules/efi64/menu.c32 /tftpboot/uefi
Install the syslinux-efi package
sudo apt install syslinux-efi
Copy the syslinux.efi uefi file to /tftboot/uefi
sudo cp /lib/SYSLINUX.EFİ/efi64/syslinux.efi /tftpboot/uefi
download the operating system live
sudo wget https://downloads.sourceforge.net/gparted/gparted-live-1.7.0-1-amd64.iso
mount the operating system to /mnt
sudo mount gparted-live-1.7.0-1-amd64.iso /mnt
Copy the three files necessary to start the operating system live to both uefi and bios
sudo mkdir /tftboot/bios/gparted
sudo cp /mnt/live/vmlinuz /tftpboot/bios/gparted
sudo cp /mnt/live/initrd.img /tftpboot/bios/gparted
sudo cp /mnt/live/filesystem.squashfs /tftpboot/bios/gparted
sudo mkdir /tftpboot/uefi/gparted
sudo cp /mnt/live/vmlinuz /tftpboot/uefi/gparted
sudo cp /mnt/live/initrd.img /tftpboot/uefi/gparted
sudo cp /mnt/live/filesystem.squashfs /tftpboot/uefi/gparted
Create directory named pxelinux.cfg
sudo mkdir /tftpboot/uefi/pxelinux.cfg
sudo mkdir /tftpboot/bios/pxelinux.cfg
Create and configure the file pxelinux.cfg/default for legacy
sudo nano /tftpboot/bios/pxelinux.cfg/default
configuration settings
Note:
1.) fetch=tftp://"your ip address">/uefi/gparted/filesystem.squashfs
Change ‘your ip address’
UI menu.c32 MENU TITLE PXE operating systemslabel GParted Live MENU LABEL GParted kernel /gparted/vmlinuz append initrd=/gparted/initrd.img boot=live config components union=overlay username=user keyboard-layouts=tr noswap noeject vga=788 fetch=tftp://192.168.2.2/bios/gparted/filesystem.squashfs
Create and configure the file pxelinux.cfg/default for uefi
sudo nano /tftpboot/uefi/pxelinux.cfg/default
configuration settings
Note:
1.) fetch=tftp://"your ip address">/uefi/gparted/filesystem.squashfs
Change ‘your ip address’
UI menu.c32 MENU TITLE PXE operating systemslabel GParted Live MENU LABEL GParted kernel /gparted/vmlinuz append initrd=/gparted/initrd.img boot=live config components union=overlay username=user keyboard-layouts=tr noswap noeject vga=788 fetch=tftp://192.168.2.2/uefi/gparted/filesystem.squashfs
Finally, the directories should look exactly like this!
/tftpboot ├── bios │ ├── pxelinux.0 │ ├── menu.c32 │ ├── libutil.c32 │ ├── ldlinux.c32 │ ├── pxelinux.cfg │ │ └── default │ └── Gparted │ ├── vmlinuz │ ├── initrd.img │ └── filesystem.squashfs ├── uefi │ ├── syslinux.efi │ ├── menu.c32 │ ├── libutil.c32 │ ├── ldlinux.e64 │ ├── pxelinux.cfg │ │ └── default │ └── Gparted │ ├── vmlinuz │ ├── initrd.img │ └── filesystem.squashfs
- 1
- 2