GithubHelp home page GithubHelp logo

tes3awy / subnetting Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 4.0 279 KB

Advanced IPv4 Subnet Calculator in Python3

License: MIT License

Python 94.07% Jinja 5.93%
subnetting-ipv4-addresses python3 python subnet-calculator subnet precommit-hooks automation excel csv jinja2

subnetting's Introduction

Tested on Python 3.7+ Code Size Contributors Release Date Commit Activity Languages Count Top Language Stars Forks Open Issues Closed PR License Code style: black Imports: isort Pre-Commit

Advanced IPv4 Subnet Calculator in Python3

Table of Contents

  1. Getting Started
  2. Installation
  3. How it works?
  4. SVI Configuration Template
  5. Previews

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-template.png
        svi.png

Installation

$ git clone https://github.com/Tes3awy/subnetting.git
$ cd subnetting
$ pip install -r requirements.txt --user

OR

  1. Download the latest release from 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

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:

  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.
  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. 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 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.


Previews

Terminal Python CLI 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) CSV File

Excel File (Output File) Excel Preview

python parse_excel.py -f <EXCEL_FILE_NAME>.xlsx SVI CLI

SVI Template SVI Template

subnetting's People

Contributors

tes3awy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.