Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if IPv4 address is in private range

In Python, using the IPy module you can do the following:

 >>> ip.iptype()
'PRIVATE'

Is there a library or easy way to do the equivalent in Java?

like image 943
stevebot Avatar asked Nov 15 '11 18:11

stevebot


People also ask

How do you tell if an IPv4 address is public or private?

To check if your IP address is public, you can use myip.com (or any similar service). You will be shown the IP address that was used for accessing the site; and if it matches the IP address that your Internet service provider assigned you, then you have a public IP address.

How do I know if my IP address is private?

Windows. Search for cmd in the Windows search bar, then in the command line prompt, type ipconfig to view the private IP address. Mac. Select system preferences, then click on network to view the private IP address.

Is 192.168 1.0 a private or public address?

Conclusion. 192.168. 1.0 is a private IP address used by many broadband routers to identify themselves to other devices on the same network. This IP address is not unique, any multiple routers can share it without any issues.


1 Answers

It seems that not exactly but InetAddress has some isXX() methods like: isAnyLocalAddress() and isSiteLocalAddress()

like image 57
AlexR Avatar answered Sep 20 '22 06:09

AlexR