Skip to main content

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

IP addressing and subnetting are an important if basic part of networks. Network administators will learn how to calculate a subnet mask using the host's formula.

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

Comments

Popular posts from this blog

Interpreting the output of lspci

On Linux, the lspci command lists all PCI devices connected to a host (a computer). Modern computers and PCI devices communicate with each other via PCI Express buses instead of the older Conventional PCI and PCI-X buses since the former buses offer many advantages such as higher throughput rates, smaller physical footprint and native hot plugging functionality. The high performance of the PCI Express bus has also led it to take over the role of other buses such as AGP ; it is also expected that SATA buses too will be replaced by PCI Express buses in the future as solid-state drives become faster and therefore demand higher throughputs from the bus they are attached to (see this article for more on this topic). As a first step, open a terminal and run lspci without any flags (note: lspci may show more information if executed with root privileges): lspci   This is the output I get on my laptop: 00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Co

Boot process hangs at dracut: Switching root

Environment Red Hat Enterprise Linux 6 Issue When server is booting the boot process hangs at  dracut: Switching root , and never displays anything else. Raw device-mapper: ioctl: 4.33.1-ioctl (2015-8-18) initialised: xx-xxxx@redhat.com udev: starting version 147 dracut: Starting plymouth daemon dracut: rd_NO_DM: removing DM RAID activation dracut: rd_NO_MD: removing MD RAID activation scsi0 : ata_piix scsi1 : ata_piix ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc120 irq 14 ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc128 irq 15 Refined TSC clocksource calibration: 2599.999 MHz. virtio-pci 0000:00:03.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ 11 virtio-pci 0000:00:05.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, high) -> IRQ 10 virtio-pci 0000:00:07.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ 11 virtio-pci 0000:00:08.0: PCI INT A -> Link[LNKD] -> GSI 11 (level, high) -> IRQ 11 input: ImExPS/2 Gener

How to get the SAN environment information and statistics on AIX, HP-UX, Linux, Solaris, and Windows

How to get the SAN environment information and statistics on AIX, HP-UX, Linux, Solaris, and Windows Description NetBackup SAN Client is supported on the Linux , Solaris, Windows, HP-UX and AIX operating systems.  These environments provide the initiator device driver which can login to the SAN client media server and mount an pseudo   target device “ARCHIVE PYTHON” so that the backup or restore can be use the fiber transport (FT).  If there is an issue in the SAN environment, it is necessary to get the information/statistics from the SAN fabric for analysis.  The commands below can be used, on the respective operating system, to gather the necessary information. If the outputs show many or steadily increasing error counts, that indicates one or more issues with  the fabric  infrastructure. The issue(s) can be caused by cabling, SFP, san switch, DWDM, HBA or ISL and those components will need to be analyzed and evaluated.  Linux Get the hardware information fo