17

I'm using OpenVPN to set up a VPN to connect my laptop at home to my workplace LAN. I want to be able to refer my workplace computers by their name and not by their IP but I can't.

This is my situation:

Workplace LAN:

  • Address space: 192.168.101.0/24
  • Router address: 192.168.101.1

Home LAN:

  • Address space: 192.168.1.0/24
  • Router address: 192.168.1.1

VPN:

  • Address space: 10.100.1.0/24
  • OpenVPN server address: 10.100.1.1

All machines are running Microsoft Windows.

At my workplace, the PC running as the OpenVPN server is 192.168.101.50 (and 10.100.1.1 in the VPN), and its machine name is workplaceserver.

At my workplace the name workplaceserver is resolved to address 192.168.101.50, but in the vpn client the name workplaceserver can't be resolved, I want it to be resolved to 10.100.1.1. How should I configure OpenVPN in order to achieve that?

Toto
  • 401
  • 1
  • 5
  • 13

3 Answers3

21

You can use your office DNS (if you have one), instead if the default DNS you are using. To do so, you have to add this option to OpenVPN server (see docs)

push "dhcp-option DNS 10.x.x.x"    
Dan Andreatta
  • 5,384
  • 2
  • 23
  • 14
  • 2
    This doesn't seem to have any effect in my case. Could it be because I'm not using DHCP? I must use a static setup, but I'd like the DNS to get overridden anyway. – Daniel F Nov 06 '14 at 13:01
  • You may also need the `redirect-gateway` directive (see [manual](http://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html)), since your default gateway has probably been handed to you by your DHCP or manually. Using the `redirect-gateway` sends things through the VPN - maybe fixing your issue in the process. – MrMajestyk Feb 03 '15 at 09:14
  • If you're not using a bridged network you will also need a route to the DNS server: push "route 10.0.0.0 255.0.0.0" – wilsotc Sep 13 '15 at 16:13
0

You can also simply add hosts you need (very few, isn't it?) to hosts file, and not even mess with OpenVPN configs (which may be useful if you don't have and won't set up DNS server inside the private network).

Alexander
  • 724
  • 2
  • 11
  • 19
-2
  • Open an account at OpenDNS.
  • Create yourself a Network.
  • Add the IP range(s) of both sides.
  • Add workplaceserver as an alias.

From there, you should have it to work and your configuration will follow you, as long as you use their DNS, which are very good by the way.

Giacomo1968
  • 3,522
  • 25
  • 38
Embreau
  • 1,277
  • 1
  • 9
  • 10