I recently set up an OpenVPN server to securely connect employee computers to an internal corporate network. The VPN doesn't "hide" the user's IP address, because that's not the intended purpose, and therefore I haven't enabled forced traffic redirection (;push "redirect-gateway def1 bypass-dhcp").
I want to change the default DNS address to one that's hosted on the VPN server, so the clients can use more user-friendly internal domain names instead of IP addresses, but I'm having some strange issues. In my server.conf, I have enabled push "dhcp-option DNS 10.8.0.1" and after connecting to the server, the correct DNS setting shows up in ipconfig /all:
Code: Select all
Unknown adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9 for OpenVPN Connect
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.8.0.6(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DNS Servers . . . . . . . . . . . : 10.8.0.1 <=== This is the correct DNS address
Strangely, if I try to nslookup an internal domain name, it works, even if I don't specify the DNS server address. What's even more strange is that DNS resolution seems to fully work from within a WSL (Windows Subsystem for Linux) terminal, e.g. the ping command functions as expected.
OpenVPN Connect is already deployed on all the relevant machines, and all .ovpn profiles have already been issued and installed, so it would be preferrable if this problem could be solved with a server-side "push" configuration, or something similar.
Here's my minimized server.conf file with all comments stripped:
Server Config
1
port 52278
2
proto udp
3
dev tun
4
ca ca.crt
5
cert server.crt
6
key server.key
7
dh none
8
topology subnet
9
server 10.8.0.0 255.255.255.0
10
ifconfig-pool-persist /var/log/openvpn/ipp.txt
11
push "dhcp-option DNS 10.8.0.1"
12
push "block-outside-dns"
13
client-config-dir /etc/openvpn/ccd
14
client-to-client
15
keepalive 10 120
16
tls-crypt ta.key
17
cipher AES-256-GCM
18
auth SHA256
19
user nobody
20
group nogroup
21
persist-key
22
persist-tun
23
status /var/log/openvpn/openvpn-status.log
24
verb 3
25
explicit-exit-notify 1