Site map  

How to subnet an IPv4 /24

Basic rules:

  1. The total number of IP addresses in a subnet is a power of two. So that's: 1, 2, 4, 8, 16, ... etc.
  2. The first IP address in a subnet is a multiple (0, 1, 2, 3 ...) of the number of IP addresses in the subnet.
  3. 'x' in netmask '255.255.255.x' is 256 - number of IP addresses in the subnet.
  4. In slash-notation, the netmask is '/y', where y = 32 - n, and 2ⁿ is the number of addresses in the subnet.

So if we want 4 addresses in our subnet, the first address in this subnet is either 0 or 4 or 8 or 12 or ... etc.
And 'x' in netmask '255.255.255.x' is: 256 - 4 = 252. So the netmask is: '255.255.255.252'.
4 = 2², so n = 2 and y is 32 - 2 = 30. The slash-notation netmask is therefore: '/30'.

Note: You can't actually use IP addresses a.b.c.0 or a.b.c.255

Netmasks
SizeNetmask/
1255.255.255.255/32
2255.255.255.254/31
4255.255.255.252/30
8255.255.255.248/29
16255.255.255.240/28
32255.255.255.224/27
64255.255.255.192/26
128255.255.255.128/25
256255.255.255.0 /24

Size: 1

Netmask: 255.255.255.255 or /32
Any address.
Note: This is a rather small subnet.

Size: 2

Netmask: 255.255.255.254 or /31
Starts with even address.
Note: This is a rather small subnet.

Size: 4

Netmask: 255.255.255.252 or /30
Starts with multiple of 4;

'd' in IP address a.b.c.d;
1st - last1st - last1st - last1st - last
0 - 3 4 - 7 8 - 11 12 - 15
16 - 19 20 - 23 24 - 27 28 - 31
32 - 35 36 - 39 40 - 43 44 - 47
48 - 51 52 - 55 56 - 59 60 - 63
64 - 67 68 - 71 72 - 75 76 - 79
80 - 83 84 - 87 88 - 91 92 - 95
96 - 99100 - 103104 - 107108 - 111
112 - 115116 - 119120 - 123124 - 127
128 - 131132 - 135136 - 139140 - 143
144 - 147148 - 151152 - 155156 - 159
160 - 163164 - 167168 - 171172 - 175
176 - 179180 - 183184 - 187188 - 191
192 - 195196 - 199200 - 203204 - 207
208 - 211212 - 215216 - 219220 - 223
224 - 227228 - 231232 - 235236 - 239
240 - 243244 - 247248 - 251252 - 255

Example I

Network: 192.168.0.12
Netmask: 255.255.255.252

Or;

192.168.0.12/30

IP addresses 192.168.0.12 to 192.168.0.15 are in this subnet (see table above).

Example II

Network: 172.16.0.116
Netmask: 255.255.255.252

Or;

172.16.0.116/30

IP addresses 172.16.0.116 to 172.16.0.119 are in this subnet (see table above).

Example III

Network: 10.0.0.240
Netmask: 255.255.255.252

Or;

10.0.0.240/30

IP addresses 10.0.0.240 to 10.0.0.243 are in this subnet (see table above).

Size: 8

Netmask: 255.255.255.248 or /29
Starts with multiple of 8;

'd' in IP address a.b.c.d;
1st - last1st - last1st - last1st - last
0 - 7 8 - 15 16 - 23 24 - 31
32 - 39 40 - 47 48 - 55 56 - 63
64 - 71 72 - 79 80 - 87 88 - 95
96 - 103104 - 111112 - 119120 - 127
128 - 135136 - 143144 - 151152 - 159
160 - 167168 - 175176 - 183184 - 191
192 - 199200 - 207208 - 215216 - 223
224 - 231232 - 239240 - 247248 - 255

Example

Network: 192.168.1.24
Netmask: 255.255.255.248

Or;

192.168.1.24/29

IP addresses 192.168.1.24 to 192.168.1.31 are in this subnet (see table above).

Size: 16

Netmask: 255.255.255.240 or /28
Starts with multiple of 16;

'd' in IP address a.b.c.d;
1st - last1st - last1st - last1st - last
0 - 15 16 - 31 32 - 47 48 - 63
64 - 79 80 - 95 96 - 111112 - 127
128 - 143144 - 159160 - 175176 - 191
192 - 207208 - 223224 - 239240 - 255

Example

Network: 192.168.1.48
Netmask: 255.255.255.240

Or;

192.168.1.48/28

IP addresses 192.168.1.48 to 192.168.1.63 are in this subnet (see table above).

Size: 32

Netmask: 255.255.255.224 or /27
Starts with multiple of 32;

'd' in IP address a.b.c.d;
1st - last1st - last1st - last1st - last
0 - 31 32 - 63 64 - 95 96 - 127
128 - 159160 - 191192 - 223224 - 255

Example

Network: 192.168.1.96
Netmask: 255.255.255.224

Or;

192.168.1.96/27

IP addresses 192.168.1.96 to 192.168.1.127 are in this subnet (see table above).

Size: 64

Netmask: 255.255.255.192 or /26
Starts with multiple of 64;

'd' in IP address a.b.c.d;
1st - last1st - last1st - last1st - last
0 - 63 64 - 127128 - 191192 - 255

Example

Network: 192.168.1.128
Netmask: 255.255.255.192

Or;

192.168.1.128/26

IP addresses 192.168.1.128 to 192.168.1.191 are in this subnet (see table above).

Size: 128

Netmask: 255.255.255.128 or /25
Starts with multiple of 128;
Note: This is a rather large subnet.

'd' in IP address a.b.c.d;
1st - last1st - last
0 - 127128 - 255

Size: 256

Netmask: 255.255.255.0 or /24
Starts with 0.
Note: This is not a subnet.

Other subnet sizes.