How to Install Ubuntu Server 18.04 over a Network
This tutorial will show you how to create a PXE server and use it to install Ubuntu over a network. This is ideal if you want to install Ubuntu on a large number of computers at once.
In this guide, I will show you how to create a PXE server on Ubuntu 18.04 using Dnsmasq. The PXE server will hand out IP addresses using DHCP and will serve the Ubuntu netboot files over TFTP.
We will also configure a client to PXE boot and install Ubuntu over the network using the minimal amount of packages needed to start the system.
After installing Ubuntu on the client machine, any future packages will be downloaded from the internet.
Before we begin, you will need to install Ubuntu Server 18.04, configure it with a static IP and install Dnsmasq. You will also need a client machine with PXE boot enabled in the BIOS.
If you don’t have the physical hardware required to perform the steps below, you can use a desktop virtualization program such as VMware Workstation* or VMware Fusion* to follow along.
In this tutorial, I’m using a MacBook Pro with VMware Fusion 11.5* to run two virtual machines, one for the PXE server, and the other as the client, which will have Ubuntu installed over the network.
Step 1: Install and Configure Dnsmasq
In this tutorial, I will use the following network settings, but you’ll want to change them to suit your environment:
----------------------------------- PXE Server ----------------------------------- IP Address: 10.1.1.250 DHCP Range: 10.1.1.11 to 10.1.1.249 Gateway: 10.1.1.2 Domain: example.lab hostname: dnsmasq
Follow the steps in this tutorial. to install Dnsmasq on Ubuntu. Once finished, you should have a
dnsmasq.conf file that looks like the following:
# Global settings domain-needed bogus-priv no-resolv expand-hosts filterwin2k # Upstream nameservers server=184.108.40.206 server=220.127.116.11 # domain name domain=example.lab local=/example.lab/ listen-address=127.0.0.1 listen-address=10.1.1.250 # DHCP options dhcp-range=10.1.1.10,10.1.1.249,12h dhcp-lease-max=100 dhcp-option=option:router,10.1.1.2 dhcp-option=option:dns-server,10.1.1.250 dhcp-option=option:netmask,255.255.255.0
Modify the network settings in the file to suit your environment.
Step 2: Enable TFTP Server and Download Ubuntu Netboot files
Add the following options to the file to enable the TFTP server:
Download and extract the Ubuntu files to the tftp root directory by running the following commands:
cd /tmp wget http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/netboot.tar.gz sudo tar -xvzf netboot.tar.gz -C /srv/tftp/ sudo chown -R nobody:nogroup /srv/tftp/
Step 3: Configure the DHCP Server to send the name of the boot image
Add the following option to the
dnsmasq.conf file to send the name of the image to boot.
Determine the MAC address of your client machine that you want to install Ubuntu on.
If you’re following along using VMware Fusion, it can be found by clicking Settings, then on the Network Adapter and then Advanced Settings.
Now assuming your MAC address is
00:50:56:39:87:7A and you want to assign an IP address of
10.1.1.21, add the following to the
Save the changes and restart dnsmasq with the following command to apply the changes:
sudo systemctl restart dnsmasq
Step 4: Power on Client and Test
Power on your client machine and it should boot using PXE. The DHCP server will assign it the fixed IP address specified in the previous step and then the client will download the Ubuntu boot image from the TFTP server.
The following screenshots show this in action on a VMware Fusion virtual machine.
Now you can walk through the installation of Ubuntu as you would normally.
In this tutorial, we configured Dnsmasq on Ubuntu Server 18.04 to work as a DHCP, PXE and TFTP server. We setup a fixed IP for a client and tested booting the Ubuntu net installer over the network.
After installing Ubuntu over the network, future packages will be downloaded from the internet. Depending on how many machines you have on the network, you might want to change it so that all files are downloaded over the local network. Another thing you might want to do, is use a Kickstart file to fully automate the installation.
Written by Tony
I do stuff with computers, mainly virtualization. Contact me: firstname.lastname@example.org