A network-services lab: DHCP, DNS, proxy, load balancer, time and failover

Build a small private network of virtual machines and run the real services from the Network Services and Linux in Production courses, so you can test them with real commands.

  • Time: 1 to 2 hours
  • Cost: free software, your own computer

What you need

The service labs in the lessons check a configuration file. A real service also has to start, listen and answer, and the best way to learn that is to run it. You need three roles, which can be separate VMs or fewer VMs doing several jobs:

  • server: runs the services you are practising (DHCP, DNS, time, a web server).
  • client: a plain Ubuntu (or Windows) machine that asks the server for things.
  • second node (optional): a second server for failover (keepalived) or a second web server behind a load balancer.

Set it up

  1. Build one Ubuntu Server VM, update it, then clone it to make the others (see the virtual machine lab guide).
  2. Give every VM two network adapters: NAT for downloading packages, and one internal network named lab for the practice network.
  3. On the internal adapter, set fixed addresses in one private range. For example, with Netplan on Ubuntu (/etc/netplan/60-lab.yaml) give the server 10.10.10.2/24, and leave the client’s adapter unconfigured so DHCP can configure it. Apply with sudo netplan apply.
  4. Install the service you are practising only on the machine that needs it:
sudo apt install -y isc-dhcp-server      # DHCP (or: dnsmasq)
sudo apt install -y unbound              # DNS resolver
sudo apt install -y squid                # forward proxy
sudo apt install -y haproxy              # load balancer
sudo apt install -y keepalived           # failover (VRRP)
sudo apt install -y chrony               # time server
sudo apt install -y nginx bind9          # web server, authoritative DNS
  1. Put your configuration in place (the lessons’ model answers are a good start), then test the file before restarting: sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf, sudo haproxy -c -f /etc/haproxy/haproxy.cfg, sudo squid -k parse, sudo unbound-checkconf, sudo nginx -t, sudo keepalived -t -f /etc/keepalived/keepalived.conf. Then sudo systemctl restart <service>.

Check that it works

Check each service from the client, not from the server:

  • DHCP: sudo dhclient -v (or restart networking) shows an offer and a lease from your server; ip -br addr shows the address from your pool.
  • DNS: dig @10.10.10.2 files.lab.example +short returns your internal address; the same query from outside the allowed network is refused.
  • Proxy: curl -x http://10.10.10.2:3128 -I http://example.com works; a blocked site returns 403.
  • Load balancer: repeated curl http://10.10.10.2/ shows both web servers answering; stop one and the other keeps answering.
  • Time: chronyc tracking on the client shows a small offset from your server.
  • Failover: ip -br addr shows the shared address on one node; stop the service and it moves.

Practise safely

  • Keep the lab network internal. Never run a DHCP server on a bridged adapter: it will answer other devices on your real network and can knock them offline.
  • Snapshot the clean clone before each service so you can return to it.
  • Read logs rather than guessing: sudo journalctl -u <service> -f while a client connects.
  • Keep services bound to the lab address; do not expose a lab resolver or time server to the internet.

Go further

  • Break each service on purpose: a wrong netmask in DHCP, a deny placed after the allow in Squid, a mismatched virtual router id in keepalived. Find each fault in the logs.
  • Capture the DHCP exchange on the client with sudo tcpdump -i <interface> -n port 67 or port 68 and read Discover, Offer, Request, ACK (see the Wireshark lab guide).
  • Add a second DHCP server on purpose, on the lab network only, and watch the clients take the first offer; then fix it.
  • Automate the build with a shell script, then rebuild the lab from clean clones and time it.

Courses that use this lab

Other lab guides

Software changes quickly. Menu names and version numbers may differ a little from what you see; the ideas and the check at the end of each section stay the same. Always download from the project's own website, and read the licence terms for your situation.