- Updated: January 4, 2026
- 6 min read
How to Set Up WireGuard VPN on FreeBSD Home NAS – Complete Guide
WireGuard VPN can be set up on a FreeBSD home NAS in just a handful of steps, giving you fast, lightweight, and cryptographically strong remote access between your office and home networks.
Why Choose WireGuard for Your FreeBSD NAS?
WireGuard is a modern VPN protocol that outperforms legacy solutions like OpenVPN in three core areas:
- Performance: Only ~4,000 lines of kernel code, delivering near‑native speeds.
- Security: Built‑in cryptography (Curve25519, ChaCha20, Poly1305) runs in kernel space, reducing attack surface.
- Simplicity: A single configuration file per peer makes deployment and troubleshooting painless.
For home NAS enthusiasts, this means you can protect your UBOS homepage‑hosted storage without sacrificing bandwidth, while still keeping a clean firewall footprint.
Step‑by‑Step WireGuard Configuration on FreeBSD
1. Install the WireGuard kernel module and tools
FreeBSD ships WireGuard as a loadable kernel module. Run the following commands as root:
pkg install wireguard-tools
kldload if_wg
sysrc wireguard_enable=YES
sysrc wireguard_interfaces=wg0
Enabling the module at boot ensures the VPN is always ready, a best practice for any Enterprise AI platform by UBOS that relies on continuous data sync.
2. Enable IP forwarding
WireGuard creates a virtual interface (wg0) that must forward traffic to your physical LAN (e.g., em0). Add these lines to /etc/rc.conf and apply them immediately:
sysrc gateway_enable=YES
sysctl net.inet.ip.forwarding=1
With IP forwarding active, the NAS can act as a router between the VPN subnet (10.8.0.0/24) and your home network (192.168.100.0/24).
3. Configure the PF firewall
FreeBSD’s Packet Filter (PF) protects the NAS while allowing VPN traffic. Below is a MECE‑styled PF snippet that you can paste into /etc/pf.conf:
# Interfaces
lan_if = "em0"
wg_if = "wg0"
# Networks
lan_net = "192.168.0.0/24"
home_net = "192.168.100.0/24"
wg_net = "10.8.0.0/24"
# Services
ssh_ports = "{ 22 }"
wg_port = "51820"
set skip on lo
block all
# SSH from LAN & Home
pass in on $lan_if proto tcp from $lan_net to (self) port $ssh_ports keep state
pass in on $lan_if proto tcp from $home_net to (self) port $ssh_ports keep state
# WireGuard handshake
pass in on $lan_if proto udp to (self) port $wg_port keep state
# VPN traffic
pass in on $wg_if from $wg_net to any keep state
pass out on $wg_if from any to $wg_net keep state
# Allow ICMP between LANs
pass in on $lan_if proto icmp from $lan_net to $home_net keep state
pass in on $lan_if proto icmp from $home_net to $lan_net keep state
After editing, reload PF with service pf reload. This configuration mirrors the security posture recommended in the UBOS portfolio examples for multi‑site deployments.
4. Generate cryptographic keys
Each peer needs a private/public key pair. Store the server keys in /usr/local/etc/wireguard:
cd /usr/local/etc/wireguard
wg genkey | tee server.key | wg pubkey > server.pub
chmod 600 server.key
For client devices (e.g., a laptop or a Raspberry Pi), repeat the process in a separate directory and keep the private key secure.
5. Create the server configuration file
Save the following as /usr/local/etc/wireguard/wg0.conf:
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = <SERVER_PRIVATE_KEY>
# Example client peer
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.8.0.2/32, 192.168.100.0/24
Replace placeholders with the actual keys generated earlier. The AllowedIPs line tells WireGuard which traffic to route to this peer – in this case, the client’s VPN address and the entire home LAN.
6. Start the WireGuard interface
Bring the tunnel up with:
wg-quick up wg0
Verify the interface:
ifconfig wg0
wg show
Both commands should display the 10.8.0.1 address and the peer you added.
7. Configure NAT and Dynamic DNS on the router
To reach the NAS from outside, forward UDP port 51820 (or a custom port) from your office router to the NAS’s LAN IP (e.g., 192.168.0.2). Most modern routers also support Dynamic DNS; set it up so the client can use a stable hostname instead of a changing public IP.
UBOS users often combine this with the UBOS templates for quick start to spin up a Dynamic DNS updater container that automatically syncs with services like NoIP.
8. Deploy client configurations
On a Linux laptop, create /etc/wireguard/wg0.conf:
[Interface]
Address = 10.8.0.2/24
PrivateKey = <CLIENT_PRIVATE_KEY>
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = your-ddns-hostname:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
Activate with wg-quick up wg0. The AllowedIPs = 0.0.0.0/0 line routes all traffic through the VPN – you can tighten it to only the office LAN (192.168.0.0/24) if you prefer.
Routing Between Office and Home LANs (Cross‑LAN Access)
Once the tunnel is up, you need static routes on both sides so each LAN knows how to reach the other.
Office side (FreeBSD NAS)
route add -net 192.168.100.0/24 10.8.0.2
This tells the NAS to forward any traffic destined for the home network to the VPN client.
Home side (Linux client)
sudo ip route add 192.168.0.0/24 via 10.8.0.1 dev wg0
Now the home laptop can reach office resources (e.g., a Samba share on the NAS) as if it were on the same subnet.
For devices that cannot run WireGuard directly (like a legacy printer), you can use the Workflow automation studio to create a lightweight proxy container that forwards traffic over the tunnel.
Extending the Setup with UBOS AI‑Powered Apps
With the VPN in place, your home NAS becomes a secure edge node for AI workloads. Here are a few ready‑made templates you can launch from the UBOS portfolio examples:
- AI SEO Analyzer – run SEO audits on remote sites without exposing them to the public internet.
- AI Article Copywriter – generate content directly on your NAS, keeping drafts private.
- AI Video Generator – process video assets locally, leveraging your NAS’s storage.
- AI Chatbot template – host a customer‑support bot that only your internal network can query.
- GPT‑Powered Telegram Bot – combine the Telegram integration on UBOS with OpenAI for secure notifications.
All these services benefit from the encrypted tunnel, ensuring that data never traverses the public internet unprotected.
Pricing, Support, and Next Steps
UBOS offers flexible plans that include UBOS pricing plans for hobbyists, startups, and enterprises. If you’re a small business, the UBOS solutions for SMBs give you a pre‑configured NAS + VPN bundle at a predictable monthly cost.
Need help with the initial setup? Join the UBOS partner program to get dedicated onboarding assistance and access to premium templates such as the AI YouTube Comment Analysis tool.
Conclusion – Secure, Fast, and Future‑Ready
By following the steps above, you transform a simple FreeBSD home NAS into a robust, WireGuard‑protected gateway that seamlessly connects your office and home networks. The lightweight nature of WireGuard keeps CPU usage low, while PF ensures granular traffic control. Coupled with UBOS’s AI‑ready ecosystem, you can now run data‑intensive workloads safely behind your own VPN.
Ready to get started? Explore the UBOS platform overview for a one‑click deployment of the NAS, then dive into the original WireGuard setup guide for deeper troubleshooting tips.
Take Action Now
- Deploy the Web app editor on UBOS to customize your VPN dashboard.
- Try the AI marketing agents to automate notifications about VPN status.
- Check out the UBOS for startups if you need a scalable solution for multiple remote offices.
Andrii Bidochko
CTO UBOS
Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.