To test things, I set up OpenVPN on my own OpenWRT-based router and talk to it with OpenVPN on one of my Gentoo laptops. Communication works fine, but the setup is not what I expected: 1. it did not route all my laptop's traffic over the VPN, and 2. it did not let me look up addresses on my remote network. As for point 1, I see that that all those ads for commercial VPN providers lulled me into thinking that OpenVPN is also supposed to work that way. It was not immediately clear, but now I know that OpenVPN ordinarily leaves the existing default route alone as it provisions a tunneled route to the addresses on the remote network. Knowing that simplifies my life because that's just the configuration I wanted.
My problem is that /etc/resolv.conf does not change when I start the openvpn service (I'm using OpenRC). After some digging, I see that openvpn is configured to run /etc/openvpn/up.sh when the connection handshake finishes. Here are what are evidently the lines of happiness in that script:
Code: Select all
# Preserve the existing resolv.conf
if [ -e /etc/resolv.conf ] ; then
cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
fi
printf "${DNS}" > /etc/resolv.conf
chmod 644 /etc/resolv.confCode: Select all
cp -p /etc/resolv.conf /etc/resolv.conf.snapshotCode: Select all
$ cat /etc/resolv.conf.snapshot
# Generated by openvpn for interface tun0
domain lan.example.com
nameserver 192.168.100.1Code: Select all
$ ls --full-time /etc/resolv.conf*
-rw-r--r-- 1 root root 209 2025-11-11 13:33:12.570588034 -0500 /etc/resolv.conf
-rw-r--r-- 1 root root 94 2025-11-11 13:33:12.523586817 -0500 /etc/resolv.conf.snapshot
-rw-r--r-- 1 root root 209 2025-11-11 13:33:12.522586791 -0500 /etc/resolv.conf-tun0.svI doubt that this is normal for VPN users. Is there something that would trigger dhcpcd to update /etc/resolv.conf and, if so, a way to stop doing that while the VPN is active?


