Home > Networking Tips > Network Engineering > IP addressing and subnetting: Calculate a subnet mask using the host's formula
Networking Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

NETWORK ENGINEERING

IP addressing and subnetting: Calculate a subnet mask using the host's formula


David Davis
11.13.2006
Rating: -4.31- (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


In this article, we will continue learning important IP addressing and subnetting information, and we will learn how to apply this valuable information to some real-world scenarios.

Review

Before we move on, I'd like to review some information that was covered in part one of this series, IP addressing and subnetting: What network administrators need to know.

  • IP addresses must be unique on the Internet (when using public IP addresses) and on a private network (when using private IP addresses).
  • DHCP is commonly used to hand out IP addresses. This helps to keep addresses unique, provides a database of addresses assigned and prevents administrators from having to assign addresses statically.
  • IP addresses are 32 bits (made up of four octets of 8 bits each).
  • A subnet mask is what tells the computer what part of the IP address is the network and what part is for the host computers on that network.
  • Subnetting is the process of breaking a large network into smaller networks by adding 1s to the subnet mask.
  • Today, classless IP addresses are used almost exclusively, and classful IP addresses are used only for certification testing or older routing protocols.
  • A default gateway is where a device sends packets that are destined for a device not on the local LAN. Again, the device knows what is and what is not on the local LAN by the subnet mask.
  • Private IP addresses are used by most networks today, and these special, non-routable IP addresses are translated to public Internet IP addresses when those devices need to talk to the Internet.
Now, let's learn more important IP address and subnetting information and how it applies to your real-world network.

Using the host's formula

A common real-world question when laying out your network is: "What subnet mask do I need for my network?" To answer this question, let's learn how to use the "host's formula." The host's formula will tell you how many hosts will be allowed on a network that has a certain subnet mask. The host's formula is 2n - 2. The "n" in the host's formula represents the number of 0s in the subnet mask, if the subnet mask were converted to binary (we will talk about this soon).

More network engineering tips from David Davis
IP addressing and subnetting: What network administrators need to know

IP addressing and subnetting: Calculate a subnet mask using the subnet's formula

Binary-to-decimal conversion

Duplex mismatch
To use the host's formula, let's first look at a simple example. Say that you have the IP address space 192.168.0.0. Currently, you have a small network with 20 hosts. This network may grow to 300 hosts within the next year, however, and you may have multiple locations in time and need to allow for them to communicate using this address space. With only 20 hosts, the simplest thing to do would be to use 255.255.255.0 as your subnet mask. This would mean that you would have 192.168.0.x as your network and x.x.x.0-255 for your hosts.

Before you decide to use this subnet mask, however, let's apply the host's formula to it. To use the host's formula in this scenario, you take the subnet mask (255.255.255.0) and convert it to binary (for more information, see my binary-to-decimal conversion article). This would give you:
111111111 11111111 11111111 00000000

The host's formula is 2 n - 2, where "n" is the number of zeros in the subnet mask. As you can count, there are eight zeros in the subnet mask. To use this with the host's formula, you would calculate 28 - 2. This comes to 256 minus 2, or 254. So, with the subnet mask specified, you will get 254 usable hosts. This would suit your 20-user network now but won't support your future network host expectations of 300 hosts.

It is in your best interest to plan ahead and choose the best subnet mask the first time. This prevents you from having to come back later and change all the IP addresses on this network. If you remember from part one, adding 1s to the subnet mask means that you get fewer hosts per network but more networks. If you take away 1s from the subnet mask, you get more hosts per network but fewer networks. The latter is what we need to do.

To do this, let's take away one of the 1s to make our subnet mask:
11111111 11111111 11111110 0000000
In decimal, this is 255.255.254.0

This means that you have nine 0s in the subnet mask. To apply the host's formula with this subnet mask, what we would calculate is 29 - 2. This comes to 512 minus 2, or 510. So, with the subnet mask specified, you will get 510 usable hosts. This would definitely suit your 20-user network now and your future network host expectations of 300 hosts.

Considering that information, we know that the most efficient subnet mask for our network is 255.255.254.0. Our valid hosts are 192.168.1-255 and 192.168.1.0-254. That is how you arrive at the total of 510 usable hosts.

It is important to understand this and be able to calculate it longhand, but I verify my calculations with a subnet calculator like Solarwind's subnet calculator or Boson's subnet calculator.

You can use the host's formula to calculate "what-if" scenarios to determine the most efficient subnet mask for the size of your networks.

  • Continue reading the next part of this series, where we discuss using the subnet's formula.

    About the author:
    David Davis (CCIE #9369, CWNA, MCSE, CISSP, Linux+, CEH) has been in the IT industry for 15 years. Currently, he manages a group of systems/network administrators for a privately owned retail company and authors IT-related material in his spare time. He has written more than 50 articles, eight practice tests and three video courses and has co-authored one book. His Web site is 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




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


    RELATED CONTENT
    Network Engineering
    Limit network energy consumption with computer cooling technologies
    Understanding remote scripting -- Managing Windows networks using scripts, part 9
    Network mapping in Vista for Windows XP
    Recovering domain controllers after a server disk failure
    Recovering from a server disk failure: The shortcomings of NTBCKUP
    Enabling Windows Vista's Network Mapping feature on domain networks
    Prevent unauthorized USB devices with software restriction policies, third-party apps
    How to subnet: Subnetting calculations and shortcuts
    Using Windows Vista group policy to prevent unauthorized USB device use
    ISDN implementation: Part 3 -- Cisco router ISDN configuration

    IP Addressing
    Do multiple router interfaces affect the amount of IP addresses?
    How to locate the lost IP address of an Access Point (AP)
    IPv4 or IPv6 -- Myths and Realities
    What is a logical network? How do you improve one?
    Why are IPv6's IP addresses in hexadecimal formatting?
    Understanding VLAN implementation and IP address assignment
    Prevent IP address conflicts on your wireless network by managing DHCP scopes
    Get IPv6 skills now rather than later
    How can I check connectivity and ping between sites?
    Can I connect to my wireless network and wired LAN simultaneously?

    LANs (Local Area Networks)
    College IT department transforms itself with network management tools
    Accessing printers on a LAN while connected to a WLAN.
    What makes a WAN different from a LAN and MAN?
    Losing the war to lock down networks might help enterprises innovate
    Prevent unauthorized USB devices with software restriction policies, third-party apps
    Can users on my LAN view my computer from other machines?
    LAN network design considerations
    Configuring VLANs
    Can my router configure devices into a LAN environment?
    What is interVLAN routing?

    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)
    route aggregation  (SearchNetworking.com)
    route summarization  (SearchNetworking.com)
    routing table  (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

    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
    IT Management Solutions and Services Directory.
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersNetworking Product Trials
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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