Accessing NAS via hostname over VPN

I previously had OpenVPN setup through a Netgear router. When I connected to the VPN (or of course if accessing locally), I could access my shared folders using the device’s hostname (\hostname\sharedfolder). The NAS has been relocated, so I set up OpenVPN through Synology (DS218+). VPN works great, but I can only access the NAS using the IP address 10.8.0.1 and not the hostname. Is it possible to access it using the hostname instead of the IP?

Add to your ovpn file:
push “dhcp-option DNS 192.168.1.1”
(replace 192.168.1.1 with the IP of your router)

9 times out of 10 this should fix your problem.

This will use your router as your DNS server instead of whatever it is on your current network.

Pointing OpenVPN to my router for DNS didn’t work for me. What I ended up doing is

  • install DNS Server on my Synology
  • create a new zone called “local”
  • create a record called “nas.local” pointing to 10.8.0.1
  • enable DNS forwarding to my router (182.168.1.1) for all unknown domains
  • in VPNConfig.ovpn, point to the Synology DNS Server by adding “dhcp-option DNS 10.8.0.1”

Now when in home, I can use “nas.local” which the router translates to 192.168…, and over VPN I also use “nas.local” which translates to 10.8.0.1.

It works well, please let me know if it’s a bad idea though!

Windows uses both NetBIOS-over-TCP (BROWSER) name resolution and DNS to resolve network shares. If your have your VPN software’s DHCP pool inside the same subnet as your NAS and your have the hostname setting configured in your Synology, Windows can resolve the hostname without DNS. However, DNS resolution is a lot simpler to set up and more reliable. OpenVPN can tell the Windows DHCP driver to use your VPN’s DNS servers.

You could faff with the DNS settings on your router, or adjust the hosts file on your client machine to point but in both instances, why not just use the ip? It seems you’re adding a lot of complexity to your setup for only cosmetic value?

I’ll give those suggested solutions a try. I want to use the hostname instead of the IP address because if the computer is connected to the local network, the VPN is not necessary and accessing the NAS by the IP wouldn’t work — it would be accessed by the hostname.

This guide might be helpful for you VPN for Synology

You need split-tunnel dns to work.

Here is a step by step tutorial: OpenVPN Split Tunnel on Synology Diskstation | Trinkets, Odds, and Ends

This didn’t work for me. I think the router returns the 192.168… IP for my NAS, which doesn’t work over VPN. How do you get around that? I posted my workaround below but it seems overly complex.

To which ovpn-file do I add this?
I can’t write to /var/packages/VPNCenter/etc/openvpn/openvpn.conf

Isn’t router IP 192.168.1.1 for most? So replace router IP with what?

So you cannot ping your NAS even by its 192.168… IP address?

Perhaps you have an incorrect ovpn configuration. You should be able to access devices by their 192.168… IP address over a VPN connection.

Are you able to ping other devices on your LAN? It may be that your VPN client is putting you on a separate VLAN. Alternatively, check your local IP (that the VPN is giving you) matches the trusted IP range on your NAS, if you’ve set one up.

Yeah it is for most, sorry, should have worded that differently - replace 192.168.1.1 with your router IP if it is different than that.

I’ve also seen various brands of router sitting at 192.168.0.1, 192.168.1. 254,10.0.0.1, 10.0.0.2, or 10.0.1.1, so didn’t want to assume the IP would be 192.168.1.1.

That’s right, the standard IP doesn’t respond. I thought it was normal and the VPN somehow operated in a different subnet. I might need to add routing entries in the ovpn file?

I think you’re right that’s the issue. My firewall allows all local IP ranges so it’s likely to be a VLAN/routing issue.