DNS Set by OpenVPN Config?

I use public wifi and when I have DNS settings configured (and especially force DNS) it doesn’t allow access to captive portal or internet so I have to manually disable DNS, connect, then re-enter DNS.

I was looking for a way to enter the DNS settings directly in the .ovpn file but don’t think this would be possible as it’s controlled by the client / dhcp.

I found this link from a few years ago which suggests the client can be edited to force a particular DNS with the code below (presumably this would allow no DNS to be set except when VPN is connected). Does anyone know what file i’ve to edit for client or whether this would work / another potential workaround.

put actual dns name here

dhcp-option DNS

There is a script in /usr/bin/dns_updown_script.sh, not tested yet, but this is used for this purpose.

You need to write in the ovpn. But we don’t have a tutorial now.
up /usr/bin/dns_updown_script.sh

down /usr/bin/dns_updown_script.sh