Use ipcalc to compute subnets
When creating VPCs, you need to divide your CIDR range into subnets.
The best tool I’ve found for the job is ipcalc.
ipcalc
can be installed via homebrew
on macOS.
Most VPC CIDR blocks are /16
, so if you do something like:
➜ ~ ipcalc 10.0.0.0/16
Address: 10.0.0.0 00001010.00000000. 00000000.00000000
Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000
Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111
=>
Network: 10.0.0.0/16 00001010.00000000. 00000000.00000000
HostMin: 10.0.0.1 00001010.00000000. 00000000.00000001
HostMax: 10.0.255.254 00001010.00000000. 11111111.11111110
Broadcast: 10.0.255.255 00001010.00000000. 11111111.11111111
Hosts/Net: 65534 Class A, Private Internet
Then, if you want to divide up the /16
space to /20
, you can do this:
➜ ~ ipcalc 10.0.0.0/16 /20
Address: 10.0.0.0 00001010.00000000. 00000000.00000000
Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000
Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111
=>
Network: 10.0.0.0/16 00001010.00000000. 00000000.00000000
HostMin: 10.0.0.1 00001010.00000000. 00000000.00000001
HostMax: 10.0.255.254 00001010.00000000. 11111111.11111110
Broadcast: 10.0.255.255 00001010.00000000. 11111111.11111111
Hosts/Net: 65534 Class A, Private Internet
Subnets after transition from /16 to /20
Netmask: 255.255.240.0 = 20 11111111.11111111.1111 0000.00000000
Wildcard: 0.0.15.255 00000000.00000000.0000 1111.11111111
1.
Network: 10.0.0.0/20 00001010.00000000.0000 0000.00000000
HostMin: 10.0.0.1 00001010.00000000.0000 0000.00000001
HostMax: 10.0.15.254 00001010.00000000.0000 1111.11111110
Broadcast: 10.0.15.255 00001010.00000000.0000 1111.11111111
Hosts/Net: 4094 Class A, Private Internet
2.
Network: 10.0.16.0/20 00001010.00000000.0001 0000.00000000
HostMin: 10.0.16.1 00001010.00000000.0001 0000.00000001
HostMax: 10.0.31.254 00001010.00000000.0001 1111.11111110
Broadcast: 10.0.31.255 00001010.00000000.0001 1111.11111111
Hosts/Net: 4094 Class A, Private Internet
3.
Network: 10.0.32.0/20 00001010.00000000.0010 0000.00000000
HostMin: 10.0.32.1 00001010.00000000.0010 0000.00000001
HostMax: 10.0.47.254 00001010.00000000.0010 1111.11111110
Broadcast: 10.0.47.255 00001010.00000000.0010 1111.11111111
Hosts/Net: 4094 Class A, Private Internet
4.
Network: 10.0.48.0/20 00001010.00000000.0011 0000.00000000
HostMin: 10.0.48.1 00001010.00000000.0011 0000.00000001
HostMax: 10.0.63.254 00001010.00000000.0011 1111.11111110
Broadcast: 10.0.63.255 00001010.00000000.0011 1111.11111111
Hosts/Net: 4094 Class A, Private Internet
...output redacted
Master GitHub Actions with a Senior Infrastructure Engineer
As a senior staff infrastructure engineer, I share exclusive, behind-the-scenes insights that you won't find anywhere else. Get the strategies and techniques I've used to save companies $500k in CI costs and transform teams with GitOps best practices—delivered straight to your inbox.
Not sure yet? Check out the archive.
Unsubscribe at any time.