w2sv / WiFi-Widget

Android app providing a fully configurable widget for the monitoring of your WiFi connection details.
https://play.google.com/store/apps/details?id=com.w2sv.wifiwidget
GNU General Public License v3.0
154 stars 7 forks source link

[Feature Request] List IPv6 Gateway and DNS information #131

Open GoetzGoerisch opened 2 months ago

GoetzGoerisch commented 2 months ago

Overview

Currently the WiFi-Widget only lists the DNS, DHCP and Gateway information for IPv4. Please also display and make it configurable for IPv6.

w2sv commented 2 months ago

Well there's no API for retrieving those addresses as IPv6s AFAIK, and I suppose just converting them from their IPv4 versions wouldn't be of much use, or am I wrong?

GoetzGoerisch commented 2 months ago

Not deep into Kotlin and Android, but shouldn't https://developer.android.com/reference/android/net/LinkProperties#getDnsServers() and https://developer.android.com/reference/android/net/LinkProperties#getRoutes() return the necessary information? BTW this would also be nice: https://developer.android.com/reference/android/net/LinkProperties#getNat64Prefix()

w2sv commented 1 month ago

The InetAddresses returned by https://developer.android.com/reference/android/net/LinkProperties#getDnsServers() only contain the IPv4 host addresses. https://developer.android.com/reference/android/net/LinkProperties#getRoutes() on the other hand returns various routes and addresses, which I, however, don't really know how to interpret. The class documentation at https://developer.android.com/reference/android/net/RouteInfo doesn't help me much either.

The RouteInfo instances it returns on my network contains the following information:

interface: wlan0 | gateway: /fe80::f1db:c284:67f6:e8d2 | destination: ::/0 | isDefaultRoute: true
interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:5207::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::f669:42ff:fea7:a73 | destination: ::/0 | isDefaultRoute: true
interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:78f3::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::7df4:c55f:14b4:7dc3 | destination: ::/0 | isDefaultRoute: true
interface: wlan0 | gateway: /0.0.0.0 | destination: 192.168.1.0/24 | isDefaultRoute: false
interface: wlan0 | gateway: /192.168.1.1 | destination: 0.0.0.0/0 | isDefaultRoute: true

192.168.1.1 is also my gateway, DNS and DHCP address shown on the widget, other than that none of those addresses is a duplicate of one featured by the widget.

Can you infer how to interpret them?

w2sv commented 1 month ago

The nat64Prefix I can definitely add, I created a separate issue for that @ https://github.com/w2sv/WiFi-Widget/issues/144.

GoetzGoerisch commented 1 month ago

Default route IPv6

interface: wlan0 | gateway: /fe80::f1db:c284:67f6:e8d2 | destination: ::/0 | isDefaultRoute: true

Default route IPv6 for prefix 2a02:3032:2e0:5207::/64

interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:5207::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::f669:42ff:fea7:a73 | destination: ::/0 | isDefaultRoute: true

Default route IPv6 for prefix 2a02:3032:2e0:78f3::/64

interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:78f3::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::7df4:c55f:14b4:7dc3 | destination: ::/0 | isDefaultRoute: true

Default route IPv4:

interface: wlan0 | gateway: /0.0.0.0 | destination: 192.168.1.0/24 | isDefaultRoute: false
interface: wlan0 | gateway: /192.168.1.1 | destination: 0.0.0.0/0 | isDefaultRoute: true
w2sv commented 1 month ago

So these aren't DHCP or DNS addresses but an entirely separate property?

w2sv commented 1 month ago

Also, how can you tell that

interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:5207::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::f669:42ff:fea7:a73 | destination: ::/0 | isDefaultRoute: true

And

interface: wlan0 | gateway: /:: | destination: 2a02:3032:2e0:78f3::/64 | isDefaultRoute: false
interface: wlan0 | gateway: /fe80::7df4:c55f:14b4:7dc3 | destination: ::/0 | isDefaultRoute: true

respectively belong together, just by their order of appearance? I'm not too much of a networking expert, as I guess isn't hard to spot.

GoetzGoerisch commented 1 month ago

their belonging together was only based on the order of apperance. On a normal linux host more information is given. You have 2 prefixes assigned, probably due to the dynamic assignment by o2 every 24h. One link-local address is derived from the interface MAC address, the others are random generated. I would need to know more about the network and the setup to properly figure this out.

w2sv commented 1 month ago

Okay, so they actually don't have anything to do with the original issue subject. Do you think adding them to the displayable widget properties under the name "Route" would be of value anyways?

GoetzGoerisch commented 1 month ago

Basically your device has more than one IPv6 Gateway configured. So this part matched the issue title. Nevertheless, there seam to be no obvious API to get the IPv6 DNS information, if I understood you and the documentation correctly?

thomasschaeferm commented 1 month ago

Just for information:

Gateway 0.0.0.0
DNS     0.0.0.0
DHCP    0.0.0.0

is definitely not correct, if there isn't ipv4 at wifi interface at all. The properties Gateway, DNS, DHCP should be hidden then. Or 0.0.0.0 should be replaced by something representing nothing/empty .

At the moment the app shows the correct public ipv4 ip(*). The local ipv4 address (clat, usually 192.0.0.2) is only visible in system "about phone". DNS (IPv6!) is correctly shown in wifi connection settings, but not in that app.

Strictly speaking - clat is an extra interface. It appears, when uplink (wifi or cellular) provides nat64.

* under some circumstances you can have two different public ipv4 addresses. (one via clat interface and one directly via NAT64, but that configuration is a rarity on plat side)