implementation of recursive subnet (re-)seller algorithm in PowerShell
  • PowerShell 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dawid Ciepiela 732c4f93ef
Merge pull request #2 from sarumaj/tech-stack-file
Create tech stack docs (techstack.yml and techstack.md)
2024-03-07 18:54:29 +01:00
.github Create FUNDING.yml 2024-01-22 20:57:43 +01:00
.vscode prettify README 2023-11-10 08:58:56 +00:00
plantuml prettify README 2023-11-10 08:58:56 +00:00
psmod_subnet_seller Update psmod_subnet_seller.psd1 2024-01-12 08:12:34 +01:00
install.ps1 init 2023-11-10 07:33:07 +00:00
LICENSE Initial commit 2023-11-10 08:13:12 +01:00
MAINTAINERS.md init 2023-11-10 07:33:07 +00:00
README.md Update README.md 2023-11-10 10:14:07 +01:00
renovate.json init 2023-11-10 07:33:07 +00:00
techstack.md Create techstack.md 2024-03-07 17:30:47 +00:00
techstack.yml Update techstack.yml 2024-03-07 17:53:08 +00:00
test.ps1 prettify README 2023-11-10 08:58:56 +00:00
uninstall.ps1 init 2023-11-10 07:33:07 +00:00

subnet-seller

Algorithm coded for .NET or PowerShell applications/scripts to manage a network subnet (sell/restore/resell subnets) from a supernet.

Installation

git clone https://github.com/sarumaj/subnet-seller
cd subnet-seller
Invoke-Command -FilePath .\install.ps1

Usage

$mySub = New-Subnet '192.168.0.0' 16 6 26
Write-Host ($mySub | Out-String)
>> 
>> 
>> 
>> RecursionLevel   : 0
>> IPAddress        : 192.168.0.0
>> MaskBits         : 16
>> NetworkAddress   : 192.168.0.0
>> BroadcastAddress : 192.168.255.255
>> SubnetMask       : 255.255.0.0
>> Range            : 192.168.0.0 ~ 192.168.255.255
>> Available        : True
>> HostAddresses    : 65534
>> MaskOffset       : 6
>> MaskLimit        : 26
>> 
>> 
>> 
Write-Host ($mySub.list() | Out-String)
>> 
>> 
>>
>> Network      : 192.168.0.0/16
>> Available    : True
>> Range        : 192.168.0.0 ~ 192.168.255.255
>> HostAddresses : 65534
>> Subnets      : {@{Network=192.168.0.0/23; Available=True; Range=192.168.0.0 ~ 192.168.1.255; HostAddresses=510; Subnets=System.Object[]}, @{Network=192.168.2.0/23; 
>> Available=True; Range=192.168.2.0 ~ 192.168.3.255; HostAddresses=510; Subnets=System.Object[]}...}
>> 
>> 
>> 
$mySub.sell('192.168.2.128', 25, "sold-out on $(Get-Date)")
$mySub.sell('192.168.3.0', 25, "sold-out on $(Get-Date)")
$mySub.sell('192.168.3.128', 26, "sold-out on $(Get-Date)")
$mySub.repurchase('192.168.2.128', 25, "repurchased on $(Get-Date)")
$mySub.repurchase('192.168.3.128', 26, "repurchased on $(Get-Date)")
$mySub.print()
>> 
>> 
>> 
>> 192.168.0.0/16(Available:False)
>> --------------192.168.0.0/23(Available:True)
>> ----------------192.168.0.0/24(Available:True)
>> ------------------192.168.0.0/25(Available:True)
>> --------------------192.168.0.0/26(Available:True)
>> --------------------192.168.0.64/26(Available:True)
>> ------------------192.168.0.128/25(Available:True)
>> --------------------192.168.0.128/26(Available:True)
>> --------------------192.168.0.192/26(Available:True)
>> ----------------192.168.1.0/24(Available:True)
>> ------------------192.168.1.0/25(Available:True)
>> --------------------192.168.1.0/26(Available:True)
>> --------------------192.168.1.64/26(Available:True)
>> ------------------192.168.1.128/25(Available:True)
>> --------------------192.168.1.128/26(Available:True)
>> --------------------192.168.1.192/26(Available:True)
>> --------------192.168.2.0/23(Available:False)
>> ----------------192.168.2.0/24(Available:True)
>> ------------------192.168.2.0/25(Available:True)
>> --------------------192.168.2.0/26(Available:True)
>> --------------------192.168.2.64/26(Available:True)
>> ------------------192.168.2.128/25(Available:True,Comment:repurchased on 04/25/2022 10:14:45)
>> --------------------192.168.2.128/26(Available:True)
>> --------------------192.168.2.192/26(Available:True)
>> ----------------192.168.3.0/24(Available:False)
>> ------------------192.168.3.0/25(Available:False,Comment:sold-out on 04/25/2022 10:14:45)
>> ------------------192.168.3.128/25(Available:True)
>> --------------------192.168.3.128/26(Available:True,Comment:repurchased on 04/25/2022 10:14:45)
>> --------------------192.168.3.192/26(Available:True)
>> ...

Snapshots

#1 192.168.0.0/27 split down from /29 to /32

test

#2 Sold 192.168.0.0/30

test

#3 Sold 192.168.0.8/31

test

#4 Repurchased 192.168.0.8/31

test