OPNSense Selective Routing for Specific Networks (Websites)
Goal: Route specific websites through Wireguard VPN tunnel
Caveat: With the use of CDNs, this doesn't work really well. i.e. the CDN redirects you to different IPs, and each time you resolve the domain, it gets a different IP, so it doesn't always get routed through the VPN tunnel
Follow the instructions from OPNsense & WireGuard: Tunnel Devices through VPN to do the following:
- Configure & Enable WireGuard (External Link)
- Assign the WireGuard interface (External Link)
- Tweak WireGuard Gateway settings (External Link)
- Add manual NAT rule for the WireGuard Interface (External Link)
- Create an Alias for Sites/Networks you want to route through the VPN tunnel
- Similar to Add firewall rules to route certain devices to the WireGuard Gateway, we are going to create a firewall rule to route all clients to the Wireguard gateway if the destination is in the Alias we created in (5)
Click the orange [+] -> and then add the Alias as the Destination in the rule, change the Gateway to your new Wireguard VPN Gateway.
Then move the rule near the top of the list so that requests will hit that rule before your other rules.