Understanding how to design an IP address scheme to a network would be an important skill for any networking engineer as well as to solve many Cisco certification problems.

Consider the following example wherein there are 3 LANs connected via 2 routers. The IP address block **192.168.1.0/24** need to be used across all the networks.

There are six steps to efficiently use the available IP address space and build a hierarchical network.

1. Determine the network and host requirement.

2. Satisfy the network and host requirement.

4. Determine the network addresses.

5. Determine the directed broadcast addresses.

6. Determine the host addresses.

**1. Determine the network and host requirement**

In this step the network engineer determines two things,

i) The number of network segments in the network

ii) The segment having the largest number of hosts

When counting the number of segments one should consider the logical segments such as VLANs plus additional growth in future. In the example there are 4 segments — 3 switched LANs + 1 WAN between the routers.

The segment having the largest number of hosts is the one connected to switch-3. Since the number of hosts in the largest segment is 14, 4 bit subnetting is optimal (2^4 – 2=14). This would yield 16 (2^4) subnets each with 14 hosts.

**2. Satisfy the network and host requirement**

In this step three formulas are used.

i) 2^s >= the no. of network segments

ii) 2^h-2 >= the no. of hosts in the largest segment

iii) s+h <= the no. of host bits in the address class

where s is the no. of subnet bits and h is the no. of host bits.

2^4 = 16 which more than the number of network segments in the example (4). 2^4 -2 = 14 which is equal to the number of hosts in the largest segment. And s+h = 4+4=8 which is equal to the default number of host bits of Class C address.

Note that if s+h exceeds the number of hosts bits in the default address class, then either you have to use two Class C addresses or a Class B address that supports more number of hosts.

**3. Determine the subnet mask**

The rest of the steps are quite easy. The number of subnet bits determines value of the subnetted octet. The 192.168.1.0 is a Class C address; hence the first three octets defaults to 255. The fourth octet has 4 subnet bits and 4 host bits. Hence its value in binary 11110000 which is 240. So the subnet mask is **255.255.255.240.**

**4. Determine the network addresses**

Determining the network addresses of the 16 subnets is done by first finding the step-size or the block size by which the subnet gets incremented.

As the number of hosts in each subnet is 14 plus network and directed broadcast address, each subnet increments by 16. That’s the block size. There are several shorthand methods to find the block size.

**Shortcut #1 Subtraction**: Subtract the subnet value in the *interesting octet* from 256. The subnet mask 255.255.255.240. The value of the subnetted octet is 240. **256-240=16, **the block size.

**Shortcut #2 Magic number**: Write the binary value of the subnetted octet and the place value of the right most one is the magic number.

Hence 16 is the magic number (aka block size). The networks hence are

Notice the last network. This is true in every subnetting scenario, the last octet of the last network overlaps with that of the subnet mask (255.255.255.240).

**5. Determine the directed broadcast addresses**

The directed broadcast address is one less than the next network address in the address space. The last directed broadcast address always ends with 255.

**6. Determine the host addresses**

The valid host addresses that can be assigned to nodes are the addresses between the network address and the directed broadcast address.

As you can see now the address space is efficiently utilized and the nodes can be assigned with any address within the chosen subnet. The subnet mask for every IP address is * 255.255.255.240*.

I’ve learnt the magic number concept from Dan. Thanks to him.