[Solved] Resolv.conf is not updated after an OpenVPN connection

After connecting a VPN on Linux (my case an Ubuntu) that resolv.conf is not updated and you can’t resolve names from that network as expected.

After searching a bit I found this website that gave me a solution.
You can check in detail here: https://dev.to/setevoy/arch-linux-openvpn–resolvconf-is-not-updated-2470

After connection to the VPN has been performed, we can observe that resolv.conf hasn’t been updated.

$ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search home

Modify your opvn file and these new lines (bottom is fine):

...
script-security 2 
up /etc/openvpn/update-resolv-conf 
down /etc/openvpn/update-resolv-conf

Restart your VPN connection and check again your resolv.conf file.

$ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 10.11.0.2
nameserver 127.0.0.53
search home

After terminating your VPN connection, resolv.conf file will be restored to its previous state.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *