Skip to content

Instantly share code, notes, and snippets.

@niqdev
Last active October 9, 2020 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niqdev/1ab727c3c01de2993cad070c04ba8b47 to your computer and use it in GitHub Desktop.
Save niqdev/1ab727c3c01de2993cad070c04ba8b47 to your computer and use it in GitHub Desktop.

Private address classes

class from to CIDR notation subnet mask
A 10.0.0.0 10.255.255.255 /8 255.0.0.0
B 172.16.0.0 172.31.255.255 /12 255.240.0.0
C 192.168.0.0 192.168.255.255 /16 255.250.0.0
APIPA 169.254.0.0 169.254.255.255 /16 255.250.0.0

CIDR notation rules

  • identifies the subnet mask by the number of leading 1s in the subnet mask
  • subnet mask tells what portion of the address is
    • network part (255)
    • host part (0)
2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128

/25 = 8+8+8+1
255       255       255       128
11111111  11111111  11111111  10000000

N = first value after last 255 e.g. 128
network increment:    256 - N = 256 - 128 = 128
number of subnets:    256 / 128 = 2
first valid address:  network id + 1
last valid address:   next network id - 2
network id first valid address last valid address broadcast address
x.x.x.0 x.x.x.1 x.x.x.126 x.x.x.127
x.x.x.128 x.x.x.129 x.x.x.254 x.x.x.255

/26 = 8+8+8+2
255       255       255       192 = (128+64)
11111111  11111111  11111111  11000000

N = first value after last 255 e.g. 192
network increment:    256 - N = 256 - 192 = 64
number of subnets:    256 / 64 = 4
first valid address:  network id + 1
last valid address:   next network id - 2
network id first valid address last valid address broadcast address
x.x.x.0 x.x.x.1 x.x.x.62 x.x.x.63
x.x.x.64 x.x.x.65 x.x.x.126 x.x.x.127
x.x.x.128 x.x.x.129 x.x.x.190 x.x.x.191
x.x.x.192 x.x.x.193 x.x.x.254 x.x.x.255

/27 = 8+8+8+3
255       255       255       224 = (128+64+32)
11111111  11111111  11111111  11100000

N = first value after last 255 e.g. 224
network increment:    256 - N = 256 - 224 = 32
number of subnets:    256 / 32 = 8
first valid address:  network id + 1
last valid address:   next network id - 2
network id first valid address last valid address broadcast address
x.x.x.0 x.x.x.1 x.x.x.30 x.x.x.31
x.x.x.32 x.x.x.33 x.x.x.62 x.x.x.63
x.x.x.64 x.x.x.65 x.x.x.94 x.x.x.95
x.x.x.96 x.x.x.97 x.x.x.126 x.x.x.127
x.x.x.128 x.x.x.129 x.x.x.158 x.x.x.159
x.x.x.160 x.x.x.161 x.x.x.190 x.x.x.191
x.x.x.192 x.x.x.193 x.x.x.222 x.x.x.223
x.x.x.224 x.x.x.225 x.x.x.254 x.x.x.255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment