I use an openvpn infrastructure with a server and some clients. The clients can call each other via their hostnames, but cannot reach the server in the same way. At the moment it is possible to reach the server via its IP address.

How can I transfer the server name and the corresponding IP addresses (v4 and v6) to the clients?

If possible, i don't want to set up an extra dns server


Edit re-read your question:

Ok without a DNS server you would add the server's IP to the client's /etc/hosts file: dns.local

I would recommend the dns server option though, it's straight-forward:

Install bind or dnsmasq on the openvpn server and add the following to its config:

push "dhcp-option DOMAIN yourdomain.local"
push "dhcp-option DNS X.X.X.X"

Where X.X.X.X is the IP bind/dnsmasq listens on.

The options do the following:

  1. DNS X.X.X.X -- Set primary domain name server IPv4 address. Repeat this option to set secondary DNS server addresses.
  2. DOMAIN yourdomain.local -- sets Connection-specific DNS

If the DNS server is not in the same network as the VPN clients you may need to use:

push "redirect-private bypass-dns"

Which will create a separate route to the DNS server that skips the VPN.

If you're using Bind, then your named.conf would contain:

zone "local" IN {
    type master;
    allow-update { none; }; 
    notify no;
    file "/etc/bind/local.zone";

And local.zone:

$TTL 600
@       IN      SOA     dns.local. root.local. (
                        2018061001      ; serial
                        12h             ; refresh
                        1h              ; retry
                        2w              ; expire
                        1h              ; minimum
                NS      ns              ; Inet Address of name                         server
                MX      10 mail.local.  ; Primary Mail Exchanger
                MX      20 mail.local.  ; Secondary Mail Exchanger
localhost       IN      A
dns             IN      A
ns              IN      A
mail            IN      A
client100       IN      A
client101       IN      A

If you're new to Bind make absolutely sure it does not respond on any Internet facing IP.

  • Hey, thanks. Maybe I should really go for a DNS server... For now I will have to read some texts about dns and bind.
    – Santobert
    Feb 20 '19 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.