OpenVPN: Automatic switching of used DNS servers

Colleagues, tell me, please, how can I make my OpenVPN client, after establishing a connection with its server, switch the DNS requests to DNS-server that OpenVPN-server specified in the "push" command? And in the event of a shutdown, OpenVPN returned requests to DNS, which reported by DHCP on the WAN interface?

I don't want to write OpenVPN scripts where DNS server addresses are hardcoded. Then it will be very difficult to change this for all clients.

I did not change the DNS and DHСP settings, I use those that the distributive had by default. I remember that a few years ago there was no such problem - everything happened automatically.

Thanks in advance,

1 Like

Thanks for the link, but it only confused the situation.

As I understand it, the "DNS and domain" section applies to my case.

The file "/etc/hotplug.d/net/00-openvpn-resolv" uses the files "/tmp/resolv.conf.d/resolv.conf.vpn" and "/tmp/resolv.conf.d/resolv.conf .auto".
There is no directory "/tmp/resolv.conf.d/" in my router, and after I created it, nothing began to appear in it. I suppose that either I need to make some additional settings that are not described in the article, or something has changed.


Sounds like you are using an old firmware that is no longer supported.
You should first upgrade to the latest stable OpenWrt release.

I installed OpenWRT a few days ago from the distribution openwrt-19.07.10-ar71xx-mikrotik-nand-large-squashfs-sysupgrade.bin.

19.07.x has been EOL for over one and a half years, please upgrade to a supported OpenWrt release.