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
Instalation:
pip install iptoolsjj
Import:
import iptoolsjj
Examples:
Check if 192.168.10.10 is inside 192.168.10.0/22:
print(iptoolsjj.is_in_subnet(‘192.168.10.10’, ‘192.168.10.0/22’))
Check if 192.168.51.1 is between 192.168.50.100 and 192.168.60.50:
print(iptoolsjj.is_in_range(‘192.168.50.100’,’192.168.60.50’,’192.168.51.1’))
Verify if ip or ip with mask is valid:
print(iptoolsjj.verify(‘192.168.1.22’)) print(iptoolsjj.verify(‘192.168.1.22/25’,’ip/mask’)) print(iptoolsjj.verify(‘192.168.1.22/255.255.255.128’,’ip/mask255’))
Get subnet ip for given ip address:
print(iptoolsjj.get_subnet_ip(‘191.123.1.36/27’))
Convert mask ‘255.255.255.240’ to ‘28’:
print(iptoolsjj.mask255_to_dec(‘255.255.255.240’))
Convert mask ‘28’ to ‘[‘255’, ‘255’, ‘255’, ‘240’]’ (by default it’s list format):
print(iptoolsjj.dec_to_mask255(28))
or
print(iptoolsjj.dec_to_mask255(28,output=’string’))
Check if mask is real mask in format xxx.xxx.xxx.xxx:
print(is_mask(“255.255.255.0”))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file iptoolsjj-1.4.2.tar.gz
.
File metadata
- Download URL: iptoolsjj-1.4.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 884522782d84065ac662d68e539c522872760268a8b5b269c3afc3388ba9d138 |
|
MD5 | 9c1fdc8e1f99ff37c181d612ae11e512 |
|
BLAKE2b-256 | 1e82bdcd2a179e435e316662a17dea09c8326925c46ddf9368728743ee2757ab |
File details
Details for the file iptoolsjj-1.4.2-py3-none-any.whl
.
File metadata
- Download URL: iptoolsjj-1.4.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db372cfb6cc598534f2408ddfaca061cb9c9ab2fc062677380f9dafaf6d95af |
|
MD5 | 9fd06d246f3eedc7c4fc26c9c7cacc78 |
|
BLAKE2b-256 | 5f43e08de625b93c3f04b802a10595605b69b37eb6bafa5bc261a8774c0e1a47 |