The Domain Name System (DNS) is a core part of how networks operate. It translates human-readable domain names into logical IP addresses (and vice versa). Allowing computers and devices to locate and communicate with one another across a network or the internet.
This lab demonstrates how to configure a Raspberry Pi 5 as a DNS server using both DNSMasq and BIND9. Each implementation is documented step-by-step, including setup, configuration, and validation.
DNSMasq is a lightweight DNS forwarder and DHCP server suitable for small environments. It's efficient, simple to configure, and ideal for local caching.
1. Begin with updating software packages on Raspberry Pi with apt package manager.

2. Install the DNSMasq DNS software on the Raspberry Pi with apt package manager.

3. Configure DNSMasq:

Here in the nano text editor, use CTRL + W to search and locate the following lines by removing the hash sign (#).

#domain-needed



#bogus-priv



#no-resolve


#server=/local/192.168.0.1


#cache-size=150


4. Restart the dnsmasq service and verify the status.

5. Configure Windows 11 Lab-Client with Raspberry Pi IP address as Preferred DNS Server.

6. Run nslookup command to test out DNS server functionality with DNSMasq running on the Raspberry Pi.

After configuration, the Raspberry Pi successfully caches DNS queries and forwards requests to Cloudflare's 1.1.1.1 and 1.0.0.1 servers.
From here, the Raspberry Pi IP address can be added as the DNS server IP on other devices.
BIND9 is a robust DNS server supporting authoritative and recursive resolution. This setup transforms the Raspberry Pi 5 into a local DNS authority for home.lan while forwarding external lookups to Cloudflare.
To begin, the Raspberry Pi needs to be configured with a Static IP address. In order to do that, we need to systematically identify how networking is managed on the given Raspberry Pi OS.
Setting this up will ensure the Raspberry Pi retains the same IP address after rebooting, enabling reliable DNS, SSH, and other network services.
1. Identify the OS Version
Learn which networking framework the OS uses.
Here we see the OS Version Raspberry Pi OS Bookworm. This means the OS Version uses NetworkManager as the networking framework.

2. Verify Which Network Service Is Active
Confirm that NetworkManager is indeed running and controlling interfaces.
If it wasn't active, the configuration file /etc/dhcpcd.conf would be modified instead.
This prevents misconfigurations caused by editing the wrong files.

3. List Active Network Connections
Discover the connection profile (e.g., "Wired Connection 1" or "WLAN connection 1").
You must know this name before modifying or applying static IP settings.
4. Check Current Network Interface and IP
To confirm which interface (e.g., eth0, wlan0) is active and what IP/subnet the Pi currently uses.
This ensures your static IP stays in the same valid range and avoids conflicts.
In this example, I'm only using the command hostname -I, in other cases running ip a would be necessary.

5. Inspect Connection Settings
Verify whether the current IPv4 method is auto (DHCP).
You need to switch it to manual before applying a static address.
This step validates your assumptions before changing configuration.

6. Apply Static IP Configuration
To explicitly define:
This makes the Pi use a fixed IP address that won't change after reboots - critical for consistent DNS, SSH, or web service operations.

7. Verify Connectivity and Persistence
Confirm that the Pi is reachable at its new static IP and still has internet access through the gateway.
This validation ensures that the configuration was applied correctly and is functioning as expected.

Here at the bottom we see valid_lft forever preferred_lft forever indicating that this is a static IP configuration.

Re-verify that the current Ipv4 method ipv4.method is set to manual.

Verify connectivity:

1. Installing BIND9
Now that the Raspberry Pi is configured with a Static IP address, we can install BIND.
In this example, I'm installing the program bind9 and bind9utils.
The bind9utils is not required, but does contain some useful tools for managing the DNS server.

Here, I'm setting up a forward lookup and reverse lookup zone.


2. Specify Configuration Settings
The zones are specified in the /etc/bind/named.conf.local file.
With the zones set in the configuration file, the individual zone files need to be created like so.
Forward Lookup Zone:


Reverse Lookup Zone:


Options:

Here, I'm going to set the Forwarders to two of Cloudflare's DNS servers.
With a DNS server now setup on the Raspberry Pi, the Raspberry Pi device now functions as a cache of DNS queries. As soon as the device queries a successful name resolution, that entry remains saved on the Raspberry Pi DNS server.
In this setup the DNS queries are still being forwarded to another DNS server.
The DNS server IP can be modified in the /etc/bind/named.conf.options by opening the file and changing the IP address in the Forwarders entry.


3. Restart bind9 service & verify functionality
And this is how you setup a DNS server with BIND on a Raspberry Pi 5.
For the configuration changes to take effect, restart bind9 like so after verifying the configuration.


Verification:

The BIND9 configuration includes both forward and reverse zone definitions, along with Cloudflare's DNS for external resolution. Successful testing with dig confirms the DNS server's proper function.
Both DNS implementations demonstrate how the Raspberry Pi 5 can serve as a powerful and flexible DNS solution for lab or production networks.
This project demonstrates local name resolution, forward and reverse zone management, and verification using dig and systemctl. The lab also reinforces the importance of DNS in network infrastructure and the versatility of the Raspberry Pi 5.