Many books on subnetting will bore the crap out of you with "The history of the Ethernet started in 1980 with the 802.1... zzzz..." and look, you've fallen asleep and gotten drool on your nice new $75 Cisco CCNA Manual. I plan on making this page simple and to the point. There are three things I want you to remember first:
This is taken from the first octet in the IP address.
Octet Range Class Default Subnet Mask Private Addressing Notes 1 - 126* Class A 255.0.0.0 10.x.x.x Used only by really high-level companies *127.0.0.1 Loopback Used to test IP connectivity to self 128 - 191 Class B 255.255.0.0 172.16.x.x - 172.31.x.x Used by larger companies 192 - 223 Class C 255.255.255.0 192.168.x.x - 192.168.255.x Used by a majority of other companies 224 - 239 Class D n/a n/a Multiclass Broadcast only 240 - 255 Class E n/a n/a Experimental: Reserved for future use
Use the following equation:
2n - 2 >= Number of subnets requiredSo if you need 25 subnets:
- 2n - 2 >= 25
- 2n - 2 >= 25
- 25 - 2>= 25
- 32 - 2 >= 25
If n = 4 then it would have been 16, less than 25.
Note: At this point, you should account for expandability, if you are going to need more than 30 (25-2 )sub-networks in the future, you should go one greater, like 62 (26-2). Remember, the more networks you have, the less collision domains you have. But you will need routers to get them to speak to each other.
First, you need to determine your default mask above. To illustrate this better, let's toss our ten-digit fingers out the window, and think of them as nothing more than nonsense labels for the moment. Computers don't have fingers or toes, only switches.
Suppose you had this address: 192.168.35.x In binary, it looks like this: 11000000.10101000.00100011.x Looking at the default subnet mask: 255.255.255.0 Which the computer sees as: 11111111.11111111.11111111.00000000 Now since n = 5 in the example above, we know we must steal five bits, which is done from left to right 255.255.255.248 This is easier to see in binary: 11111111.11111111.11111111.11111000 As you can see, this makes less sense in our decimal world. "Huh? 248? WTF?!" Easy, tiger. This is simpler than it looks. See, each "bit" from left to right represents a factor of 2some power. Here's how we break down an octet:
Power of: 27 26 25 24 23 22 21 20 Decimal Number 128 64 32 16 8 4 2 1 Binary Number 1 1 1 1 1 0 0 0 So 5 bits stolen is really 128 + 64 + 32 + 16 + 8 = 248 (in decimal). If you think this is fun, wait until I write about Binary to Hexadecimal! But now we are getting off topic.
Okay, you have the new subnet mask, now what? "What the heck are my goddamn IP address ranges???" Whoa, too much caffeine, there, dude. But rest assured, even with too much Mountain Dew sloshing in your belly, you can do this. First, we have to determine the number of hosts per subnet. This is also better understood in binary:
Now, remember your default mask? Unless you have ADHD, you know it as: 255.255.255.248 But again, it's easier to see in binary 11111111.11111111.11111111.11111000 Since the 11111111.11111111.11111111.11111xxx is the network portion, then the remaining bits (which are zeros) are the hosts portion! Forget decimal for now Hosts (oooh): 11111111.11111111.11111111.11111000 Now, I may not be a bright man, but even I can tell there are only 3 bits left. So we use a familiar looking equation again to determine how many hosts (anything that needs an IP address to function) we have for each network.
2n - 2 >= Number of hosts per subnetSo in this case, 23 - 2 = 8 - 2 = 6 hosts per subnet. Wow, that's not a whole lot. But you do have a Class C address, and you were the bozo that wanted 25 networks.
256 - subnet mask = Interval
So, in our example, 256 - 248 = 8! Well, whattia know! This will also be the value of the lowest network, unless you are including zero networks, but for this case, we won't. So, now we start moving the tables around.
| Subnet | Subnet Address | First useable IP Address | Last useable IP address | Broadcast Address |
| First | 192.168.35.8 | 192.168.35.9 | 192.168.35.14 | 192.168.35.15 |
| Second | 192.168.35.16 | 192.168.35.17 | 192.168.35.22 | 192.168.35.23 |
| Third | 192.168.35.24 | 192.168.35.25 | 192.168.35.30 | 192.168.35.31 |
| Fourth | 192.168.35.32 | 192.168.35.33 | 192.168.35.38 | 192.168.35.39 |
| ... 30th | 192.168.35.240 | 192.168.35.241 | 192.168.35.246 | 192.168.35.247 |
Note we didn't use the 192.168.35.0 or 192.168.35.248 networks. We usually discard the first and last (which is why there are only 30 instead of 32 available in the equation above). This makes sense because the first would have 192.168.35.0 as a subnet, when it's really considered the name of a whole network. And 192.168.35.248 would have 192.168.35.255 as a broadcast address for a subnet when it should be the default broadcast for the whole 192.168.35.0 network. This will confuse people later on. But I'd be a liar in a Viking hat if I said that it hasn't been done before. It's just not a good IDEA. Many subnet calculators out there also include these networks, usually called zero networks.
| Subnet | Subnet Address | First useable IP Address | Last useable IP address | Broadcast Address |
| First | 10.16.0.0 | 10.16.0.1 | 10.31.255.254 | 10.31.255.255 |
| Second | 10.32.0.0 | 10.32.0.1 | 10.47.255.254 | 10.47.255.255 |
| Third | 10.48.0.0 | 10.48.0.1 | 10.63.255.254 | 10.63.255.255 |
| ...14th | 10.224.0.0 | 10.224.0.1 | 10.239.255.254 | 10.239.255.255 |
| Subnet | Subnet Address | First useable IP Address | Last useable IP address | Broadcast Address |
| First | 129.50.4.0 | 129.50.4.1 | 129.50.7.254 | 129.50.7.255 |
| Second | 129.50.8.0 | 129.50.8.1 | 129.50.11.254 | 129.50.11.255 |
| Third | 129.50.12.0 | 129.50.12.1 | 129.50.15.254 | 129.50.15.255 |
| ...50th | 129.50.200.0 | 129.50.200.1 | 129.50.203.254 | 129.50.203.255 |
| ...62nd | 129.50.248.0 | 129.50.248.1 | 129.50.251.254 | 129.50.251.255 |
Problem: How about just the countries in Europe?
| Subnet | Subnet Address | First useable IP Address | Last useable IP address | Broadcast Address |
| Albania | 222.100.42.4 | 222.100.42.5 | 222.100.42.6 | 222.100.42.7 |
| Andorra | 222.100.42.8 | 222.100.42.9 | 222.100.42.10 | 222.100.42.11 |
| Austria | 222.100.42.12 | 222.100.42.13 | 222.100.42.14 | 222.100.42.15 |
| ...Serbia/Montenegro | 222.100.42.176 | 222.100.42.177 | 222.100.42.178 | 222.100.42.179 |
| ...62nd | 222.100.42.248 | 222.100.42.249 | 222.100.42.250 | 222.100.42.251 |
See, it's not that hard, once you think in binary. Some classes you take might ask you to think in HEX, which is like having 10 fingers and using all the toes on one foot. They go 0,1,2,3...9 and then A,B,C,D,E, and F for 10-15. "Hexadecimal" means "six and ten" or 16, which is 0-15 (remember, computers always start with 0 when counting). In some of the old configs I have seen on Sun/Solaris boxes, I have seen the netmask as ff.ff.ff.C0. That's really 255.255.255.192, because ff = 16 x 16 numbers, or 256, which is 0-255 in range.
And you now know what that is in binary, right? ;-)