Issue switching between dual-stack and IPv4-only networks

Got a problem with Viscosity or need help? Ask here!

illusionrelief

Posts: 1
Joined: Sun Sep 03, 2023 11:41 am

Post by illusionrelief » Sun Sep 03, 2023 11:53 am
Hi - I seem to be running into an issue when switching between dual-stack and IPv4-only networks. Here's the setup:

I have an OpenVPN server (let's call it my-openvpn-server.example.com) that is fully dual-stack: it's accessible over both IPv4 and IPv6 and has both A and AAAA records (let's say 123.45.67.89 and 2000: 1111: 2222::abcd). When I'm elsewhere on the Internet on a dual-stack network and connect to my server, Viscosity resolves it to the IPv6 address and uses that to talk to the server, and all is well and good.

However, if I then switch to an IPv4-only network (by connecting to different WiFi on my Mac) and try to connect, Viscosity stays in the "connecting" state and I see this in the logs:
Code: Select all
2023-09-02 01:00:00: State changed to Connecting
2023-09-02 01:00:00: Checking reachability status of connection...
2023-09-02 01:00:00: Testing address: 2000:1111:2222::abcd Not Reachable
2023-09-02 01:00:00: Connection is not reachable. Disconnecting.
2023-09-02 01:00:00: State changed to Disconnected (Not Reachable)
2023-09-02 01:00:00: Connection will be reconnected when it becomes reachable
It looks like the resolved IPv6 address is being cached and used even when I'm no longer on a v6-enabled network. I appreciate saving a DNS lookup, but I would expect OpenVPN/Viscosity to fall back to IPv4 in this situation. I'm not sure if this is a Viscosity issue or an underlying OpenVPN bug, but figured I'd start by reporting it here. Thanks!

James

User avatar
Posts: 2297
Joined: Thu Sep 04, 2008 9:27 pm

Post by James » Tue Sep 05, 2023 3:17 pm
Hi illusionrelief,

A quick fix in this instance will be to change the protocol from "UDP" or "TCP" to "UDP v4" or "TCP v4". This will force the use of IPv4 in both instances.

Viscosity will cache remote IPs, however these should be reset when the connection enters a disconnected state. If you're leaving the VPN connection active while switching networks, OpenVPN may enter a "reconnecting" state instead, and so it'll attempt to use the same remote address and the cache won't be cleared. You should be able to work around this by adding "remap-usr1 SIGTERM" as an advanced command to your connection (this will cause it to do a full disconnect/connect cycle instead).
https://www.sparklabs.com/support/kb/ar ... -commands/

If you're manually disconnecting and reconnecting your VPN connection and you are still seeing the cached IP address being used, then it likely points to a bug in Viscosity. If this is the case, a copy of the details listed in the following article (you may prefer to email these rather than posting on a public forum) should help us track it down.
https://www.sparklabs.com/support/kb/ar ... ort-staff/

Cheers,
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
2 posts Page 1 of 1