Our Linux Ubuntu configuration does have a DNS server (Bind 9).
And resolv.conf
has its
nameserver 127.0.0.1
When using openvpn
client on that Linux, the nameserver is not changed (by the VPN server) but I would like to set it - only during the VPN session - to another specific DNS server x.y.z.t
, by changing the openvpn client config.
Then, when the openvpn
session ends, nameserver should be back to 127.0.0.1
.
Is there a "clean" way (ie a line in the openvpn client config file) to do that?
(Note: The VPN server config cannot be changed)
After more googling, could find the answer - below if it can help someone.
resolv.conf
config file/usr/share/openvpn
, namedupdate-resolv-conf
. The script determines what should be the newresolv.conf
, and how to restore it (see link below)these lines
in the openvpn client config file.
Read on this wiki for more information.
2022 update (Arch Linux)
To set a public dns server and update resolvconf, add the following to your ovpn client profile file:
Consider using
route-up
/route-down
scripts on your client to alter your configuration on connection setup as you see fit. See the OpenVPN docs on details for how to set this up and which variables you might use in these scripts.This was useful information in order to help me fixing this issue.
I'm an arch linux user and what I saw is that when a Linux client is used with Access Server, this one is unable to alter the DNS settings on the client in question not resolving host as it the stands on OPEN VPN Documentation
I created a script which fixes the problem and with a couple of extra parameters handles openvpn connections via command line.
https://gist.github.com/android10/ee5c3e93dbcf9b7b31e6ee768cbfd477
Here is the main command being executed for the connection:
Any feedback is more than appreciated it.
echo "nameserver=w.x.y.z" > /etc/resolv.conf
echo "nameserver=127.0.0.1" >> /etc/resolv.conf