Home > Networking Tips > Network Engineering > How to subnet: Subnetting calculations and shortcuts
Networking Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

NETWORK ENGINEERING

How to subnet: Subnetting calculations and shortcuts


Mimi Shaw
11.29.2007
Rating: -4.24- (out of 5)


Routing and switching news, advice and technical information
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Whether you need a subnetting cheat sheet or you're preparing for your CCNA exam, this tip shows you how to calculate a subnet mask, break down IP address classes and understand binary. If you're wondering how to figure out what subnet mask to use when you need "x" hosts and "x" networks, this tutorial is the perfect read. Take the interactive quiz at the bottom of this page to find out how much you've learned.

Special thanks to Mimi Shaw for contributing these shortcuts!

When you are going to take a Cisco exam, before the exam starts write the following information down (public and private class address ranges and then the chart) as it will save you a lot of time and headaches.

IP Address Classes
Class A: 1 – 126 (127 reserved for loop-back and diagnostic tests)
Class B: 128 – 191
Class C: 192 – 223
Class D: 224 – 239 (reserved, used primarily for IP multicasting)
Class E: 240 – 254 (reserved, experimental)

Private addresses
Class A: 10.0.0.0 through 10.255.255.255
Class B: 172.16.0.0 through 172.31.255.255
Class C: 192.168.0.0 through 192.168.255.255

1286432168421 
10000000128
11000000192
11100000224
11110000240
11111000248
11111100252
11111110254
11111111255

What the chart represents are the 8-bit values of one octet of an ...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Network Engineering
Desktop virtualization network requirements
Preventing hacker attacks with network behavior analysis IPS
Internal cloud computing on the cheap: Free automated provisioning?
Improved storage performance without adding more disk
Troubleshooting -- 'Network Know-How' Chapter 17
Windows Server 2008 IP routing configuration: Static and dynamic RIPv2
Understand Windows tracert output to troubleshoot network connectivity
Using tracert and TTL to troubleshoot network connectivity problems
10 Gigabit Ethernet interconnect solutions: Investigate carefully before choosing
Optimization of the data center with 10 Gigabit Ethernet

IP Networking
What is the definition of ATM (Asynchronous Transfer Mode)?
Do I have to disable DHCP on my router to create a DHCP server?
Windows Server 2008 IP routing configuration: Static and dynamic RIPv2
What is IP?
Connect your LAN to the Internet using static or dynamic NAT
Using tracert and TTL to troubleshoot network connectivity problems
Test your TCP/IP protocol stack to troubleshoot network connectivity
IP addressing and subnetting explained
Checking IP configuration to troubleshoot Windows network connectivity
Does IPv6 abandon TCP/IP fragmentation?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
32-bit IP addressing  (SearchNetworking.com)
fixed-length subnet mask  (SearchNetworking.com)
GARP (Generic Attribute Registration Protocol)  (SearchNetworking.com)
Port Address Translation (PAT)  (SearchNetworking.com)
route aggregation  (SearchNetworking.com)
route summarization  (SearchNetworking.com)
subnet  (SearchNetworking.com)
subnet mask  (SearchNetworking.com)
variable-length subnet mask  (SearchNetworking.com)
wildcard mask  (SearchNetworking.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


IPv4 IP address. If you add up all of the bits it comes to 255 which is an all 1's mask.

If you are wondering how we get 256 in one octet, there is an implied zero at the end. If you are looking at a network you can have a network address of 192.168.17.0. The modulus of 128 – 0 would be 256. To arrive at the subnet mask we can do one of two things: add the positive bits together or take the least significant positive bit and subtract it from 256.

BIT VALUES OF ONE OCTET
1286432168421(Implied zero) 0Modulus of 128 – 0 would be 256
10000000128Subnet mask
11000000192 
11100000224 
11110000240 
11111000248 
11111100252 
11111110254 
11111111255 

Where the chart comes in handy is if you are being asked what the subnet mask would be for /27. You know that the sum of the first three octets is 24 so you start counting 25 with the first bit (128). Counting to 27 would get you to the third most significant bit (32). Look to the subnet mask column and you see that it is .224.

I had a teacher (Jeremy Cioara -- he has written several Cisco books), and he gave the story of a guy that owned a brick company. He had a lot with a lot of bricks and people would come and buy bricks. As the guy got more successful he had to figure out a way of putting the bricks in piles so it would be quick and easy to give them the number of bricks they wanted. He then put the bricks on pallets in the following quantities: 128, 64, 32, 16, 8, 4, 2 and 1. As a result, it was easy to come up with quantities for a customer. For example, if a customer wants 188 bricks, you would give them one of the 128 pallets. They are 60 bricks short. You sure as heck are not going to give him a 64-brick pallet because you would loose money so you give him a 32-brick pallet. You are now 28 bricks short so you give him a 16 brick pallet. You are still 12 bricks short so you give him an 8-brick pallet and a 4-brick pallet. Here is the binary of 188:
1286432168421
10111100

Jeremy used this method when you had the question of what subnet mask to use when you need "x" hosts and "x" networks.

I then had another teacher who used to do the 2-2 table. That's a little too complicated when you are going against time in a Cisco exam.

Here's how I determine networks/hosts. You know that you have to subtract two because you need one end for the network and one end for the broadcast address (subnet mask). So, when you get to a bit value (i.e., 128, 64, 32 etc.) you subtract two and the remainder will be the hosts.

Let's say that you are told that you have 57 hosts and are asked for the subnet mask. Easy. When you go to the chart and you find that 57 is more than 32 but less than 64. Try to think 30 and 62 because you are thinking hosts. You would use the second bit, 64, and so if you go to the right side for the subnet mask it would be .192.

If you are asked for valid hosts in the 192.168.30.7/28 range you start out by counting off the chart to see the numerical value for the 28th bit. It is 16. Then take a look at the last octet (since 28 puts us in the last octet range) and divide it by 16. In this case we don't have to because we can see it is less than 16 but if you are given .189 rather than .7 you would divide 189 by 16 and see that it was over 11. Then multiply 11 times 16 to see the first address in that subnet -- 176. Then add 16 to 176 and you will get the first address of the next subnet (192). That means that .189 falls in the subnet 176 – 188. We know that the first number is the network address (192.168.30.176) and the last number is the broadcast address (255.255.255.188 -- remember we are breaking down that 256 block so we can't use the full 256 subnet, only the portion blocking our network). That means that the hosts must fall in the range of 177 – 187 (one after 176 and one before 188).

Going back to our question of valid hosts in the 192.168.30.7/28 range they would be:

192.168.30.1
192.168.30.2
192.168.30.3
192.168.30.4
192.168.30.5
192.168.30.6
192.168.30.7
192.168.30.8
192.168.30.9
192.168.30.10
192.168.30.11
192.168.30.12
192.168.30.13
192.168.30.14

And if you counted them up you would see there are 14 of them. Remember the 2-2 formula -- it is the bit value minus 2 (one for network and one for broadcast address or subnet mask) equals the number you can use for hosts.

If you want to know how many of these 16-bit networks we can get out of that third octet, divide 256 by 16. It is 16. Don't slip and think that the number of networks you can get is the bit value -- it just works out that way with /28. For a /26 you can get four networks (0 – 63; 64 – 127; 128 – 191 and 192 – 255 (and I didn't use the number 256 because I started at zero -- the modulus (value of 256) comes from zero to 255).

There is another way to figure out how many 16-bit networks you can get out of an octet. If you take a look at our bit values of 128, 64, 32, 16, 8, 4, 2 and 1, double the number of networks per bit value starting with 2 for 128. You would then have 4 for 64, 8 for 32, 16 for 16, 32 for 8, 64 for 4 and 128 for 2. This is easier than dividing 256 by 16 to see that you can have 16 networks.

If you are given a problem asking the subnet mask of 172.16.64.0/18, go back to the chart, and when you start counting at the first bit (128) think of it as being in the third octet rather than the forth octet so /18 would be the second bit (64) and the subnet mask would be .192.

By the way, if they asked you how many hosts you would have it is easy. You've noticed that the bit values are cut in half for descending order so you just double them for ascending. Start with your most significant bit of the last octet (128) and multiply it by two to come up with the bit value of the least significant bit of the third octet and keep doubling.
/17/18/19/20/21/22/23/24/25/26etc.
3276816384819240962048102451225612864 

On a /18 network you would have 16382 hosts (16384 – 2).

That's the theory of my easy way to do subnetting. Here are some example questions:

This tip originally appeared on HappyRouter.com.


Rate this Tip
To rate tips, you must be a member of SearchNetworking.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Networking Solutions for Business

Alcatel-Lucent Network Business Communications Solutions

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts