rethink-app icon indicating copy to clipboard operation
rethink-app copied to clipboard

ipv6 is used even though ipv4 is selected

Open FlingCarnationProposal opened this issue 1 year ago • 4 comments

Addresses are sometimes resolved using ipv6 addresses even though "choose ip version" is set to ipv4. As a result, connections frequently fail.

screenshot img0:

Screenshot_20240616_071632_com celzero bravedns

FlingCarnationProposal avatar Jun 15 '24 23:06 FlingCarnationProposal

Seems to not be an issue without advanced dns filtering switched on.

FlingCarnationProposal avatar Jun 15 '24 23:06 FlingCarnationProposal

Yes. Thanks.

This happens because in Advanced DNS filtering mode, Rethink may engage in 4to6 (IPv4 to IPv6) translations, which hurts in cases where the underlying network may not even have IPv6 connectivity.

This issue has been fixed along with fixes done for #1546 but if Rethink doesn't perform translations, it'll cause issues seen in #1543 (where both IPv4+IPv6 are available to use, but Android only reports IPv6)... of course we must fix connectivity issues in both these cases.

ignoramous avatar Jun 16 '24 13:06 ignoramous

See also: https://github.com/krille-chan/fluffychat/issues/1197

ignoramous avatar Nov 02 '24 20:11 ignoramous

An update on this issue: it seems my home ISP had added ipv6 connectivity(?), but my mobile ISP had not, and testing on mobile internet leads me to believe that, while the situation seems to have improved(can't remember what the original issue was like, but I think it was more unreliable than now), some apps are still trying to connect to ipv6 addresses even though ipv6 connectivity is not available:

Screenshots

cfcae149-1a2b-46c6-8dac-81c09df978ae 61505b66-8cf7-4712-8cf3-2d5c7b9b22e3

It's also rather inconsistent, as sometimes it can connect to an ipv4 address like it should've.

FlingCarnationProposal avatar Jan 14 '25 03:01 FlingCarnationProposal

A bunch of improvements around dual-stack connectivity in v055o: https://github.com/celzero/rethink-app/releases/tag/v0.5.5o

Especially, if you've set Choose IP version to Auto and Configure -> Network -> Perform connectivity checks to Auto, you should see a marked improvement in v4+v6 (dual-stack) or v4-only networks.

Let us know how it goes.

ignoramous avatar Aug 09 '25 05:08 ignoramous

Now everything thinks I'm offline, even on reinstall of the app. Had to downgrade.

The logs don't seem to reflect that, as it shows the apps connecting.

Edit: The VPN is in lockdown mode. Might be related to #2021.

FlingCarnationProposal avatar Aug 09 '25 07:08 FlingCarnationProposal

Now everything thinks I'm offline, even on reinstall of the app. Had to downgrade ... Might be related to https://github.com/celzero/rethink-app/issues/2021.

Possible. Which Android version?

ignoramous avatar Aug 09 '25 08:08 ignoramous

Android 10. Huawei Nova CDY NX9B running EMUI 10. Last and current working version of Rethink: v0.5.5n.

FlingCarnationProposal avatar Aug 09 '25 08:08 FlingCarnationProposal

A bunch of improvements around dual-stack connectivity in v055o: https://github.com/celzero/rethink-app/releases/tag/v0.5.5o

Especially, if you've set Choose IP version to Auto and Configure -> Network -> Perform connectivity checks to Auto, you should see a marked improvement in v4+v6 (dual-stack) or v4-only networks.

Let us know how it goes.

but it causes this issue #2024

error-reporting avatar Aug 09 '25 11:08 error-reporting

Had an interesting observation trying out 0.5.5p. When Choose IP version is set to IPV4, network connectivity is lost when toggling wifi on/off. When it is set to AUTO there is no issues.

anxiouslelimo avatar Aug 12 '25 07:08 anxiouslelimo

When Choose IP version is set to IPV4, network connectivity is lost when toggling wifi on/off

Sounds worrying.

  1. Do you have any other setting turned ON in Configure -> Network (like "Use all available networks" or "Stall on network loss" or "Loopback" etc). If so: turn them OFF (those are OFF by default).
  2. Have you turned ON "Block connections without VPN" mode (from Android's VPN Settings) for Rethink? This is turned ON by default on Graphene, afaik.
  3. Does your Wifi have IPv4 connectivity? You can test this by excluding browser or Termux and testing if IPv4-only websites like github.com / ip4.me work.

ignoramous avatar Aug 12 '25 08:08 ignoramous

When Choose IP version is set to IPV4, network connectivity is lost when toggling wifi on/off

Sounds worrying.

  1. Do you have any other setting turned ON in Configure -> Network (like "Use all available networks" or "Stall on network loss" or "Loopback" etc). If so: turn them OFF (those are OFF by default).
  2. Have you turned ON "Block connections without VPN" mode (from Android's VPN Settings) for Rethink? This is turned ON by default on Graphene, afaik.
  3. Does your Wifi have IPv4 connectivity? You can test this by excluding browser or Termux and testing if IPv4-only websites like github.com / ip4.me work.
  1. It behaves the same if Stall on network loss on/off. Use all available networks and Loopback was never turned on.
  2. Yes. I use RethinkDNS only with this mode as rethinkdns sometimes stops itself. All Battery opitimization turned off.
  3. Yes.

Edit:

Behaves the same if Shorter TCP keep alive and Idle timeout is turned on/off. Idle timeout was set at 2m.

anxiouslelimo avatar Aug 12 '25 11:08 anxiouslelimo

Okay. Genuinely worrying.

Can you see what you see in About -> Stats (it is towards the bottom half of the UI) in the "TUNStat" (appears in the top half) and "VPN Stats" (appears towards the bottom) sections when the Internet works versus when it doesn't? If you can't process what's shown, please share it here (you can remove addresses or email the output to me: mz at celzero dot com & if you do, please mention this bug in the subject).

ignoramous avatar Aug 12 '25 13:08 ignoramous

With IP Version set to IPV4

Internet Works

TUNStat
Open:true
Up:true
Mtu:1280
Sid:255
EpStats:Fd: 171
Alive: true
Age: 26s
R: 45.29kb
W: 542 bytes
LastRead: 4s
LastWrite: 4s
PcapMode:none

VPN Stats:
Builder:
  mtu: 1280
   has4: true
   has6: false
   noRoutes: false
   dnsMode? true
   firewallMode? true
   builderRoutes: (true, false)
   fd: 255
   dns: /76.76.2.2, /76.76.10.2
   setUnderlyingNws: null
   Underlay
      4: 1
      6: 0
      vpnRoutes: (false, false)
      useActive: true
      mtu: 1280
   Overlay
      4: false
      6: false
      mtu:2147483647
      determine4: true
      determine6: false
   Net ID
      4: [304]
      6: []
   Link Addresses
      4: 192.168.18.126
      6: N/A

No Internet

TUNStat
Open:true
Up:true
Mtu:1280
Sid:171
EpStats:Fd: 141
Alive: true
Age: 1m 26s
R: 544 bytes
W: 0 bytes
LastRead: 28s
LastWrite: 20312d 17h 15m 56s
PcapMode:none

VPN Stats:
Builder:
  mtu: 1280
   has4: true
   has6: false
   noRoutes: false
   dnsMode? true
   firewallMode? true
   builderRoutes: (true, false)
   fd: 171
   dns: /76.76.2.2, /76.76.10.2
   setUnderlyingNws: null
   Underlay
      4: 1
      6: 0
      vpnRoutes: (false, false)
      useActive: true
      mtu: 1280
   Overlay
      4: false
      6: false
      mtu:2147483647
      determine4: true
      determine6: false
   Net ID
      4: [307]
      6: []
   Link Addresses
      4: 192.168.18.126
      6: N/A

anxiouslelimo avatar Aug 12 '25 17:08 anxiouslelimo

All that looks pretty okay. Except...

LastWrite: 20312d 17h 15m 56s

Tells us there has been zero (network inbound) ingress packets (written into the tunnel) since ever (20312 days ago), which means, even if (need not be the case) there's egress (network outbound), ingress (network inbound) hasn't happened.

  1. Can you see if you can reproduce this issue in "Auto" mode with Perform connectivity checks turned OFF?
  2. If you're technical enough, when you do not have Internet connectivity, can you copy paste the output from adb shell ip rule (if you've access to adb)?
  3. Are you comfortable looking at app logs and/or sharing them over email? If so:
    • Go to Configure -> Settings -> App logs.
    • Click on the filter icon in the search box and set log level to "Very verbose".
    • Do steps that trigger the bug. Then perform recovery steps (setting Perform connectivity checks to "Auto").
    • Go to App logs, and pause log collection by changing log level to "None".
    • Use the search box to filter for "RethinkDnsVpn", then for "ConnectivityEvents", and see if you spot anything that stands out. These logs may be too heavy to parse.
    • You can also email them to me (mz at celzero dot com) and mention this GitHub issue in the subject and I'll take a look.

ignoramous avatar Aug 13 '25 17:08 ignoramous

Thanks for the logs.

Now, first I noticed when Choose IP Version is changed from IPV4 to Auto without restarting app, connectivity was fine but vice versa, connectivity was lost. So, on this assumption, I restarted the app and connectivity was fine. I tried toggling Choose IP Version again, but this time connectivity was lost both ways.

What Android version are you on? Are you on a custom ROM or stock?

We don't see this issue ourselves on stock ROMs (in our test Samsung / OnePlus / Nothing / Motorola / POCO / Xiaomi / Oppo / Vivo devices running Android 12 or above), but we've a theory on why this might be (the connectivity loss only when IPv4 is set as Choose IP version stumped us). We'll release v055q in a few hours from now, if our testing looks fine.

ignoramous avatar Aug 13 '25 21:08 ignoramous

@anxiouslelimo Will you please see if v055q fixes network loss on your Android: https://github.com/celzero/rethink-app/releases/tag/v0.5.5q It is bit of a guess work fix / workaround from app logs and bug repro steps (on your Android)... since we ourselves can't really reproduce what you were observing.

ignoramous avatar Aug 14 '25 00:08 ignoramous

@ignoramous Android 14 - Motorola. Highly debloated using App Manager. With 0.55q issue not reproduced.

anxiouslelimo avatar Aug 14 '25 04:08 anxiouslelimo

With 0.55q issue not reproduced.

Encouraging. Thanks!

Now everything thinks I'm offline, even on reinstall of the app. Had to downgrade.

@FlingCarnationProposal Can you pls see if v055q works + fixes the originally reported issue too (apps egressing over IPv6 even though there's only IPv4)? Note that v055q is also a pre-release and there may be other bugs.

ignoramous avatar Aug 14 '25 08:08 ignoramous

@ignoramous It happened again. Wifi toggled OFF for a few hours. Now setting 'Choose IP Version' to Auto and let me see after a few hours.

Here is the adb log
0:	from all lookup local 
10000:	from all fwmark 0xc0000/0xd0000 lookup 99 
11000:	from all iif lo oif dummy0 uidrange 0-0 lookup 1002 
11000:	from all iif lo oif wlan0 uidrange 0-0 lookup 1029 
11500:	from 192.168.18.127 lookup 1029 
11500:	from 192.168.18.130 lookup 1029 
11500:	from 192.168.18.131 lookup 1029 
12000:	from all iif tun0 lookup 97 
13000:	from all fwmark 0x0/0x20000 iif lo uidrange 0-10223 lookup 1102 
13000:	from all fwmark 0x0/0x20000 iif lo uidrange 10225-20223 lookup 1102 
13000:	from all fwmark 0x0/0x20000 iif lo uidrange 20225-99999 lookup 1102 
13000:	from all fwmark 0xc00b3/0xcffff lookup 1102 
14000:	from all fwmark 0x0/0x20000 iif lo uidrange 1-10223 prohibit
14000:	from all fwmark 0x0/0x20000 iif lo uidrange 10225-20223 prohibit
14000:	from all fwmark 0x0/0x20000 iif lo uidrange 20225-99999 prohibit
16000:	from all fwmark 0x10063/0x1ffff iif lo lookup 97 
16000:	from all fwmark 0x100b3/0x1ffff iif lo uidrange 0-10223 lookup 1102 
16000:	from all fwmark 0x100b3/0x1ffff iif lo uidrange 10225-20223 lookup 1102 
16000:	from all fwmark 0x100b3/0x1ffff iif lo uidrange 20225-99999 lookup 1102 
16000:	from all fwmark 0x100b3/0x1ffff iif lo uidrange 0-0 lookup 1102 
16000:	from all fwmark 0x100b4/0x1ffff iif lo lookup 1029 
17000:	from all iif lo oif dummy0 lookup 1002 
17000:	from all iif lo oif tun0 uidrange 0-10223 lookup 1102 
17000:	from all iif lo oif tun0 uidrange 10225-20223 lookup 1102 
17000:	from all iif lo oif tun0 uidrange 20225-99999 lookup 1102 
17000:	from all iif lo oif wlan0 lookup 1029 
18000:	from all fwmark 0x0/0x10000 lookup 99 
19000:	from all fwmark 0x0/0x10000 lookup 98 
20000:	from all fwmark 0x0/0x10000 lookup 97 
23000:	from all fwmark 0xb4/0x1ffff iif lo lookup 1029 
26000:	from all fwmark 0x0/0x10000 iif lo lookup 1000000029 
28000:	from all fwmark 0xb3/0xffff lookup 1029 
31000:	from all fwmark 0x0/0xffff iif lo lookup 1029 
32000:	from all unreachable

anxiouslelimo avatar Aug 14 '25 08:08 anxiouslelimo

Sigh. Was it a total network loss and nothing in Network or DNS logs? I presume you're using Rethink in VPN Lockdown mode ("Block connections without VPN") and have Configure -> Network -> Stall on network loss turned OFF?

It happened again ... Here is the adb log

Btw, this ip rule output has looked OK from your device (even before). Please share "TUNStat" and "VPN Stats" when it happens the next time.

ignoramous avatar Aug 14 '25 08:08 ignoramous

Configure_ -> Network -> Stall on network loss turned OFF?

@ignoramous Configure -> Network -> Stall on network loss turned ON,

anxiouslelimo avatar Aug 14 '25 09:08 anxiouslelimo

We can reproduce the issue you were seeing (Choose IP version set to IPv4) on an Android 11 device rather consistently. Unsure why it happens as Rethink is taking the steps we want it to... We'll keep looking.

ignoramous avatar Aug 14 '25 12:08 ignoramous

@FlingCarnationProposal Can you pls see if v055q works + fixes the originally reported issue too (apps egressing over IPv6 even though there's only IPv4)? Note that v055q is also a pre-release and there may be other bugs.

On initial install, everything seems to work fine. However, upon changing network from IPv4 to Auto, everything was offline again. After that, no changes I made got it to work again. Changing back to IPv4, changing censorship settings, re-adding VPN. Had to restore to last working version.

FlingCarnationProposal avatar Aug 16 '25 04:08 FlingCarnationProposal

@ignoramous For the last two days I had Choose IP Version set to to Auto and didn't encounter any issue. I was using WiFi the whole time. Today I had to switch to mobile data for a while and then back to WiFi (mobile data was still ON when I connected to WiFi again). I lost net connectivity. I changed Choose IP Version to IPV4 to no avail. STOP -> START the app a few times and yet no connectivity which actually surprised me. After Toggling ON and OFF Airplane Mode, I got back connectivity.

anxiouslelimo avatar Aug 16 '25 15:08 anxiouslelimo

Current version (v0.5.5t) seems to have fixed connectivity issues. Some apps complain when switching networks, but they quickly reconnect. Will see if issue persists and if original issue is fixed over the week.

FlingCarnationProposal avatar Aug 23 '25 07:08 FlingCarnationProposal

Latest version seems to solve these issues. Hardly noticed any. Great update otherwise too.

anxiouslelimo avatar Aug 23 '25 14:08 anxiouslelimo

Thanks for confirming. Closing... Feel free to ask to reopen in case it happens again on v055t.

(I've deleted a comment or two given sensitive information in it).

ignoramous avatar Aug 23 '25 21:08 ignoramous

I am currently on an IPv6 enabled network, so I can't reproduce the exact environment the original issue appeared in. However, switching to IPv4 in the app seems to cease IPv6 connections from happening. I think it might be fixed. I'll report back if it appears on the original network.

Thank you for your hard work and dedication!

FlingCarnationProposal avatar Aug 24 '25 12:08 FlingCarnationProposal