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.35- (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...


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



RELATED CONTENT
Network Engineering
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
Converged Enhanced Ethernet: New protocols enhance data center 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?

LANs (Local Area Networks)
Integrated wireless and wired LAN: Brocade-Motorola deal ups the ante
Enterprise passive optical networks: a spanning-tree LAN alternative
10 Gigabit Ethernet tutorial: Connecting data centers, storage, LAN and beyond
Intelligent edge switches: Complexity is driving a smarter LAN
Q&A: Jim Metzler previews the networking track at Interop
Extreme's port extender can replace consumer devices at network edge
VLANs versus IP subnets: Why use a VLAN over IP subnetting?
Troubleshooting VLANs: How to monitor 802.1q tagged traffic
Top 10 networking advice of 2008
During a recession, align the network with business priorities

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


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).

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




    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