Switch network interface
I have standalone Tor client listening on localhost port 53 for DNS UDP packets on a Ubuntu 18.04 VM environment. This is the equivalent to setting on /etc/tor/torrc:
I also have a DNS rule on network manager set to redirect DNS packets to IP:
After following the standard OpenVPN configuration, I make a connection to the VPN server with:
openvpn --config /etc/openvpn/servers-conf/01.example.tcp.ovpn
The problem is Tor receives the DNS UDP packets, converts them to TCP packets and then attempts to send them through my main "naked" network interface to Tor relays, instead of using the secure tun0 interface. OpenVPN sees the TCP packet leaving the "naked" interface and thinks this is not safe and blocks them, which means I'm not able to resolve domain names as Tor's DNS TCP packets can't leave the system.
In order to fix this, I have to restart Tor using:
systemctl restart tor
This then updates Tor to connect to tun0 and everything works fine again however, it would make sense to have Tor update automatically or to have an option to specify a network interface order for Tor to connect to. Example:
InterfacePref: tun0, tun1, eth0
Similar to a bootloader selecting what to boot first, this means Tor would always try to connect to tun0 if available, if not it will try tun1 and else eth0. If at any time a better interface comes up Tor should switch to it automatically. A default value would still connect to the default interface as it does today.