Using DNS provided by OpenVPN

Hello everyone,

I’ve started with a fresh install of CoreELEC on my Odroid N2 yesterday. Used the latest image of Matrix 19.3 which went smootly.

The first thing i’ve started configuring is OpenVPN, because this is always the hardest to get right and in the past i took some “shortcuts” to get things working.

Anyway, the thing i had problems with last time is the nameservers; i could not get CoreELEC to use the nameservers provided by my VPN provider. In the end i resorted to handing out the VPN providers nameservers through my routers DHCP options, which means i can’t use DNS until the VPN is up and i have to resort to connecting to IP addresses of my VPN provider instead of hostnames.

Upon connecting the OpenVPN i can see that a nameserver is being provided:

CoreELEC openvpn[4913]: PUSH: Received control message: 'PUSH_REPLY,dhcp-option DNS

However, when i do a lookup i see the nameserver being used that my router provides through DHCP:

CoreELEC:/etc # nslookup
Address 1:

Address 1:

And my OpenVPN config:

dev tun
proto udp4
remote 1194
remote 1194
cipher AES-256-CBC
resolv-retry infinite
verb 3
remote-cert-tls server
ping 10
ping-restart 60
sndbuf 524288
rcvbuf 524288

route net_gateway

pull-filter ignore "route-ipv6"
pull-filter ignore "ifconfig-ipv6"

auth-user-pass /storage/.config/credentials.txt
ca /storage/.config/vpn_ca.crt
remap-usr1 SIGTERM

script-security 2
up /storage/.config/

Any suggestions how i can get the VPN providers nameservers working when the VPN is up?

I found a solution:

i’ve changed the last line in my openvpn config file to:

up /storage/.config/

(didnt need the route deletion anymore that was there before)

This file contains the following:

echo "nameserver" > /etc/resolv.conf

This does seem to work. Are there any downsides to this solution?

The only one i can think of that this still doesn’t use the nameserver that gets pushed by the OpenVPN server, but sets it static.

Any better possible solution?

Good evening,

I’m still struggling to get an OpenVPN setup that i am satisfied with regarding DNS. I would like to prevent DNS leaking, but i’m running into 2 main problems:

  1. I can’t get CoreELEC to use the nameservers pushed by the OpenVPN server.
  2. Automatically installed host routes to the nameservers provided by the local router’s DHCP.

The first problem has a few workarounds, but they create new problems:

  • Use up/down scripts to set the nameservers as the VPN status changes: I would have to set it to a pre-defined nameserver, this will break if my VPN provider changes nameservers and I’m not sure the down script will function properly if the VPN fails/stops/gets stopped, with the risk of the VPN not able to come back up because I’ve set a nameserver that’s only reachable with the VPN up.

This last part is fixable by changing the hostname of the VPN service to IP addresses, but these are not static I’ve noticed.

The second problem; the automatic host (/32) routes to the nameservers received by DHCP are a pain in my ass. I want DNS requests to go into the tunnel, not towards my router. I could make a script to delete these specific routes when the tunnel comes up, but that won’t work if the nameservers get changed in the routers DHCP sometime in the future or if I use my CoreELEC box somewhere else with different DHCP servers.

Any help pointing me in the right direction is much appreciated.



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.