Over the years, I have found 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 before you know it, 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 because too many subnetting FAQs out there went on and on before they taught you anything useful. There are four things I want you to remember first:
Unless the DHCP server has been set up to give YOUR specific computer the SAME IP address (and it can do that,just not usually), each time you get on the network, it's a crapshoot of what IP address you end up with. Today it's 192.168.1.2, the next time you connect, it could be 192.168.1.5. You never know. DHCP is best for laptops or workstations where the IP address doesn't really matter just as long as you have one. It also is great for managing networks.
Static IP means the machine always has the same IP, which is most useful for servers. Usually, though, you have to set everything yourself with a static IP, which means you have to know the gateway, name servers, subnet mask, and so on by yourself. In some cases, I have seen some networks set up a server as DHCP, and then tell the DHCP server, "Always give this IP address to this server." Static IPs are boring, but predictable. Like that girlfriend you pretended to dump in high school.
In either case, you have to know how to set up IPs. Either on your machine, or on the DHCP server. And that's why you're here. Let's get started, shall we? What? Bored already? Come on, man. You watched the Windows defrag tool for hours last week. Stay with me.
This is taken from the first octet in the IP address. IPs are separated into classes. Like Texas Chili.What is "private addressing?" Well, each class has a separate set of addresses that everyone has agreed on are "not Internet routable." This is very handy for firewalls and NAT. See, there aren't enough IP addresses to go around any more. So you have "outside IPs" (which are most of them), and "inside IPs" which are the private addresses. The most common you will see for home and small office networks are the 192.168.x.x variety. Because this class C address range has a default mask of 255.255.255.0, you can really only have 254 hosts per subnet
Octet Range Class Default Subnet Mask Private Addressing Notes 1 - 126* Class A 255.0.0.0 10.x.x.x Used by really high-level companies with a lot of computers *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, I see a lot of this in mid-level networks 192 - 223 Class C 255.255.255.0 192.168.x.x - 192.168.255.x Used by small companies, home offices, small home networks 224 - 239 Class D n/a n/a Multicast Broadcast only 240 - 255 Class E n/a n/a Experimental: Reserved for future use (I don't know what the hell that means, either)
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. People would laugh at you. And point.
Note: At this point, you should about 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. That's another topic for a later time, but keep in mind if you have TOO many hosts all working on the same subnet (like over 100 servers all talking at once), you are going to slow your network down.
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 again. Focus. Before going to step 4, go and get yourself a cookie and a drink of water. I'll wait.
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.
As a side note, how many hosts SHOULD you have per subnet? Well, the rule of thumb is that you shouldn't have more than 254 hosts in the same subnet because they will all share the same collision domain. Your network will slow to a crawl with all that traffic. Keep in mind, a lot of traffic isn't just a machine accessing the Internet, a lot of services will constantly send traffic back and forth. If you have ever sniffed traffic on a closed network, even "idle" computers are sending info back and forth, espically if you haven't firewalled them and you have default services enabled. If you have 1000 hosts on the same subent, even if the machines are idle, you will notice some machines will start to slow down as the NIC or software tries to process all the messages.
A lot of people have /24 networks to make sure this doesn't happen, which is 254 hosts, and /24 is an "even break point" of one octet that's easier to do quick math. Routers/firewalls and managed switches (like VLANS) will take care of any translation from subnet to subnet.
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? ;-)