Setting up a netboot server is surprisingly easy, but I have not found comprehensive guides.
What you really need:
- DHCP Server, from which your client receives an IP-Address and the Address to a tftp server
- TFTP Server, where a bootloader and one or more images are located
TFTP Server
- install a tftp server package with support for xinet (that is the normal one)
- xinetd is a daemon, which listens on specified ports and pipes the traffic to a program one can specify in config. In this case we want a tftp config file, where you can also specify a root path for your tftp server:
12345678910111213service tftp{socket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/in.tftpdserver_args = -s /home/max/kolibrios/netboot/disable = noper_source = 11cps = 100 2flags = IPv4}
Notice: If you are using SELinux and want to use a directory in a users home directory (like in that example), you will have to tell SELinux about it:
1setsebool -P tftp_home_dir 1
DHCP Server
- the installation package is most likely called dhcp or dhcp-server or dhcpd. It will not preinstalled in most cases as normal users do not need it.
- the most important part in our dhcpd.conf-file is the subnet part. It acts like a filter and will only become active for interfaces, which are in the ip range (starting with
192.168.178.0
in the following example).
123456789101112131415161718allow booting;allow bootp;option space PXE;option PXE.mtftp-ip code 1 = ip-address;option PXE.mtftp-cport code 2 = unsigned integer 16;option PXE.mtftp-sport code 3 = unsigned integer 16;option PXE.mtftp-tmout code 4 = unsigned integer 8;option PXE.mtftp-delay code 5 = unsigned integer 8;option arch code 93 = unsigned integer 16; # RFC4578subnet 192.168.178.0 netmask 255.255.255.0{option routers 192.168.178.1;range 192.168.178.60 192.168.178.100;next-server 192.168.178.26;filename "pxelinux.0";}
filename “pxelinux.0” loads a bootloader from the syslinux project (think of it as a network grub if you like). This file must be accessible through your previously configured tftp server.
starting the dhcp server
After you have modified the addresses and saved the configuration file you can start the dhcpd-daemon:
1 2 |
systemctl start dhcpd tail -n60 /var/log/messages # shows you either DHCP [...] listing [...] or DHCP [...] error [...] |
Firewall
Do not forget to open the firewall ports for DHCP Server (UDP 67,68) and TFTP Server (UDP 69)!
Getting something running…
Put files from the syslinux project in your tftp-root-directy, namely:
- /usr/share/syslinux/vesamenu.c32
- /usr/share/syslinux/memdisk
- KolibriOS – used for testing because it is so damn small 🙂
- create a path in your TFTP root path, called pxelinux.cfg
- create a file inside pxelinux.cfg/ called default (without extension) and insert:
123456789101112UI vesamenu.c32LABEL kolibri.isoLINUX memdiskINITRD kolibri.isoAPPEND isoLABEL kolibri.imgLINUX memdiskINITRD kolibri.imgAPPEND raw - Now start your network machine!
Troubleshooting
You can run qemu in order to test whether or not your tftp folder is correctly set up:
1 |
qemu-kvm -boot n -net user,tftp=/path/to/tftp,bootfile=/pxelinux.0 |