Introduction
Here's my particular situation:
- I'm developing Emilio. Which requires to have an accessible endpoint so that I can query stuff from a Gmail Addon.
- I have Nginx Proxy Manager at home routing requests made to my development url to my laptop so I can test this endpoint.
- I have a WireGuard VPN server at home that I can use to connect my devices to my local network when I travel.
You might have a similar issue if you have set up a server somewhere, say, your friend's home, and you want that server to be part of your local network.
Problem:
WireGuard clients (my laptop) have a totally different subnet:
- Your local subnet (probably):
192.168.0.0
(255.255.255.0
as the mask or/24
) - WireGuard subnet:
10.6.0.0/24
This means that, while I can ping LAN devices from my laptop when connected through WireGuard, I cannot do the opposite.
Here's a solution that worked for me.
Problem Setup and Variables
To make this guide clearer I will create fictional addresses:
- My laptop's WireGuard IP:
10.6.0.12
- WireGuard's server internal IP at home:
192.168.0.59
What I want:
NGINX routing requests from test.domain.com
to 10.6.0.12
.
Static Routes
I want to tell my NGINX host or any device in my LAN for that matter, where to point when I request the IP 10.6.0.12
.
This is a great use case for static routes.
To create a static route you need 3 things:
- The Gateway: What's the entry point for the subnet you want to connect to.
- The subnet you want to connect to
- The subnet mask
In my case:
- Gateway:
192.168.0.59
- Subnet:
10.6.0.0
- Subnet mask:
/24
or255.255.255.0
(they're 2 ways of saying the same)
Create a Static Route in PFSense
I use PFSense at home, so I will demonstrate how to do it in there. If you have another router or firewall just search how to add a static route in your specific model.
- Go to
System
>Routing
- In the
Gateways
tab, add a new gateway. - Give the gateway the name you want and set the IP, in my case
192.168.0.59
(the WireGuard server at home). - Apply the changes.
- Now in the
Routing
menu, go toStatic Routes
- Hit
+ Add
- In Destination Network add the WireGuard subnet, in my case
10.6.0.0/24
- Select the Gateway we just added
- Give it a description if you want
- Save and apply changes
Done!
Now you should be able to ping your laptop from your LAN. It might take a few minutes though, so be patient.
In my case I can now create an NGINX proxy that redirects test.domain.com
to my laptop while away at 10.6.0.12
.
Top comments (0)