An IPv4 address has 32 bits, 4 octets, and 8 bits in each octet
Subnet Masks: 128 192 224 240 248 252 254 255 Base 2 Math (also block size): 128 64 32 16 8 4 2 1
Class A (1 – 126) 255.0.0.0 – 8 bits for network, 24 bits for host Class B (128 – 191) 255.255.0.0 – 16 bits for network, 16 bits for host Class C (192 – 223) 255.255.255.0 – 24 bits for network, 8 bits for host Class D (224 – 239) – multicast Class E (240 – 255) – reserved future, experimental 127.0.0.0 /8 is reserved for loopback addresses
Private address classes – RFC 1918
-- Non-routable on the internet, need network address translation (NAT) to get to the internet
Class A 10.0.0.0 – 10.255.255.255 /8 Class B 172.16.0.0 – 172.31.255.255 /12 Class C 192.168.0.0 – 192.168.255.255 /16
Questions that need answering
- What is the CIDR notation or prefix length, subnet mask, and wildcard mask?
- How many subnets or networks? (Remember classes default subnet mask)
- What is the block size or what is the number that the subnet or network increment by?
- How many usable hosts per subnet or network?
- What subnet or network does this host belong to?
- What is the next network address?
- What is the first usable IP? (valid address range)
- What is the broadcast address?
- What is the last usable IP? (valid address range)
Given the IP of 188.8.131.52 and subnet mask of 255.255.240.0
For the CIDR notation or prefix length, convert the subnet mask to binary and count up the number of bits used for the network (1s) and put a slash in front of it. So, the subnet mask of 255.255.240.0 converted to binary is 11111111.11111111.11110000.00000000 and the amount of ones is /20.
The wildcard mask is found by flipping the bits (turn 1s into 0s and 0s into 1s). The easy way, is to minus 1 from the block-size (block-size is 16, so 16 -1 = 15 and put that in the third octet). So, a subnet mask of 255.255.240.0 would equal a wildcard mask of 0.0.15.255. The binary way is to take the subnet mask and convert it to binary. So, 255.255.240.0 = 11111111.11111111.11110000.00000000. You would flip the bits and you get 00000000.00000000.00001111.11111111. Convert that back into decimal using the magic numbers and the wildcard mask equals 0.0.15.255
To find how many subnets or networks, one would start with the default subnet mask for the number in the first octet. 1 is a Class A address, so it’s default subnet mask is 255.0.0.0. We then compare 255.0.0.0 with that of the 255.255.240.0 given. 255.0.0.0 = 11111111.00000000.00000000.00000000 255.255.240.0= 11111111.11111111.11110000.00000000 We count up the 1s and there are 12 more 1s than the default subnet mask. We then use the Magic numbers and count over 12 times starting from right to left at the binary number 2 or second digit from the right. 4096 2048 1024 512 256 128 64 32 16 8 4 2. = 4,096 total networks or subnets. NOTE If given a 184.108.40.206 network with a /20 or 255.255.240.0. You know that you can only manipulate the third octet. The first and second are already allocated. You put that third octet number into binary and get 11110000, count up the 1s and from right to left using the magic numbers above starting at 2, counting over 4 times and you get 16 (which is also the block size). There are only 16 usable networks with this subnet mask given the network.
We look at the subnet mask given for the first number that does not equal 255. So, with 255.255.240.0, we can see that the first octet that is different is the third, which is 240. We look at the magic numbers above and see that under the number 240 is 16. So, the block-size or number that the networks increment in the third octet is 16.
Look at the subnet mask given and count up what bits that are left for hosts. So, 255.255.240.0 = 11111111.11111111.11110000.00000000. There are 12 zeros. The zeros represent hosts. We then use the Magic numbers and count over 12 times starting at 2 from right to left. Remember to minus 2 from the number, because one IP is reserved for the network and one IP is reserved for the broadcast address 4096 2048 1024 512 256 128 64 32 16 8 4 2 1. = 4,096-2 = 4094 total usable hosts per network.
We look at the subnet mask of 255.255.240.0 and find the first octet number that is not 255 and put that into binary. We then find the number in the IP address of 220.127.116.11 that falls into that same octet, which is the third octet and the number is 1. We change that into binary and place it under the 240 and times them together. We then compare the 1s. Since the 1 under the 240 does not fall into direct line with the 1s above it, the network is 0. Place the zero back into the IP address in the third octet and change the octet to the right as a 0, since the network will only increment in the third octet. The network with the given IP address lives on = 18.104.22.168 240 = 11110000 1= 00000001
Knowing that the networks increment by 16, thanks to the steps in #3, we add 16 to the number in the third octet from the answer in #5. Our next network = 22.214.171.124
If our networks increment in the third octet, then we increment the hosts in the fourth octet. So, our first usable host = 126.96.36.199
Knowing the next network in #6, we minus 1 from the next networks third octet and minus 1 from the fourth octet (octets range from 0 to 256). So, 256 -1 equals 255. You can also think of it as a loop or circle. Goes from 0 to 255, then starts over at 0, So 0-1 equals 255 in that loop. This gives us 188.8.131.52 as the broadcast address.
Knowing the broadcast address in #8, the last usable IP is 1 minus the broadcast address. So, we minus 1 from the fourth octet. This gives us 184.108.40.206 as the last usable IP address.
Hopefully this helps… You can use these same principles for any IP address and subnet mask given.