Skip to content

Subnetron is a command-line utility written in Go that provides fast and reliable IPv4 subnet analysis.

License

Notifications You must be signed in to change notification settings

lenardjombo/Subnetron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Subnetron

Subnetron is a high-performance subnet calculator built in Go.
It validates IP addresses and CIDR notations, generates subnet masks, computes network and broadcast addresses, determines usable IP ranges and calculates host availability — all with comprehensive unit test coverage to ensure correctness and reliability.


Features

  • IP Address Validation – Rejects invalid or reserved addresses.
  • CIDR Validation – Supports the full IPv4 range (/0–/32).
  • Subnet Mask Generation – Derives masks directly from CIDR values.
  • Network Address Calculation – Computes the base network address via bitwise operations.
  • Broadcast Address Calculation – Identifies the last address in a subnet.
  • Usable IP Range – Determines the first and last usable hosts.
  • Host Capacity – Calculates available host addresses per subnet.
  • Unit Tested – All core functions validated using Go’s testing framework.

Installation

Option 1: Download Prebuilt Binary

  1. Go to the Releases page.
  2. Download the binary for your platform (Linux, macOS, or Windows).
  3. Make it executable (Linux/macOS):
   chmod +x subnetron

    Run the tool:

    ./subnetron -ip 192.168.1.10 -cidr 24 

Option 2: Build from Source

Make sure you have Go installed.

    git clone https://github.com/lenardjombo/subnetron.git
    cd subnetron
    go build -o subnetron main.go
    ./subnetron -ip 192.168.1.10 -cidr 24

Why This Project Matters

Subnetting is a foundational skill in networking, system administration and cybersecurity. Misconfigurations in subnetting often lead to:

  • Inefficient IP allocation and wasted address space
  • Increased routing complexity
  • Security vulnerabilities from improper segmentation

Subnetron automates subnet calculations, reducing human error and providing:

  • Network Engineers → Faster IP planning and allocation
  • Security Analysts → Reliable tools for auditing segmentation
  • Students & Learners → A hands-on way to master IP addressing

How Subnetron Performs Its Calculations

Subnetron leverages CIDR arithmetic and bitwise operations to compute subnet details.

Example: 192.168.1.10/24

  • CIDR → Subnet Mask

    • /24 means 24 network bits, 8 host bits
    • Subnet mask → 255.255.255.0
  • Network Address

192.168.1.10 AND 255.255.255.0 = 192.168.1.0

  • Broadcast Address

Invert mask, OR with network = 192.168.1.255

  • Usable Range

  • First usable → 192.168.1.1

  • Last usable → 192.168.1.254

  • Host Capacity

2^(32-24) - 2 = 254 usable hosts

Sample outputs : tests


Testing Strategy

Subnetron includes unit tests for every core function, ensuring accuracy and preventing regressions.
Coverage includes:
Sample tests : tests

  • CIDR validation (0 ≤ CIDR ≤ 32)
  • IP validation (rejects invalid/reserved addresses)
  • Subnet mask generation for multiple CIDR values
  • Network & broadcast address derivation
  • Usable IP range correctness
  • Host count verification

Technical Highlights

  • Written in Go for performance and reliability
  • Uses Go’s net and math standard libraries
  • Structured with modular, testable functions
  • Implements defensive programming practices

Next Steps

  • Extend support for IPv6 subnetting
  • Build a CLI tool for system administrators
  • Add a web-based UI for educational and visualization purposes

Project Status

  • Completed core functionality
  • Comprehensive testing included
  • Planned feature expansions (IPv6, CLI, Web UI)

License

This project is released under the MIT License.


About

Subnetron is a command-line utility written in Go that provides fast and reliable IPv4 subnet analysis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages