netaddr is a Python library for representing and manipulating network addresses.
Installing netaddr library:
Use any of following command to install netaddr library
$ sudo pip install netaddr or $ easy_install netaddr
Observe following example for more details:
>>> from netaddr import * >>> IPAddress('74.125.236.194').is_private() False >>> IPAddress('192.168.1.10').is_private() True >>> IPAddress('127.0.0.1').is_loopback() True
IPAddress(‘input ip’).is_private() will return true if the input ip address private, else it will return false.
Reference: Netaddr