· 9 min read
Site-to-Site VPNs with WireGuard and pfSense: A Practical Guide
- Security
- Networking
- WireGuard
- pfSense
- AWS
When you need a site-to-site VPN#
A site-to-site VPN joins two networks so that machines on either side can talk as if they were on one private network. Typical cases:
- On-premise devices (for example IP cameras streaming RTSP) that a cloud service must reach without exposing them to the internet
- A lab or office network that needs private access to services inside a cloud VPC
- Two cloud environments in different providers or regions
I have configured site-to-site VPNs in production and built RTSP camera-streaming pipelines, which is where these two topics usually meet. This guide uses WireGuard on pfSense at the remote site and a Linux WireGuard gateway inside an AWS VPC, but the principles carry over to any pair of endpoints.
Why WireGuard#
- Small and auditable: a few thousand lines of code instead of the large codebases of older VPN stacks.
- Modern cryptography by default: no cipher negotiation to misconfigure.
- Fast reconnects: roaming and NAT changes are handled gracefully.
- Simple model: every peer is a public key plus the IP ranges it is allowed to use.
Step 1: plan the addressing#
Overlapping subnets are the number-one cause of broken site-to-site VPNs. Decide the ranges first:
| Network | CIDR |
|---|---|
| Remote site LAN (behind pfSense) | 192.168.50.0/24 |
| AWS VPC | 10.0.0.0/16 |
| Tunnel network | 10.99.0.0/30 |
The tunnel network is a tiny point-to-point range used only for the two WireGuard interfaces.
Step 2: the cloud gateway#
Inside the VPC, a small Linux instance in a public subnet acts as the gateway. Two AWS settings are easy to forget:
- Disable source/destination check on the instance, otherwise AWS drops traffic it forwards.
- Add a route in the private subnets' route table:
192.168.50.0/24→ the gateway instance.
WireGuard config on the gateway (/etc/wireguard/wg0.conf):
[Interface]
Address = 10.99.0.1/30
ListenPort = 51820
PrivateKey = <gateway-private-key>
PostUp = sysctl -w net.ipv4.ip_forward=1
[Peer]
# pfSense at the remote site
PublicKey = <pfsense-public-key>
AllowedIPs = 10.99.0.2/32, 192.168.50.0/24
The security group only needs UDP 51820, and ideally only from the remote site's public IP.
Step 3: pfSense at the remote site#
On pfSense (with the WireGuard package installed):
- VPN → WireGuard → Tunnels: create a tunnel, generate keys, listen port 51820.
- Peers: add the cloud gateway with its public key, endpoint
<elastic-ip>:51820, keepalive 25 seconds, and allowed IPs10.99.0.1/32, 10.0.0.0/16. - Interfaces → Assignments: assign the WireGuard tunnel as an interface, give it
10.99.0.2/30, and enable it. - System → Routing: add a gateway at
10.99.0.1on that interface and a static route for10.0.0.0/16through it.
The persistent keepalive matters when pfSense sits behind NAT: it keeps the mapping open so the cloud side can always reach it.
Step 4: firewall rules (least privilege)#
A tunnel that is up is not the same as a tunnel that is safe. Allow only what the use case needs.
On the pfSense WireGuard interface, for a camera use case:
| Action | Source | Destination | Port |
|---|---|---|---|
| Pass | 10.0.0.0/16 (streaming service subnet only) |
camera VLAN | TCP/UDP 554 (RTSP) |
| Block | any | any | any |
On AWS, the security groups of the services should accept traffic from 192.168.50.0/24 only on the ports they serve. Never open the whole VPC to the remote site "temporarily".
Step 5: verify and monitor#
# On the gateway: is the handshake recent? Are bytes flowing?
sudo wg show
# Path check from the cloud side
ping -c3 192.168.50.10
# Can the service reach the camera stream?
ffprobe rtsp://192.168.50.10:554/stream1
A handshake older than a few minutes means the tunnel is down. Exporting wg show data to your monitoring and alerting on handshake age catches outages before users do.
Hardening checklist#
- Restrict the listening port to known peer IPs wherever possible.
- Rotate keys when people with access leave, and keep private keys out of Git.
- Segment the remote site so the tunnel only reaches the VLANs it needs.
- Log blocked traffic on both ends during rollout; it reveals what is really being used.
- Document addressing and rules next to the code that creates them (Terraform for AWS, config backups for pfSense).
Summary#
A WireGuard site-to-site VPN is one of the simplest ways to connect on-premise devices to cloud services without exposing them publicly. Plan addresses first, remember the AWS routing details, and spend most of your effort on firewall rules: the tunnel is the easy part, least privilege is the important part.