Previously we created a VM with installed OpenMediaVault 2.1. It is accessible via SSH and via web-gui. Now we will create a DHCP & TFTP server from it. Let’s start it.
Add network adapter to existing VM & setup network:
In first post you saw on schematic diagram that our Media Server had 2 ethernet interface. Now we will create it in our virtual environment:
Create host-only network in VirutalBox:
Create second ethernet interface for our VM:
Setup second ethernet interface on OS:
– Reboot (init 6) is necessary after adding lines to configuration-file.
For reference you can check my “interfaces” configuration file here:
Create PXE-test VM:
To test our dhcp & tftp server we will need a VM which will try to connect our previously connected, host-only network. As in future we will test windows PE image also, system-resources will adjust to make this possible. Please follow pictures:
– Memory: If you will load some kind of diagnostic ISO, you need at least 2 x iso-image size + ~30% of iso-image size installed memory (ISO=400MB –> ~920MB of installed memory). If loaded ISO load application / OS which runs from memory, it is possible that you will need more than calculated memory.
Now we can leave in powered off state this VM, we will use it soon.
Install DHCP-server application:
In short about DHCP: This technology provide automatically an ip-address for connected devices on network. In everyday we saw it when connect to our router. Just to clarify: in our router also a DHCP-server application runs (minimal, targeted dhcp-server)!
Install “isc-dhcp-server”, our DHCP-server application:
– Install it: sudo apt-get install isc-dhcp-server
– Declare where (which Ethernet interface) it will be listening: sudo nano /etc/default/isc-dhcp-server
By default it will be listening on all interface. In our case it is not as good, as on ETH0 our real network’s router also offer ip-address. +1 that absolutely un-needed to listen interface where we will not use PXE-boot mechanism.
For reference you can check my /etc/default/isc-dhcp-server configuration file here:
– Edit main-configuration file of isc-dhcp-server: sudo nano /etc/dhcp/dhcpd.conf
For reference you can check my /etc/dhcp/dhcpd.conf configuration file here:
– Start our configured dhcp-server: sudo /etc/init.d/isc-dhcp-server start
Now we have a configured, working DHCP-server which will provide ip-addresses for our PXE-boot clients. In case of your isc-dhcp-server couldn’t be started:
– Check /etc/default/isc-dhcp-server file for syntax-error / miss-configuration.
– Check /etc/dhcp/dhcpd.conf file for syntax-error / miss-configuration.
– Check /var/log/syslog file for messages from isc-dhcp. You can use the following command to check what is the problem when try to start isc-dhcp: sudo /etc/init.d/isc-dhcp-server start; tail -f /var/log/syslog
Test our new Software DHCP-server:
– Make sure, our “Media&PXE” VM is running. If yes, start to inspect dhcp log entrys: tail -f /var/log/syslog
– Start “PXE-test” VM which try to boot from network. You need to get the following:
Now our dhcp-servers is working, it is redirect “PXE-test” VM to boot “grldr” file from FTP-server just until now we don’t have grldr file. So this response is expected.
Install TFTP-server application:
As we used OMV21 as source of our media & pxe-boot server, tftp software was installed by default. But if you need to install it, use the following command:
sudo apt-get install tftpd-hpa tftp-hpa
Please don’t left to add tftp-server as auto start application in case of server-reboot, with the following command:
update-rc.d tftpd-hpa enable
Configure TFTP-server: Configuration file is “/etc/default/tftpd-hpa”. Here is my configuration with short explanation.
– I adjusted the “TFTP_ADDRESS” & “TFTP_OPTIONS” to our needs. Address was adjusted to our ETH1 (this is used for PXE-network) address. For options I added logging-option to make tftp-server visible on “/var/log/syslog”. After you adjust your configuration file like my config-file, please restart tftp server: /etc/init.d/tftp-hpa restart
If you restart / start your PXE-test VM, you will get log-entry on your “media&pxe” VM:
You can see that requested file was not found (on /srv/tftp folder). So fix this problem, download missing (grub4dos) file with the following commands:
After these commands, your tftp-server’s folder must to be look like:
Test TFTP-server: Now we have DHCP server, TFTP-server, and file which can be booted by pxe-client. Let’s test it:
Start / restart PXE-test VM.
On VM-side you must to get the following:
On server-side (Media&PXE vm) /var/log/syslog entry while pxe-client VM boot:
Finalize settings, create missing files for complete boot: Now our PXE-client get IP-address from our dhcp-server and boot file served by our tftp-server, but just a minimal-BASH available at the moment. Now we will create a missing “menu.lst” file what will be interpreted by grub4dos (grldr) and give choosable options fror user on pxe-client. We will also test it with bootable tool (memtest).
– Download memtest image file & prepare it.
– Create & adjust “menu.lst”. Please create menu.lst (touch /srv/tftp/menu.lst) & fill up with the following content:
Now our tftp (& dhcp) server is working fine, we can boot image(s) with grub4dos. If everything is working fine, with “PXE-test” VM you will get similar like this:
For this post, I used grub4dos as my boot manager, but not this is the only available tool for multi / pxe boot, you can use also syslinux. You just replace “grldr” file with yours (in dhcp-server configuration & physically).
On next post, we will create a winPE environment and append it to the our actual grub4dos menu.
If you faced with problem or you found a bug on post please let me know, leave a comment.