Advanced IPv4 Subnet Calculator in Python3.

Getting Started

│   svi.j2
│   subnets.csv
│   requirements.txt
│   .pre-commit-config.yaml
│   .gitignore


$ git clone
$ cd subnetting
$ pip install -r requirements.txt --user


  1. Download latest release from Releases.
  2. Extract subnetting-<ver>.zip file.
  3. cd into subnetting-<ver> directory.
  4. Run path_to\subnetting-<ver>> pip install -r requirements.txt --user in terminal.

How it works?


path_to\subnetting> python

macOS or Linux

$ python3

You will be prompted to enter the name of the CSV file containing input subnets, the gateway IP address, a name for the Excel file to be created, and the name of the sheet within the Excel file that will hold all subnetting data. (All inputs have default values).

A subnets.csv file can be found in the repo. This file is an entry point to get started using this program. It's prepopulated with three different subnets. (Class A, Class B, and Class C).

- CSV file w/ extension? [Defaults to subnets.csv]:
- Gateway first or last IP Address? [0/1] [Defaults to 0]:
- Excel file w/o extension? [Defaults to IP-Schema]: Test-Schema
- Worksheet name? [Defaults to IP Schema Worksheet]: Test Worksheet
  • Abbreviations:
    - w/: With
    - w/o: Without

Voila :sparkles: You have an Excel file that includes all required data about each subnet.

Please check Test-Schema_<TODAYS_DATE>.xlsx in current working directory.

Default behaviors:

  1. CIDR notation with no prefix length will be handled as /32.
    - For example, if you enter without a prefix length in the CSV file, the script will handle it like
  1. The header line Subnets in CIDR Notation within the subnets.csv file is automatically skipped. So, there is no need to manually remove it.
  1. Gateway input accepts 0 or 1 ONLY [Defaults to 0]. 0 picks the first IP address of the subnet, while 1 picks the last IP address.
  1. Microsoft Excel does not allow worksheet name longer than 31 characters. Worksheet names longer than 31 chars will be truncated.

SVI Configuration Template

Finally, if you have a L3 switch and you want to create SVI interfaces of the created subnets on that switch, you can run:

$ python --file Test-Schema-<TODAYS_DATE>.xlsx

This Python script will generate a text file including all VLANs and their SVI interfaces.

NOTE: Make sure you add the VLAN ID and VLAN Name in all the cells in the generated Excel file before running this script. Otherwise, VLAN ID and VLAN Name will be NaN in the generated text file.



CSV File (Input File)

Excel File (Output File)

SVI Template