Skip to main content

IP Tools

Project description

I have written my own python ip/subnet tool. It works in both python 2 and 3. It does not have dependencies except standard ‘re’ module.

Use theese methods to conver ip mask formats and to check if ip/subnet belong to other subnet. I made it partly for fun and to learn, so perhaps these are not the best, but they get the job done. Checking if ip belongs to subnet is even a bit faster, than with tools from netaddr module.

Methods provided: - is_in_subnet : check if ip belongs to subnet - is_in_range : check if ip belongs to ip range - verify : check if ip or ip/netmask are valid - get_subnet_ip : get subnet ip for some ip/mask - mask255_to_dec : convert ip mask format - dec_to_mask255 : convert ip mask format - is_mask : check if ip mask is real


pip install iptoolsjj


import iptoolsjj


Check if is inside

print(iptoolsjj.is_in_subnet(‘’, ‘’))

Check if is between and


Verify if ip or ip with mask is valid:

print(iptoolsjj.verify(‘’)) print(iptoolsjj.verify(‘’,’ip/mask’)) print(iptoolsjj.verify(‘’,’ip/mask255’))

Get subnet ip for given ip address:


Convert mask ‘’ to ‘28’:


Convert mask ‘28’ to ‘[‘255’, ‘255’, ‘255’, ‘240’]’ (by default it’s list format):




Check if mask is real mask in format


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for iptoolsjj, version 1.4.2
Filename, size File type Python version Upload date Hashes
Filename, size iptoolsjj-1.4.2-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size iptoolsjj-1.4.2.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page