bpennypacker / phad

Pi-Hole Alternate Display
GNU General Public License v3.0
75 stars 8 forks source link

Public IPv4 not correct #22

Open combro2k opened 3 years ago

combro2k commented 3 years ago

Hi,

I run dualstack it shows me my ipv6 address instead of ipv4. I will check it later what happens :-)

combro2k commented 3 years ago

https://github.com/bpennypacker/phad/blob/2feb4d1a636ea742b9cfe90b9fb3b39bf04b21e3/templates/network.j2#L9

In here there is no 'sanity' check if the public_ip is an ipv4 ip or ipv6 The link https://diagnostic.opendns.com/myip resolves ipv6 too.

combro2k commented 3 years ago

It sems not be that easy to fix I see in the library many people can't force 'requests' to use ipv4 or ipv6 only to distinct the different lookups.

bpennypacker commented 3 years ago

Thanks for the detailed information. I'll look into this as soon as I can.

bpennypacker commented 3 years ago

The public IP is determined by querying one of the following URLs to see what is returned. This is an entry in your phad.conf fle:

external_ip_url=https://diagnostic.opendns.com/myip,https://www.myexternalip.com/raw,http://ipv4bot.whatismyipaddress.com

PHAD queries the list in order until one returns a valid result. It looks like that first URL, https://diagnostic.opendns.com/myip, is also dual-stack, so when PHAD queries it from a dual-stack environment like yours it's hitting it over IPv6, so it's returning that address.

The easiest fix in this case is likely to just change phad.conf to use http://ipv4bot.whatismyipaddress.com as the external_ip_url which should always return the IPv4 public IP.

combro2k commented 3 years ago

This is more what I meant that time :-) https://github.com/HorlogeSkynet/archey4/blob/3e008fd0b1b6fdd714823f441e51c6bc70d4ee3d/archey/entries/wan_ip.py#L32 So if you have a dual stack setup you can see both IP's