Subnet Cheat Sheet – 24 Subnet Mask, 30, 26, 27, 29, and other IP Address CIDR Network References As a developer or network engineer, you may need to occasionally look up subnet mask values and figure out what they mean. By Kris Koishigawa Oct 04, 2021 09:00 AM 10 min. read As a developer or network engineer, you may need to occasionally look up subnet mask values and figure out what they mean. To make your life easier, the freeCodeCamp community has made this simple cheat sheet. Just scroll or use Ctrl/Cmd + f to find the value you’re looking for. Here are the charts, followed by some explanations of what they mean. CIDR Subnet mask Wildcard mask # of IP addresses # of usable IP addresses /32 255.255.255.255 0.0.0.0 1 1 /31 255.255.255.254 0.0.0.1 2 2* /30 255.255.255.252 0.0.0.3 4 2 /29 255.255.255.248 0.0.0.7 8 6 /28 255.255.255.240 0.0.0.15 16 14 /27 255.255.255.224 0.0.0.31 32 30 /26 255.255.255.192 0.0.0.63 64 62 /25 255.255.255.128 0.0.0.127 128 126 /24 255.255.255.0 0.0.0.255 256 254 /23 255.255.254.0 0.0.1.255 512 510 /22 255.255.252.0 0.0.3.255 1,024 1,022 /21 255.255.248.0 0.0.7.255 2,048 2,046 /20 255.255.240.0 0.0.15.255 4,096 4,094 /19 255.255.224.0 0.0.31.255 8,192 8,190 /18 255.255.192.0 0.0.63.255 16,384 16,382 /17 255.255.128.0 0.0.127.255 32,768 32,766 /16 255.255.0.0 0.0.255.255 65,536 65,534 /15 255.254.0.0 0.1.255.255 131,072 131,070 /14 255.252.0.0 0.3.255.255 262,144 262,142 /13 255.248.0.0 0.7.255.255 524,288 524,286 /12 255.240.0.0 0.15.255.255 1,048,576 1,048,574 /11 255.224.0.0 0.31.255.255 2,097,152 2,097,150 /10 255.192.0.0 0.63.255.255 4,194,304 4,194,302 /9 255.128.0.0 0.127.255.255 8,388,608 8,388,606 /8 255.0.0.0 0.255.255.255 16,777,216 16,777,214 /7 254.0.0.0 1.255.255.255 33,554,432 33,554,430 /6 252.0.0.0 3.255.255.255 67,108,864 67,108,862 /5 248.0.0.0 7.255.255.255 134,217,728 134,217,726 /4 240.0.0.0 15.255.255.255 268,435,456 268,435,454 /3 224.0.0.0 31.255.255.255 536,870,912 536,870,910 /2 192.0.0.0 63.255.255.255 1,073,741,824 1,073,741,822 /1 128.0.0.0 127.255.255.255 2,147,483,648 2,147,483,646 /0 0.0.0.0 255.255.255.255 4,294,967,296 4,294,967,294 * /31 is a special case detailed in RFC 3021 where networks with this type of subnet mask can assign two IP addresses as a point-to-point link. And here’s a table of the decimal to binary conversions for subnet mask and wildcard octets: Subnet Mask Wildcard 0 00000000 255 11111111 128 10000000 127 01111111 192 11000000 63 00111111 224 11100000 31 00011111 240 11110000 15 00001111 248 11111000 7 00000111 252 11111100 3 00000011 254 11111110 1 00000001 255 11111111 0 00000000 Note that the wildcard is just the inverse of the subnet mask. If you are new to network engineering, you can get a better idea of how computer networks work here. Finally, this cheat sheet and the rest of the article is focused on IPv4 addresses, not the newer IPv6 protocol. If you’d like to learn more about IPv6, check out the article on computer networks above. How Do IP Address Blocks Work? IPv4 addresses like 192.168.0.1 are really just decimal representations of four binary blocks. Each block is 8 bits, and represents numbers from 0-255. Because the blocks are groups of 8 bits, each block is known as an octet. And since there are four blocks of 8 bits, every IPv4 address is 32 bits. For example, here’s what the IP address 172.16.254.1 looks like in binary: Source: IPv4 To convert an IP address between its decimal and binary forms, you can use this chart: The chart above represents one 8 bit octive. Now lets say you want to convert the IP address 168.210.225.206. All you need to do is break the address into four blocks (168, 210, 225, and 206), and convert each into binary using the chart above. Remember that in binary, 1 is the equivalent to “on” and 0 is “off”. So to convert the first block, 168, into binary, just start from the beginning of the chart and place a 1 or 0 in that cell until you get a sum of 168. For example: 128 + 32 + 8 = 168, which in binary is 10101000. If you do this for the rest of the blocks, you’d get 10101000.11010010.11100001.11001110. What is Subnetting? If you look at the table above, it can seem like the number of IP addresses is practically unlimited. After all, there are almost 4.2 billion possible IPv4 addresses available. But if you think about how much the internet has grown, and how many more devices are connected these days, it might not surprise you to hear that there’s already a shortage of IPv4 addresses. Because the shortage was recognized years ago, developers came up with a way to split up an IP address into smaller networks called subnets. This process, called subnetting, uses the host section of the IP address to break it down into those smaller networks or subnets. Generally, an IP address is made up of network bits and host bits: Source: What is IPv4 So generally, subnetting does two things: it gives us a way to break up networks into subnets, and allows devices to determine whether another device/IP address is on the same local network or not. A good way to think about subnetting is to picture your wireless network at home. Without subnetting, every internet connected device would need its own unique IP address. But since you have a wireless router, you just need one IP address for your router. This public or external IP address is usually handled automatically, and is assigned by your internet service provider (ISP). Then every device connected to that router has its own private or internal IP address: Source: What Is My IP Address? Now if your device with the internal IP address 192.168.1.101 wants to communicate with another device, it’ll use the IP address of the other device and the subnet mask. The combination of the IP addresses and subnet mask allows the device at 192.168.1.101 to figure out if the other device is on the same network (like the device at 192.168.1.103), or on a completely different network somewhere else online. Interestingly, the external IP address assigned to your router by your ISP is probably part of a subnet, which might include many other IP addresses for nearby homes or businesses. And just like internal IP addresses, it also needs a subnet mask to work. How Subnet Masks Work Subnet masks function as a sort of filter for