IP subnetting is the art of taking a given address range and dividing it into several smaller networks.
How to subnet
an IP address range
The first thing you need to figure out is how many bits are required for the network
portions of the address. So if you had a class B
(yeah, I know about CIDR
, but I'm starting slow), and you needed, say, 200 subnets:
Class B: 126.96.36.199/16
, A class B has 16 bits
in the network portion
. You need enough bits to be above 200 in decimal. The first power of 2 that's above 200 is 2 to the 8th, which equals 256
(although you don't get two of those subnets if you're taking an MCP
exam, because Microsoft
is dumb). So you shift the network portion to the right 8 bits, giving you:
This gives you 254 usable subnets (per Microsoft's definiton- 256 anywhere else). You can determine the number of hosts by taking 2 to the power of however many bits are left, so (2^(32-24)) comes out as 256. Now, you need to subtract 2 from the network address and broadcast address. This gives you 254.
The next step is to figure out the subnet mask
. To do this, convert everything in the network portion of the address to 1s (in binary
), and everything in the host portion
Now convert back to decimal:
Look familiar? Yeah, it's the subnet mask for a class C
Now, to find the individual networks:
The first 16 bits were assigned by your ISP, so you can't touch those. The last 8 bits are the host portion, so you can't use those to determine networks, either. This leaves you with the third octet
. Your usable networks are all possible combinations of those 8 bits:
and so on.
I left off the bottom range because Microsoft's exams say you can't use it- on their exams you can't use the top one either.
The network address
(the address that defines a given network) is the lowest address in a subnet. So for your subnet:
188.8.131.52 is your network address.
Similarly, the highest address in that subnet is the broadcast address
, so in that same range:
184.108.40.206 (143.17.00000100.11111111) is your broadcast address. Pretty simple, huh? All you need now is to figure out the default gateway
. The default gateway
is the near side of a router- the router interface
that is on the same network as you. Typically, a default gateway is one number higher than the network address, but this is not always the case- it depends what the netadmin
assigned to it.
To tackle a tougher one: Your address range is 220.127.116.11/11 (a range so large you'll never be able to buy one these days). Converting this to binary gives us:
The section you get to play with is after the first 11 bits (the first octect and the first 3 from the second). So let's say you needed 1,000 subnets of this gigantic network. The next higher power of 2 is 2^10th, which comes out to 1024. Again, Microsoft doesn't let you use the top or bottom networks (assuming you're taking one of their exams), so you're left with 1022. Taking your IP range, we move the network portion 10 bits to the right, leaving you with:
So the dividing line between the hosts and network portions are:
So to find your subnet mask, take everything to the left of that dividing line and turn it into a 1. Take everything to the right and turn it into zeroes. This gives you:
11111111.11111111.11111000.00000000, which, in decimal, is 255.255.248.0.
To figure out the number of hosts per subnet, merely count the digits to the right of the dividing line and take 2 to that number. In this case, we get 2^11, which is 2048. Subtract 2 (that network address and broadcast address again!), and you're left with 2046.
Finding the individual networks is again nice and easy. Your ISP assigned the top 11 bits, the bottom 11 bits are for hosts, so you're left with the remaining (middle) 10. So your addresses look like this:
I segmented it out so you can see what are we're working with here. All you have to do now is convert it back to binary, giving you:
Et Cetera. Again, the gateway
is the address of the router interface on your network.
I hope this is helpful to someone.
Oh, and I'm looking for a job as a netadmin's assistant while I learn the ropes. Any offers?