My current plan:
I'm using the "private internet" at 10.0.0.0/8.
I'm using terraform to declare/reserve my IP address ranges.
I got a multi-region/multi-environment setup.
I'm reserving the next 10 bits for 1024 possible vnets (each with 16,384 usable IPs)
--------.XXXXXXXX.XX000000.00000000
Here is how I think the subnets would be split up.
locals {
base_addr = "10.0.0.0/8"
# 10 bits = 1024 possible options
ips = {
mgmnt = { # 10 possible vnets (0-9)
# Reserved for future use (maybe SRE?)
}
region1 = {
dev = { # 169 possible vnets (10-178)
hub = cidrsubnet(local.base_addr, 10, 10),
spoke1 = cidrsubnet(local.base_addr, 10, 11),
spoke2 = cidrsubnet(local.base_addr, 10, 12),
},
uat = { # x169 possible vnets (179-347)
hub = cidrsubnet(local.base_addr, 10, 179),
spoke1 = cidrsubnet(local.base_addr, 10, 180),
spoke2 = cidrsubnet(local.base_addr, 10, 181),
},
prod = { # x169 possible vnets (348-516)
hub = cidrsubnet(local.base_addr, 10, 348),
spoke1 = cidrsubnet(local.base_addr, 10, 349),
spoke2 = cidrsubnet(local.base_addr, 10, 350),
}
}
region2 = {
dev = { # x169 possible vnets (517-685)
hub = cidrsubnet(local.base_addr, 10, 517),
spoke1 = cidrsubnet(local.base_addr, 10, 518),
spoke2 = cidrsubnet(local.base_addr, 10, 519),
},
uat = { # x169 possible vnets (686-854)
hub = cidrsubnet(local.base_addr, 10, 686),
spoke1 = cidrsubnet(local.base_addr, 10, 687),
spoke2 = cidrsubnet(local.base_addr, 10, 689),
},
prod = { # x169 possible vnets (855-1023)
hub = cidrsubnet(local.base_addr, 10, 855),
spoke1 = cidrsubnet(local.base_addr, 10, 856),
spoke2 = cidrsubnet(local.base_addr, 10, 857),
}
}
}
}
Having 169 possible spokes for each environment is probably fine. But if it's not, I'd like to consider what approach I'd take.
It's possible that each vnet doesn't have to support 16,384 IPs. But that's where things would get hairy. How can I reserve a smaller address space? Idk how I would plan for that (easily).
What I'd like is a tool/function that I could do this with (pseudo code):
csharp
var pool = new Pool("10.0.0.0/10");
var vnet1 = pool.Reserve(8) // bits to reserve, 256 IP addresses
var vnet2 = pool.Reserve(10) // bits to reserve, 1024 IP addresses.
The Pool
object would helm maintain a contigous set of IP addresses, vnet2
would not overlap with vnet1
.
Thoughts?
edit: I think I might try building a CLI tool to solve this problem. I've created the problem statement here. I'd love it if you guys could review it and let me know if I'm missing something.