I have 172.16.0.0/21 and my mask is 255.255.248.0 which gives me an IP range from 172.16.0.0 to 172.16.7.255
255.255.248.0
11111111.11111111.11111000.00000000
Network------------------------Host
xxxxxxxx.xxxxxxxx.xxxxx111.11111111I know I need a /23 subnet mask, but I don’'t know how to do that from the above information.
I need:
255.255.254.0
11111111.11111111.11111110.00000000 In the previous paragraph, I get this binary 2 is the “magic number” and my subnet IP address will increase by two. I’m just baffled about how to initially determine it was going to need a /23 subnet. I’ve gone through my notes, texts but I don’t get it.
The unmasked bits “zeros” turn to ones 2^9 = 512 -2 = 510 hosts.
I just need help understanding the /23 part.
2 Answers
Subnet masks, when represented as a row of 32 bits (1s or 0s), always have all 1s on the left (the most significant bits of the first octets), and all 0s on the right (the least significant bits of the last octets). So we can describe them in shorthand by just noting how many 1's there are.
As you know, a /21 has 21 1's, starting from the left:
11111111.11111111.11111000.00000000Now convert each octet to decimal to get the familiar "dotted-decimal" or "dotted-quad" notation:
255.255.248.0This is because the most significant bit in an octet (8-bit Byte) is the "128's place", the next is the "64's place", etc:
128, 64, 32, 16, 8, 4, 2, 1So in that third octet, you have 5 1s and 3 0's:
128 + 64 + 32 + 16 + 8 + 0 + 0 + 0 = 248Now let's look at your /23:
11111111.11111111.11111110.00000000That third octet converts to decimal like this:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 0 = 254
255.255.254.0You see, by adding two bits to the subnet mask, you're not adding a "binary 2" (the value 2, which is 10 in binary), or even the max value two bits can store (binary 11 = decimal 3).
You've got to look at the binary place-value of the 1s you're adding to the mask. In your case, you were adding a 1 in the 4's place, and a 1 in the 2's place, so you're adding 6 to that octet's value.
248 + 6 = 254Because of the way that subnet masks "grow from the left" like this, there are only 9 possible values for any octet in a subnet mask:
0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0
128 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 128
128 + 64 + 0 + 0 + 0 + 0 + 0 + 0 = 192
128 + 64 + 32 + 0 + 0 + 0 + 0 + 0 = 224
128 + 64 + 32 + 16 + 0 + 0 + 0 + 0 = 240
128 + 64 + 32 + 16 + 8 + 0 + 0 + 0 = 248
128 + 64 + 32 + 16 + 8 + 4 + 0 + 0 = 252
128 + 64 + 32 + 16 + 8 + 4 + 2 + 0 = 254
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 0 A valid submask for you would be 255.255.254.0
Addresses Hosts Netmask Amount of a Class C
/30 4 2 255.255.255.252 1/64
/29 8 6 255.255.255.248 1/32
/28 16 14 255.255.255.240 1/16
/27 32 30 255.255.255.224 1/8
/26 64 62 255.255.255.192 1/4
/25 128 126 255.255.255.128 1/2
/24 256 254 255.255.255.0 1
/23 512 510 255.255.254.0 2
/22 1024 1022 255.255.252.0 4
/21 2048 2046 255.255.248.0 8
/20 4096 4094 255.255.240.0 16
/19 8192 8190 255.255.224.0 32
/18 16384 16382 255.255.192.0 64
/17 32768 32766 255.255.128.0 128
/16 65536 65534 255.255.0.0 256There is a nice cheatsheet and more information over here:
All devices on a local network have a unique IP address, but each address is inherently divided into two parts, a shared network part, and a unique host part, and this information is used by the TCP/IP stack for routing. When sending traffic to a machine with a different network part, it must be sent through a router for final delivery. The dividing line between the network and host parts is determined by the subnet mask, and it's often seen in 255.255.255.0 notation. It looks like an IP address, and it uses a "1" bit to select, or "mask" the network part.
In this case, the netmask of 255.255.255.248 represents 29 bits of network and 3 bits of host (totalling 32 bits, of course), and this give 8 possible IP addresses in this range. The first and last of the range are reserved addresses, giving 6 usable addresses that may be assigned to a device.
2