How can I know an IP is a public IP or not?

发布时间 2023-03-28 14:52:07作者: ChuckLu

How can I know an IP is a public IP or not?

To determine whether an IP address is public or private, you can compare it to a list of private IP address ranges specified in RFC 1918. If the IP address falls within one of these ranges, it is a private IP address and not accessible from the internet:

  • 10.0.0.0 - 10.255.255.255 (10/8 prefix)
  • 172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
  • 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)

If the IP address does not fall within one of these ranges, it is a public IP address and is accessible from the internet. Note that there are some special IP address ranges that are reserved for other purposes, such as loopback addresses (127.0.0.0/8) and link-local addresses (169.254.0.0/16), but these should not be used for public internet communication.