I have an internal website and a few microservices that are only accessible on a VPN (which is set up using WireGuard running in docker).
Currently, users access these services by using the private/local IP address of the servers assigned by the VPN server and optionally adding a port number, e.g. <server IP>:<server port>
.
Is it possible to create fully qualified domain names that resolve to the location of these services ONLY when users are connected to the VPN?
I could create a regular DNS rule mapping some FQDN to the public IP address of the internal website server, but not all of the servers have unique public IP addresses.
Can I somehow run my own DNS server on the VPN that takes priority over public DNS servers? I imagine that this way, if I have specified that www.google.com
should resolve to 192.168.0.1
, users would end up at that address rather than the real google.com site. If I hadn't specified that rule, I would want users to fall back to a public DNS service.
Is this possible? (or bad practice?)
Hopefully, that makes sense. This is my first question on StackExchange :)
--add-host
to yourdocker run
invocation, orextra_hosts:
if you're using docker-compose? (example)