Comment on How can I restrict visiting a service through a domain to VPN-connected devices?
TheQuantumPhysicist@lemmy.world 1 year agoBut what about the domain name association? How is that done?
Comment on How can I restrict visiting a service through a domain to VPN-connected devices?
TheQuantumPhysicist@lemmy.world 1 year agoBut what about the domain name association? How is that done?
InvertedParallax@lemm.ee 1 year ago
Same as the public one, just with an internal address.
Have this on my domain, public domain with a subdomain server behind VPN and 1 host that points to an internal address.
Anyone tries to reach from outside just times out or something.
DNS is just a lookup of names to numbers, that’s all it is, the numbers can be anything, I can point my domain to Google if I want.
TheQuantumPhysicist@lemmy.world 1 year ago
Please elaborate a little more. So assuming the server where the service lies has IP address 1.2.3.4, and some VPN that I can connect to with 1.2.3.4:1194. If my DNS server points to 1.2.3.4, how will the service only work through that VPN?
elbarto777@lemmy.world 1 year ago
Whatever you do with IPs, you can do with ports too.
“Allow this port, but not that one”.
TheQuantumPhysicist@lemmy.world 1 year ago
Please see this comment to understand my frustrations with the answers in this thread: lemmy.world/comment/2363248
InvertedParallax@lemm.ee 1 year ago
There’s an internal ip address for the VPN server, say 4.3.2.1, you point the http dns record to that address.
The VPN server has 2 addresses by definition, an internal address and an external, public one that you connect the VPN to. Make sure the webserver only exposes itself on the private address, either by configuration (nginx/apache listen address) or by firewall (iptables -A input -j DROP)
pe1uca@lemmy.pe1uca.dev 1 year ago
About the DNS, you can use an internal DNS and find some way for your VPN to configure it in all the machines connected to it.
DNS usually has a fall back if the name is not found, so you can always have your custom DNS on and it’ll first check its own records then check for some level up (I’m basing this off of my experience with with pihole docs.pi-hole.net/ftldns/ )
About your ports question: you just need to change the ip to the VPN one.
For example, I have a VPS which has a public IP and I have tailscale installed.
If I were to make my service listen to all interfaces I could use
1.2.3.4:1194
or100.100.100.100:1194
(this being the tailscale ip)But I usually only configure them to listen to
tailscale0
, so I can no longer reach them with1.2.3.4:1194
, only with the tailscale ip.In your DNS you need to configure this new IP to be served.
I’m guessing you can also do some configuration with a firewall.
Probably
ufw add allow from 10.0.0.0/8
could work if this was the IP range of your VPN, then any one can still use your public IP and only your VPN will be able to connect (But don’t quote me on this, I haven’t done it).(Just be sure to check the configuration of your service, docker can bypass ufw :/ )
TheQuantumPhysicist@lemmy.world 1 year ago
Thank you, but my question was specifically about DNS. Another person pointed out that setting the DNS record to the VPN destination is the right answer. I appreciate the details you wrote and I’ll look into them.