How to create a VPN with custom DNS

Issues related to configuring your network
Post Reply
vinilara
Posts: 9
Joined: 2020/08/01 13:53:09

How to create a VPN with custom DNS

Post by vinilara » 2020/08/01 15:10:03

Hi everyone,

I have one VPS that has CentOS 7 installed. I need to put this server as VPN so when the clients connect they will be able to reach personalised domains, like:

ftp.development.mycompany

I installed OpenVPN and configured it to allow communication between client-server but this do not resolve domains, just IP's. So how can I set up this DNS Server?

BShT
Posts: 584
Joined: 2019/10/09 12:31:40

Re: How to create a VPN with custom DNS

Post by BShT » 2020/08/04 13:13:23

i have the same situation here and we use 2 browsers, one for general internet and other connected to our proxy over VPN that resolves internal sites.

BShT
Posts: 584
Joined: 2019/10/09 12:31:40

Re: How to create a VPN with custom DNS

Post by BShT » 2020/08/04 13:20:54

https://openvpn.net/vpn-server-resource ... -problems/

according to this, you can set a DNS server inside openvpn client, i never used this way

i don´t want everybody querying DNS over VPN...

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to create a VPN with custom DNS

Post by TrevorH » 2020/08/04 13:54:54

Bear in mind the way that DNS works on linux. There is one set of dns servers listed in /etc/resolv.conf and they are consulted in order, from the top down, one by one until one of them gives an answer. Any answer, even if it's "never heard of it". At that point the search stops. The only time a second nameserver is asked is if the first one does not respond.

This means that any DNS server you put in there has to be able to answer all queries, not just the ones that need to go over the VPN.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: How to create a VPN with custom DNS

Post by aks » 2020/08/04 18:40:44

Generally the way I "solve" this is to use DHCP routes and DHCP provided DNS servers (they are all options). This usually means clients work, except in the cases where the client has done "silly" things.
This also gets very complex very quickly across Windows, MacOS and Linux.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How to create a VPN with custom DNS

Post by jlehtone » 2020/08/05 11:45:27

BShT and aks said that openvpn can tell the client to use a specific DNS server, when the VPN tunnel is active.

That DNS server would be separate from the VPN, but one that can resolve all names (public and private) "correctly".
dnsmasq is relatively simple, can act as caching DNS server, and resolve private names too.

Post Reply