OpenVPN guide: fix DNS servers for VPN connections

Moderator: BarryK

Post Reply
User avatar
Federico
Posts: 288
Joined: Tue Jun 20, 2023 2:40 pm
Has thanked: 1 time
Been thanked: 36 times

OpenVPN guide: fix DNS servers for VPN connections

Post by Federico »

When connecting to a VPN by using OpenVPN or other Linux software, the system will not add the DNS server(s) of the network you are connecting to, to the /etc/resolv.conf file.
This implies that you will be able to ping the IP addresses of all computers being part of the network you are connecting to, but not their respective hostnames. This can be a problem in certain situations.

- This issue is basically universal on Linux and affects the vast majority of distributions

- This issue does not occur on MS Windows

I'm going to show you the solution I found when using OpenVPN, which comes preinstalled on EasyOS (and usually also on other distros):

1) Go here to download and install the package openresolv_3.12.0-3_all.deb

2) Go here and download (or just copy / paste the code) the script update-resolv-conf.sh . Place it on /etc/openvpn making it executable and keeping its name

3) add these parameters to the command through which you are launching OpenVPN:

Code: Select all

--setenv PATH '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' --script-security 2 --up /etc/openvpn/update-resolv-conf.sh --down /etc/openvpn/update-resolv-conf.sh --down-pre

4) Enjoy your ability to ping all the hostnames of your remote network computers when you are connected through OpenVPN.

Desktop PC
Case: Sharkoon S25-W MB: Asus Rog Strix B550-A PSU: XFX Pro 750W CPU: AMD Ryzen 5700X @ 4.6 GHz RAM: Corsair 32 GB DDR4 @ 3000 MHz Heatsink: Scythe Mugen 5 rev. B VGA: Asus Tuf RTX 3080 12 GB OC

Laptop PC: Asus Zenbook UX325E

Post Reply

Return to “EasyOS”