Skip to main content

Count usable IPv4 hosts across CIDR subnets and individual IP addresses.

Project description

SubnetHostCount

Simple python to count hosts in a list of subnets and ip addresses

CIDR Host Counter

This script reads a file containing IPv4 CIDR notations or individual IP addresses and calculates the total number of valid hosts. It excludes network and broadcast addresses for subnets, but counts single IPs (e.g., 10.0.0.5) as one valid host.

Features

  • Accepts a file containing:
    • IPv4 CIDR ranges (e.g., 192.168.1.0/24)
    • Individual IP addresses (e.g., 10.0.0.5)
  • Excludes network and broadcast addresses from the host count
  • Ignores empty lines and lines starting with #
  • Warns about invalid lines with a descriptive message
  • Identifies duplicates (-D to list hosts appearing in multiple files)
  • Calculates RFC1918 private vs public host counts (-r)

Usage

Prerequisites

Python 3.6+

Command

python HostCount.py -d path/to/cidrs.txt

or

subnethostcount -d path/to/cidrs.txt

Optional flags:

  • -D, --duplicates
    When processing a directory, list hosts that appear in more than one file and which files they appear in.

  • -r, --rfc1918
    Show how many hosts are in RFC1918 private address space vs how many are not (prints per-file and totals).

Project details


Download files

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

Source Distribution

subnethostcount-0.1.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subnethostcount-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file subnethostcount-0.1.5.tar.gz.

File metadata

  • Download URL: subnethostcount-0.1.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for subnethostcount-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c5e93c51007943b5f8a2cd2af6069fbdc9086b2b0edf149db52aacba987245e7
MD5 72a77b3e8242c9ec28f05eb4e5448671
BLAKE2b-256 0a3483635c3aa1bed456fe40e3048a97d8e3bde825492a6bc8fa9e802fbd3f08

See more details on using hashes here.

File details

Details for the file subnethostcount-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for subnethostcount-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 62ebe9c491fd3ab28509e18bd8ea3a0e5bbadba06a7af008673c487cfa9fd405
MD5 9fd591dbaf9283e95e1a37980fdf0e51
BLAKE2b-256 12c90951055c63355c2ff649b1f4a9365afbea35b8217d1addaedb3246651775

See more details on using hashes here.

Supported by

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