Skip to main content

IP Address Pool

Description

This is a tool to generate a list of IP addresses and track which ones are used. For example, tooling that generates VPN profiles can request a new address, and this will hand out the next available one and make a note of it. When an address is no longer required, it can be returned to the pool.

Currently only supports IPv4.

Installation

$ pip3 install [--user] ip-pool

Example Usage

Usage:

$ ip-pool --help
usage: ip-pool [-h] [--initialize CIDR_ADDRESS] [--new-address HOSTNAME] [--release-address HOSTNAME]
               [--address-for HOSTNAME]
               pool_db_json

positional arguments:
  pool_db_json          Path to IP pool database json file

optional arguments:
  -h, --help            show this help message and exit
  --initialize CIDR_ADDRESS
                        Initialize IP pool with the provided CIDR address/netmask
  --new-address HOSTNAME
                        Allocate next unused address to HOSTNAME
  --release-address HOSTNAME
                        Release address for HOSTNAME and return it to the pool
  --address-for HOSTNAME
                        Print address for HOSTNAME

The following will initialize a new IP address pool, but not allocate any addresses:

$ ip-pool ./pool.json --initialize "192.168.8.1/24"
$ cat pool.json
{
  "ip_version": 4,
  "network": "192.168.8.0/24",
  "hostnames": {}
}

Request a new address for hostname (or other identifier) server_1:

$ ip-pool ./pool.json --new-address server_1
192.168.8.1/24

Return a new address for hostname server_1:

$ ip-pool ./pool.json --release-address server_1

Reassign an address from host_2 to host_3:

$  ip-pool ./pool.json --release-address host_2 --new-address host_3
192.168.8.2/24

Get the address for host_3:

$ ip-pool pool.json --address-for host_3
192.168.8.2/24

List all addresses and their identifiers in use:

 $ ip-pool pool.json --list-used
host_1: 192.168.8.1/24
host_3: 192.168.8.2/24

Download files

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

Source Distribution

ip-pool-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file ip-pool-0.1.0.tar.gz.

File metadata

  • Download URL: ip-pool-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.6.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.7

File hashes

Hashes for ip-pool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 16b9a1be1e6aeb9fa3f5d2098f3b194bda3521a43f7a9c6c049f309eccea877e
MD5 4369abfa7b3839545565e040fcbbbc52
BLAKE2b-256 967d1430e37a8f4f06aa8ce2f9232653edc1865f26e9ef002c9c06ff88837fed

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page