PXE Server PXE Client
(Container) (VM)
192.0.0.2 192.0.0.1XX
br0 eth1
+ +
+--------------------+
host$ git clone https://github.com/thachmpham/lab.git
host$ cd lab/pxe/use/setup-02host$ docker compose build
host$ docker compose up
host$ docker exec -it pxe bashThe DHCP server automatically start together the container startup.
container$ ps ax
PID TTY STAT TIME COMMAND
46 ? Ss 0:00 /usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf br0Listening at port 67.
container$ lsof -P -i -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dhcpd 46 root 8u IPv4 9300 0t0 UDP *:67Show DHCP configuration.
container$ cat /etc/dhcp/dhcpd.conf
# ---------------------------------------- #
allow booting;
allow bootp;
subnet 192.0.0.0 netmask 255.255.255.0 {
range 192.0.0.100 192.0.0.150; # range for client address
option broadcast-address 192.0.0.255;
next-server 192.0.0.2; # where is boot file
option subnet-mask 255.255.255.0;
filename "/pxelinux.0"; # boot file
}
# ---------------------------------------- #pxe$ cat /etc/default/isc-dhcp-server
# ---------------------------------------- #
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="br0"
# ---------------------------------------- #The TFTP server automatically start together the container startup.
pxe$ ps ax | grep -P 'dhcp|tftp'
PID TTY STAT TIME COMMAND
59 ? Ss 0:00 /usr/sbin/atftpd --daemon --port 69 --verbose=7 /srv/tftpListening at port 69.
pxe$ lsof -P -i -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
atftpd 59 nobody 0u IPv6 8401 0t0 UDP *:69Show TFTP configuration.
container$ cat /etc/default/atftpd
# ---------------------------------------- #
OPTIONS="--port 69 --verbose=7 /srv/tftp"
# ---------------------------------------- #TFTP server hosts the boot directory (/srv/tftp).
container$ tree /srv/tftp
.
|-- ldlinux.c32 # control module: display menu.
|-- pxelinux.0 # bootloader binary: start boot process in client.
|-- pxelinux.cfg # boot menu.
|-- ubuntu-installer
| `-- amd64
| |-- boot-screens
| | |-- txt.cfg # menu when in text graphics.
| |-- initrd.gz # ramdisk, tools to load filesystem.
| |-- linux # kernel.container$ cat /srv/tftp/ubuntu-installer/amd64/boot-screens/txt.cfg
# ---------------------------------------- #
default install
label install
menu label ^Install
menu default
kernel ubuntu-installer/amd64/linux
append vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- console=ttyS0,19200 earlyprint=serial,ttyS0,19200
label cli
menu label ^Command-line install
kernel ubuntu-installer/amd64/linux
append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- console=ttyS0,19200 earlyprint=serial,ttyS0,19200
# ---------------------------------------- #Start VM, boot from network.
container$ ./start_vm.sh