https://github.com/tes3awy/subnetting
Advanced IPv4 Subnet Calculator in Python3
https://github.com/tes3awy/subnetting
automation csv excel jinja2 jinja2-templates precommit-hooks python python3 subnet subnet-calculator subnetting-ipv4-addresses
Last synced: about 2 months ago
JSON representation
Advanced IPv4 Subnet Calculator in Python3
- Host: GitHub
- URL: https://github.com/tes3awy/subnetting
- Owner: Tes3awy
- License: mit
- Created: 2021-06-09T20:52:21.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-20T16:08:37.000Z (about 3 years ago)
- Last Synced: 2025-04-06T14:12:50.301Z (3 months ago)
- Topics: automation, csv, excel, jinja2, jinja2-templates, precommit-hooks, python, python3, subnet, subnet-calculator, subnetting-ipv4-addresses
- Language: Python
- Homepage:
- Size: 272 KB
- Stars: 1
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.python.org/downloads)
[](https://github.com/Tes3awy/subnetting)
[](https://github.com/Tes3awy/subnetting/graphs/contributors)
[](https://github.com/Tes3awy/subnetting/releases)
[](https://github.com/Tes3awy/subnetting/commits/main)


[](https://github.com/Tes3awy/subnetting/stargazers)
[](https://github.com/Tes3awy/subnetting/network/members)
[](https://github.com/Tes3awy/subnetting/issues)
[](https://github.com/Tes3awy/subnetting/pulls?q=is%3Apr+is%3Aclosed)
[](https://github.com/Tes3awy/subnetting/blob/main/LICENSE)
[](https://github.com/psf/black)
[](https://pycqa.github.io/isort/)
[](https://github.com/pre-commit/pre-commit)# Advanced IPv4 Subnet Calculator in Python3
## Table of Contents
1. [Getting Started](#getting-started)
2. [Installation](#installation)
3. [How it works?](#how-it-works)
4. [SVI Configuration Template](#svi-configuration-template)
5. [Previews](#previews)### Getting Started
```bash
│ 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-template.png
svi.png
```---
### Installation
```bash
$ git clone https://github.com/Tes3awy/subnetting.git
$ cd subnetting
$ pip install -r requirements.txt --user
```**OR**
1. Download the latest release from [Releases](https://github.com/Tes3awy/subnetting/releases/).
2. Extract `subnetting.zip` file.
3. `cd` into `subnetting` directory.
4. Run `path_to\subnetting> pip install -r requirements.txt --user` in terminal.---
### How it works?
**Windows**
```powershell
path_to\subnetting> python main.py
```**macOS or Unix**
```bash
$ python3 main.py
```You will be prompted to enter the name of the CSV file containing input subnets, the gateway, a name for the Excel file to be created. _(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, B, and C)_.
```bash
- CSV file [subnets.csv]:
- The gateway, first or last IP Address [0/1] [0]:
- Excel file to create [New-Schema.xlsx]:
```Voila :sparkles: You have an Excel file that includes all required data about each subnet.
```bash
Please check New-Schema_.xlsx in current working directory.
```> **Default behaviors:**
> 1. CIDR notation with no prefix length will be handled as /32.
- For example, if you enter `10.0.0.1` without a prefix length in the CSV file, the script will handle it like `10.0.0.1/32`.> 2. The header line **`Subnets in CIDR Notation`** within the `subnets.csv` file is automatically skipped. So, there is no need to manually remove it.
> 3. The 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.
---
### SVI Configuration Template
Finally, if you have a L3 switch and you want to create [SVI interfaces](https://en.wikipedia.org/wiki/Switch_virtual_interface) of the created subnets on that switch, you can run:
```bash
$ python parse_excel.py --file .xlsx
```This Python script will generate a configuration file that includes 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 `parse_excel.py` script. _Otherwise, VLAN ID and VLAN Name will be NaN_ in the generated configuration file.
---
### Previews
**Terminal**

_Elapsed time is about 9 seconds in here because a CIDR notation like 10.0.0.0/8 is a little bit extensive to process._**CSV File (Input File)**
**Excel File (Output File)**
**python parse_excel.py -f .xlsx**
**SVI Template**
