NETWORK SECURITY • RASPBERRY PI

Pi-hole, Unbound & WireGuard VPN

A Raspberry Pi-based network security platform providing DNS filtering, recursive DNS resolution, encrypted remote access, and centralized control of home-network DNS traffic.

Raspberry Pi Linux Pi-hole Unbound WireGuard DNS Security

PROJECT OVERVIEW

Secure DNS and Remote Access

This project transformed a Raspberry Pi into a centralized network-security and remote-access platform for a home network.

Pi-hole was installed to block advertising, tracking, and unwanted domains at the DNS level. Unbound was then added as a local recursive DNS resolver, reducing dependence on public DNS providers.

WireGuard VPN was configured through PiVPN to provide encrypted remote access to the home network. This made it possible to use Pi-hole filtering while away from home and securely access internal services.

OBJECTIVES

Project Goals

DNS Filtering

Block advertising, tracking, malicious domains, and unwanted content across the network.

Recursive DNS

Use Unbound to resolve DNS requests directly rather than relying only on third-party DNS providers.

Encrypted Access

Securely access the home network from mobile devices using WireGuard VPN.

Network Visibility

Monitor DNS requests, blocked domains, active clients, and network behavior from one dashboard.

SYSTEM ARCHITECTURE

How the System Works

Client Devices

Phones, computers, tablets, smart TVs, and other devices.

Pi-hole

Filters DNS requests using blocklists and custom rules.

Unbound

Performs recursive DNS resolution.

Internet DNS

Root, top-level-domain, and authoritative DNS servers.

Remote VPN Access

A remote phone, tablet, or laptop connects through WireGuard. VPN traffic enters the Raspberry Pi, receives Pi-hole DNS filtering, and can securely access permitted home-network resources.

COMPONENTS

Hardware and Software

HARDWARE

Raspberry Pi

  • Raspberry Pi 3 B+
  • MicroSD card
  • Ethernet connection
  • Stable power supply
  • Home router
SOFTWARE

Network Services

  • Raspberry Pi OS
  • Pi-hole
  • Unbound
  • PiVPN
  • WireGuard
ADMINISTRATION

Management Tools

  • SSH
  • Pi-hole web dashboard
  • Router administration
  • WireGuard mobile application
  • Linux command line

BUILD PROCESS

Installation and Configuration

1

Prepare the Raspberry Pi

Installed Raspberry Pi OS, completed system updates, enabled SSH, and connected the Pi to the router using Ethernet.

sudo apt update
sudo apt full-upgrade -y
sudo reboot
2

Assign a Stable Network Address

Configured the router to reserve a consistent local IP address for the Raspberry Pi. This prevents DNS clients from losing access after a DHCP address change.

3

Install Pi-hole

Installed Pi-hole and configured the Raspberry Pi as the primary DNS server for the network.

curl -sSL https://install.pi-hole.net | bash
4

Configure Router DNS

Updated the router's LAN DNS settings so client devices use Pi-hole for DNS requests.

Private addresses and public IP information are intentionally omitted from public documentation.

5

Install Unbound

Installed Unbound and configured it as a local recursive DNS resolver.

sudo apt install unbound -y

Pi-hole was then configured to forward permitted DNS requests to the local Unbound service.

6

Install PiVPN and WireGuard

Installed PiVPN, selected WireGuard, created VPN clients, and imported client configurations into mobile devices.

curl -L https://install.pivpn.io | bash
7

Configure Remote Connectivity

Configured router port forwarding and dynamic DNS to support remote WireGuard connections when the public IP address changes.

8

Test and Validate

Verified DNS filtering, recursive resolution, VPN handshakes, remote internet access, and access to approved internal services.

TROUBLESHOOTING

Problems Encountered and Solutions

WireGuard Had No Handshake

The VPN client initially failed to establish a connection.

Checks Performed

  • Verified WireGuard was listening.
  • Confirmed the configured UDP port.
  • Checked router port forwarding.
  • Verified the correct remote endpoint.
  • Reviewed firewall and NAT settings.

VPN Connected but No Internet

A successful handshake did not always result in working internet access.

Resolution Process

  • Checked DNS settings in the client profile.
  • Verified IP forwarding.
  • Reviewed NAT and masquerade rules.
  • Confirmed Pi-hole was listening for VPN clients.
  • Tested DNS and IP connectivity separately.

Unbound Root Hints Permissions

Unbound encountered a permissions issue while accessing root-hints information.

Resolution Process

  • Verified file ownership and permissions.
  • Confirmed the configured root-hints path.
  • Restarted and checked Unbound status.
  • Used DNS queries to validate recursive resolution.

Dynamic DNS Update Script

The dynamic DNS update script initially returned a permissions error.

Resolution Process

  • Made the update script executable.
  • Ran the script manually.
  • Confirmed the update log returned success.
  • Scheduled regular updates.

VALIDATION

Testing and Verification

Test Purpose Result
Pi-hole Dashboard Confirm client DNS requests are visible. Passed
Blocked Domain Test Verify Pi-hole blocks listed domains. Passed
Unbound Resolution Confirm recursive DNS queries work. Passed
WireGuard Handshake Verify encrypted remote connection. Passed
Remote DNS Filtering Confirm VPN clients use Pi-hole. Passed
Remote Internet Access Confirm VPN clients can reach the internet. Passed

SECURITY

Security Considerations

Minimal Exposure

Only the required VPN port should be exposed through the router.

Key Protection

WireGuard private keys and client configuration files should never be published.

Regular Updates

The operating system and installed services should be patched regularly.

Backup Configuration

Pi-hole configuration, blocklists, and important service files should be backed up.

Public Documentation

Public IP addresses, private network ranges, keys, passwords, and QR codes are excluded from this page.

Network Segmentation

IoT and guest devices should be isolated where router capabilities permit.

LESSONS LEARNED

Key Takeaways

This project strengthened my understanding of DNS, routing, Linux services, VPN configuration, network address translation, firewall behavior, and structured troubleshooting.

One of the most important lessons was that a successful VPN handshake does not automatically mean the entire connection is working. DNS resolution, packet forwarding, NAT, firewall rules, and routing must all work together.

Troubleshooting was most effective when each layer was tested separately:

  • Physical and local network connectivity
  • Service status
  • Listening ports
  • DNS resolution
  • VPN handshake
  • Packet forwarding
  • Internet connectivity

The project also demonstrated the value of documentation, consistent file permissions, backups, and controlled configuration changes.

SKILLS DEVELOPED

Technical Capabilities

Linux Administration

Package management, services, permissions, logs, and command-line troubleshooting.

Networking

DNS, DHCP reservations, routing, NAT, port forwarding, and private addressing.

VPN Configuration

WireGuard clients, keys, endpoints, tunnels, and remote access testing.

Troubleshooting

Service verification, packet-level testing, logs, and evidence-based diagnosis.

FUTURE IMPROVEMENTS

Next Development Steps

Improved Network Segmentation

Separate trusted devices, IoT equipment, guests, and lab systems into controlled network groups.

Monitoring and Alerts

Add service-health monitoring and notifications for DNS or VPN failures.

Automated Backups

Back up important Pi-hole, Unbound, WireGuard, and system configuration files.

Expanded Analytics

Add dashboards for system performance, DNS behavior, and service availability.

PROJECT RESOURCES

Explore the Project

Documentation and supporting resources will be expanded as the project develops.