│ 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
$ git clone https://github.com/Tes3awy/subnetting.git
$ cd subnetting
$ pip install -r requirements.txt --user
OR
- Download the latest release from Releases.
- Extract
subnetting.zip
file. cd
intosubnetting
directory.- Run
path_to\subnetting> pip install -r requirements.txt --user
in terminal.
Windows
path_to\subnetting> python main.py
macOS or Unix
$ 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).
- CSV file [subnets.csv]:
- The gateway, first or last IP Address [0/1] [0]:
- Excel file to create [New-Schema.xlsx]:
Voila ✨ You have an Excel file that includes all required data about each subnet.
Please check New-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.1
without a prefix length in the CSV file, the script will handle it like10.0.0.1/32
.
- The header line
Subnets in CIDR Notation
within thesubnets.csv
file is automatically skipped. So, there is no need to manually remove it.
- 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.
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 <EXCEL_FILE_NAME>.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.
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.