| 1 |
.. _network-boot-server: |
| 2 |
|
| 3 |
Setting Up a Network Boot Server |
| 4 |
================================ |
| 5 |
|
| 6 |
.. sidebar:: Abstract |
| 7 |
|
| 8 |
This page provides general information on how to set up |
| 9 |
a network boot server that provides all services |
| 10 |
needed for the PXE boot protocol. |
| 11 |
|
| 12 |
To be able to deploy a system through the PXE boot protocol, you need |
| 13 |
to set up a network boot server providing the services DHCP and TFTP. |
| 14 |
With `dnsmasq`, a utility exists that allows you to set up all needed |
| 15 |
services at once: |
| 16 |
|
| 17 |
Installing and Configuring DHCP and TFTP with dnsmasq |
| 18 |
----------------------------------------------------- |
| 19 |
|
| 20 |
The following instructions can only serve as an example. Depending on your |
| 21 |
network structure, the IP addresses, ranges, and domain settings need to |
| 22 |
be adapted to allow the DHCP server to work within your network. If you |
| 23 |
already have a DHCP server running in your network, make sure that the |
| 24 |
`filename` and `next-server` directives are correctly set on this server. |
| 25 |
|
| 26 |
The following steps describe how to set up dnsmasq to work as |
| 27 |
DHCP and TFTP server. |
| 28 |
|
| 29 |
1. Install the `dnsmasq` package. |
| 30 |
|
| 31 |
2. Create the file :file:`/etc/dnsmasq.conf` and insert the following content: |
| 32 |
|
| 33 |
.. code:: bash |
| 34 |
|
| 35 |
# Do not function as a DNS server. |
| 36 |
port=0 |
| 37 |
|
| 38 |
# Log information about DHCP transactions. |
| 39 |
log-dhcp |
| 40 |
|
| 41 |
# Set the root directory for files available via TFTP, |
| 42 |
# usually "/srv/tftpboot": |
| 43 |
tftp-root=TFTP_ROOT_DIR |
| 44 |
|
| 45 |
enable-tftp |
| 46 |
|
| 47 |
dhcp-range=BOOT_SERVER_IP,proxy |
| 48 |
|
| 49 |
In the next step, it's required to decide on the boot method. There |
| 50 |
is the PXE loader provided via `pxelinux.0` from the `syslinux` package, |
| 51 |
and there is the GRUB loader provided via the `grub` package. |
| 52 |
|
| 53 |
.. note:: Placeholders |
| 54 |
|
| 55 |
Replace all placeholders (written in uppercase) with data fitting |
| 56 |
your network setup. |
| 57 |
|
| 58 |
|
| 59 |
2.1. insert the following content to use `pxelinux.0`: |
| 60 |
|
| 61 |
.. code:: bash |
| 62 |
|
| 63 |
# The boot filename, server name, and server IP address |
| 64 |
dhcp-boot=pxelinux.0,,BOOT_SERVER_IP |
| 65 |
|
| 66 |
# Disable re-use of the DHCP servername and filename fields as extra |
| 67 |
# option space. This is to avoid confusing some old or broken |
| 68 |
# DHCP clients. |
| 69 |
dhcp-no-override |
| 70 |
|
| 71 |
# PXE menu. The first part is the text displayed to the user. |
| 72 |
# The second is the timeout, in seconds. |
| 73 |
pxe-prompt="Booting FOG Client", 1 |
| 74 |
|
| 75 |
# The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86, |
| 76 |
# Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI |
| 77 |
# This option is first and will be the default if there is no input |
| 78 |
# from the user. |
| 79 |
pxe-service=X86PC, "Boot to FOG", pxelinux.0 |
| 80 |
pxe-service=X86-64_EFI, "Boot to FOG UEFI", ipxe |
| 81 |
pxe-service=BC_EFI, "Boot to FOG UEFI PXE-BC", ipxe |
| 82 |
|
| 83 |
.. note:: |
| 84 |
|
| 85 |
On boot of a network client with that configuration, the default |
| 86 |
`pxelinux.0` config file is expected at |
| 87 |
:file:`TFTP_ROOT_DIR/pxelinux.cfg/default` |
| 88 |
|
| 89 |
2.2. insert the following content to use GRUB: |
| 90 |
|
| 91 |
.. code:: bash |
| 92 |
|
| 93 |
# The boot filename, server name, and server IP address |
| 94 |
dhcp-boot=boot/grub2/i386-pc/core.0,,BOOT_SERVER_IP |
| 95 |
|
| 96 |
When using GRUB, the referenced `dhcp-boot` GRUB module must be generated. |
| 97 |
To do this, change the directory to :file:`TFTP_ROOT_DIR` and create |
| 98 |
the :file:`setvars.conf` file with the following content: |
| 99 |
|
| 100 |
.. code:: bash |
| 101 |
|
| 102 |
set root=(tftp) |
| 103 |
set net_default_server=BOOT_SERVER_IP |
| 104 |
set prefix=boot/grub2 |
| 105 |
|
| 106 |
Now, call the following commands to create the GRUB module: |
| 107 |
|
| 108 |
.. code:: bash |
| 109 |
|
| 110 |
$ grub2-mknetdir --net-directory=TFTP_ROOT_DIR --subdir=boot/grub2 |
| 111 |
$ grub2-mkimage -O i386-pc-pxe \ |
| 112 |
--output boot/grub2/i386-pc/core.0 \ |
| 113 |
--prefix=/boot/grub2 \ |
| 114 |
-c setvars.conf \ |
| 115 |
pxe tftp |
| 116 |
|
| 117 |
.. note:: |
| 118 |
|
| 119 |
On boot of a network client with that configuration, the GRUB |
| 120 |
config file is expected at :file:`TFTP_ROOT_DIR/boot/grub2/grub.cfg` |
| 121 |
|
| 122 |
3. Run the dnsmasq server by calling: |
| 123 |
|
| 124 |
.. code:: bash |
| 125 |
|
| 126 |
systemctl start dnsmasq |