Skip to content

Calculate if an IPv4 CIDR overlaps with an existing Azure VNet

Notifications You must be signed in to change notification settings

Timothy-Pulliam/Azure_CIDR_Overlap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Setup

az login
git clone https://github.com/Timothy-Pulliam/Azure_CIDR_Overlap.git
cd Azure_CIDR_Overlap
python3 -m venv venv
. venv/bin/activate
pip install -U pip
pip install -r requirements.txt

Usage

The script will pull all VNets from all Subscriptions (that the user has access to) using an Azure Resource Graph Explorer query.

Pass an IPv4 CIDR as a positional argument. No output indicates the provided CIDR does not overlap with any existing VNets.

$ ./net_overlap.py '12.34.56.78/16'
$

If the CIDR does overlap, it will list the overlapping VNets

$ ./net_overlap.py '10.0.0.0/16'
10.0.0.0/16 overlaps {'name': 'vnet-myapp-dev-1', 'addressSpace': ['10.0.0.0/16']}

Optionally, run in verbose mode

$ ./net_overlap.py '10.2.0.0/16' --verbose
Found 1 subscriptions

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Found 2 VNets

[{'addressSpace': ['10.0.0.0/16'], 'name': 'vnet-myapp-dev-1'},
 {'addressSpace': ['10.1.0.0/16', '10.2.0.0/16'], 'name': 'vnet-myapp-dev-2'}]

10.2.0.0/16 overlaps {'name': 'vnet-myapp-dev-2', 'addressSpace': ['10.1.0.0/16', '10.2.0.0/16']}

About

Calculate if an IPv4 CIDR overlaps with an existing Azure VNet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages