This is an odd one… NetIP uses icanhazip.com to obtain the computer’s public IP.
It specifically uses ipv4.icanhazip.com and ipv6.icanhazip.com to respectively get the IPv4 and IPv6. It shouldn’t be able to output v4 instead of v6 and vice versa.
Could you check what these links return in a web browser to see if they have the same issue?
After searching a bit, I found these old issues on the icanhazip archive repo that could be related to your issue:
icanhazip is owned & maintained by Cloudflare since 2021 (blog post annoucement). I don’t know what Cloudflare did on the code since then, and I can’t reproduce the error on my end, unfortunately.
I see 3 possible fixes:
Check the format of the string returned by the request. If it contains dots . where we expected IPv6 or if it contains : where we expected IPv4, don’t display the incorrect value. It’s an easy regex fix that could do the job.
Force each HttpClient request to use respectively IPv4 or IPv6. (Example). Not sure if it’ll help if the provider is returning the incorrect the value anyway.
Customize Public IP Providers. It’s a planned feature that would mitigate the issue if icanhazip is struggling to return the correct public ip.
Today I can’t reproduce the bug, the browser returns the correct ip, and NetIP returns the correct ip in the appropriate position no matter how many times I refresh. So, that makes me think that is an API issue? According to the forum posts it is quite sporadic…
Yep, it confirms what I thought. The problem is probably on the icanhazip side. I’m validating this issue nonetheless to implement the two first fixes I suggested earlier. It will be fixed for v0.2.0. Customized Public IP Providers will come in another next patch.