subnetting
Advanced IPv4 Subnet Calculator in Python3.
Getting Started
│ main.py
│ read_subnets.py
│ subnetting.py
│ export_subnets.py
│ parse_excel.py
│ svi_generator.py
│ svi.j2
│ subnets.csv
│ requirements.txt
│ README.md
│ .pre-commit-config.yaml
│ .gitignore
│ LICENSE
│
└───assets
preview.png
subnets-csv.png
subnetting-cli.png
svi.png
Installation
$ git clone https://github.com/Tes3awy/subnetting.git
$ cd subnetting
$ pip install -r requirements.txt --user
OR
- Download latest release from Releases.
- Extract
subnetting-<ver>.zip
file. cd
intosubnetting-<ver>
directory.- Run
path_to\subnetting-<ver>> pip install -r requirements.txt --user
in terminal.
How it works?
Windows
path_to\subnetting> python main.py
macOS or Linux
$ python3 main.py
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:
- CIDR notation with no prefix length will be handled as /32.
- For example, if you enter10.0.0.0
without a prefix length in the CSV file, the script will handle it like10.0.0.0/32
.
- The header line
Subnets in CIDR Notation
within thesubnets.csv
file is automatically skipped. So, there is no need to manually remove it.
- 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.
- 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 parse_excel.py --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.
Previews
Terminal
CSV File (Input File)
Excel File (Output File)
SVI Template