简体   繁体   中英

Python3 Wrong IP Address Detection?

Reading this:

How do you determine if an IP address is private, in Python?

I wrote:

>>> import ipaddress
>>> ipaddress.ip_address('172.23.86.32').is_private
True

But that's not correct, this is a public IP address... how to fix this?

Your program is actually correct, 172.23.86.32 is a private IP address. Just check https://www.whatismyip.com/ or a similar service and you will see a different address (and that's your public address).

See this wiki entry on IPv4 private network addresses: https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM