Networking 101: Undressing IP addresses – Subnetting (Part 4 of 4)

In the last post you learned about IPv6 and now we’re going to talk about one of the of most daunting IP addressing topics of all: subnetting.

Let’s say you contact your service provider and say:

Hey, I just started a new business and I need IP addresses so I can get my computers on the internet.

Your service provider isn’t going to give you a unique public IP address for each host; instead, it’ll give you an Class Block and will expect you to divide it up into useful networks.

For example, you might contact AT&T and they might say:

Okay, we’ll assign 90.4.0.0/16 to your organization.

Your job would be to divide that super street into multiple side streets.  This is called subnetting and it’s a critical skill to have.

At the end of this article you’ll have it!

Check it out.

1. Write out your binary chart

It all starts with your beautiful binary chart.

128 64 32 16 8 4 2 1

2. Ask: “How many subnetworks do I want?”

What you’re really asking is: “How many bits do I need to take from the host portion of the IP network?”

Here’s how to figure this out:


Imagine each of your fingers is equivalent to 1 bit.  Your thumb is 1 bit, your index finger is one bit; each finger represents a bit.

Finger Bits

Now imagine that you wrote the number two on your thumbnail in a hot pink permanent magic marker.

Thumb Subnets

You continue the trend of writing on your thumbnails but this time you write a 4 in hot pink on your index fingernail.  Each fingernail gets a value of the previous number times two.

These numbers represent subnets.

Subnets

Your fingers are bits and the numbers on your fingernails are subnets.

If you need 7 subnets you would count out the values until you get to 7.

2, 4, 8… okay so that’s three fingers which means I need to take 3 bits from the host portion of the IP address to create a subnet that can support 7 unique host addresses.


 

Let’s say you need 14 subnets.

  • First is your thumbnail, it’s a 2. Is that enough? No.
  • Your index fingernail is a 4.  Is that enough? No.
  • Your middle fingernail is a 8.  Is that enough? Nope.
  • Your ring fingernail is a 16.  Is that enough? Yes! It’s more than enough.
    • So count each finger: you need one, two, three, four; four fingers or four bits to create a subnet with 14 unique hosts.  If you take four bits from the host portion of the IP address you can carve out 14 unique addresses.

3. Ask: “How many bits do I need to add to the mask to create that number of subnets”?

Let’s look at our network block again:

90.4.0.0./16

And let’s say we wanted to create 14 subnets.  We know from step 2 that we need four bits.

So just add those 4 bits to that slash 16 bit mask you’re good!

16+4 = 20.

90.4.0.0/20 gives us 14 subnets.


Let’s say you wanted to create 8 subnets from 90.4.0.0/16.  Do the finger game again:

  • First is your thumbnail, it’s a 2.  Is that enough? No
  • Your index fingernail is a 4.  Is that enough? No.
  • Your middle fingernail is a 8.  Is that enough? Yes.
    • So count each finger: you need one, two, three; three fingers or three bits to create a subnet with 8 unique hosts.

So how many bits do you need to add to that 16 bit mask to create 8 subnets?

3 right? so 16 + 3 = 19 and your new network is 90.4.0.0/19.

Sexy Subnetting Tips

It’s really helpful to know the mask values in decimal when doing subnetting.  The only way to get this is to memorize it.

What’s so sexy about memorization?  Trust me having a great memory is probably the sexiest thing a guy can have.  It means you’ll remember all these special moments with your wife like the day you first met, the first booger she ate and the first time you farted without caring.

Having a great memory is sexier than huge biceps and a deep voice.  And no, I’m not just saying that because I  don’t have biceps and have a high pitched voice haha.

Anyway, what was I talking about?

Oh yeah – subnetting.  It took me a while to memory the subnet values in decimal but I know them by heart now.  It just takes time and practice.  Commit 5 minutes per day to reviewing these values and you’ll be good by the end of two weeks.

First write out your famous chart:

128, 64, 32, 16, 8, 4, 2, 1

Next turn the mask on for each binary value:

128, 64, 32, 16, 8, 4, 2, 1
  1   0   0   0  0  0  0  0

What is 1000 0000 in decimal? 128.

So if you had the first bit on in the mask but the rest were off you would have 128.0.0.0.

What about the first two bits?

128, 64, 32, 16, 8, 4, 2, 1
  1   1   0   0  0  0  0  0

This is 1100 0000.  What the decimal equivalent?  Just add 128 + 64 and you get 192.

If you kept this trend going you would get this:

128, 64, 32, 16,  8,   4,  2,  1
128 192 224 240 248  252 254 255

Subnet mask decimal values

This means if the first 4 bits of the mask were flipped on, the value would be 240.

What about the first 7?  The value would be 254.

Using the subnet mask

90.4.0.0/16

Let’s take this 16 bit class A network and the 14 subnets we wanted.

We know from step 3, that 14 subnets requires 4 bits.  This changes our mask from /16 to /20.  In other words, we added 3 bits to the mask to make room for our subnet.  So how do we represent this in decimal?

128, 64, 32, 16,  8,   4,  2,  1
128 192 224 240

Most operating system don’t take netmasks in CIDR notation so you’ll need to remember how to get these decimal values.

So a 20 bit mask is the following in dotted decimal notation:

1111 1111 . 1111 1111 . 1111 0000 . 0000 0000
      255 .       255 .       240 .         0

Slash 20 mask

Bam! there you have it.  If you had a computer in this street, 90.4.0.0/20 in one of your 14 subnets would use 255.255.224.0 for he mask.

Listing the streets

So what do your street names look like?  We have 14 subnetworks but what are they?

The first street (network) is 90.4.0.0/20.

To find the next subnet you’ll look at your binary chart again.

128, 64, 32, 16,  8,   4,  2,  1
128 192 224  240

The dividing vertical line is right after the 16 so the block size of each network is 16.

IP address block size

So the second street (network) is 90.4.16.0/20.

Do you see how that works?

Here are the next few:

  • 90.4.32.0/20
  • 90.4.48.0/20
  • 90.4.64.0/20

We just keep multiplying the octet that has the subnet/host name division by the block size.

This continues until we finish all 14 subnets.

These are the networks.

Banging out Broadcast addresses

Okay, I’m getting tired and when I’m tired I make mistakes.  So let’s wrap up with a little talk about Broadcasts, Multicasts and Unicasts.

If you fired up a packet capture while pinging a broadcast address all the hosts in that broadcast domain would receive the frame.

So heres the thing: Whenever you create an IP address it can’t be all ones or all zeros.  All ones are reserved for broadcast addresses and all zeros are reserved for the network names.

For example: 90.4.0.0/16 means the the network name is:

01011010 00000100 00000000 00000000

All those zeros in the last two octets represent the network ID itself.

Similarly, if they were ones it would mean you want to send to the broadcast address.

01011010 00000100 11111111 11111111

There’s also something called a Multicast which is just a host group.  Instead of sending the frame to all hosts in the subnet only those that are part of a multicast group would get it.  And a unicast is message sent from one host to exact one other host.

In summary:

  • Unicast is 1 on 1
  • Multicast is 1 to a group (one to many)
  • Broadcast is 1 to a subnet (one to all)

Yup.

The Bottom Line

If you went through this tutorial from start to finish you should now have an excellent understanding of IP addressing.

  1. In the first Networking 101 IP address guide, you learned how to think about IP addresses and how to convert decimal to binary.
  2. In the second Networking 101 IP address guide, you learned the purpose of IP addresses, private addresses and classes.
  3. In the third Networking 101 IP address guide, you learned all about IPv6 addresses.
  4. In the fourth and final Networking 101 IP address guide you learned how to Subnet!

Whoohoo.

Now you’re ready to take on the world.

Let me know what you thought of the series in the comments below.  By the way, i only accept criticism; I don’t care about praise.   Criticism make me better lol.

Thanks.

About

Connect with Vonnie on Twitter

Posted in Linux, Mac OS X 10.10 Yosemite, Mac OS X 10.8 Mountain Lion, Mac OS X 10.9 Mavericks, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Vista, Windows XP Tagged with: , ,
  • Samy

    Excellent Article ! Thanks a lot.