# Networking Fundamentals: Subnetting

Subnetting involves dividing a network into more manageable sub-networks. Within IPv4 addressing, an IP address comprises four octets, each containing eight bits, culminating in a total of thirty-two bits. These octets are expressed in decimal format and are separated by dots, exemplified by `11111111.11111111.11111111.00000000`, which translates to `255.255.255.0`. The Subnet Mask allows devices to determine the range of addresses within their network, from the network address to the broadcast address.

For instance, given an IP address of `192.168.1.5` with a subnet mask of `255.255.255.128`, the device knows that the Network address is `192.168.1.0` and the Broadcast Address is `192.168.1.127`.

Each bit in the octet represents a value:

```plaintext
128  64  32  16  8  4  2  1
1    1   1   1   1  1  1  1
```

When added together (`128+64+32+16+8+4+2+1`), the result is `255`.

### **Network Class Ranges**

IP addresses are classified into different classes based on the value used. Private IP addresses are commonly used in LAN networks and cannot be routed on the public Internet. Subnetting enables the subdivision of these private IP addresses to accommodate varying numbers of hosts, depending on the subnet mask used. The subnet mask distinguishes the network portion (network bits) of the address from the host portion (host bits).

#### Typical Private Range Masks

* **Class A:** `255.0.0.0`
    
    ```plaintext
    11111111.00000000.00000000.00000000
    [-network-].[-----------------host---------------]
    ```
    
* **Class B:** `255.255.0.0`
    
    ```plaintext
    11111111.11111111.00000000.00000000
    [----network----].[------host------]
    ```
    
* **Class C:** `255.255.255.0`
    
    ```plaintext
    11111111.11111111.11111111.00000000
    [--------network---------].[---host---]
    ```
    

### **CIDR Notation**

CIDR notation provides a simpler method for representing subnet masks. For example, if the subnet mask being used in a Class C network is `255.255.255.240`, the CIDR notation would be `/28`, indicating that four bits have been borrowed from the host portion. The borrowed bits are indicated below:

```plaintext
255.255.255.240 = 11111111.11111111.11111111.11110000
```

Here are a few examples to review. Below are a few practice questions.

### **Example 1: Office Network**

* **Network Address:** 192.168.0.0
    
* **Subnet Mask:** 255.255.255.0 (Class C)
    
* **Number of Subnets:** 4
    
* **Number of Hosts per Subnet:** 30
    
* **Subnet Ranges:**
    
    * Subnet 1: 192.168.0.0 - 192.168.0.31
        
    * Subnet 2: 192.168.0.32 - 192.168.0.63
        
    * Subnet 3: 192.168.0.64 - 192.168.0.95
        
    * Subnet 4: 192.168.0.96 - 192.168.0.127
        

### **Example 2: University Campus Network**

* **Network Address:** 10.0.0.0
    
* **Subnet Mask:** 255.255.255.128 (Class A)
    
* **Number of Subnets:** 8
    
* **Number of Hosts per Subnet:** 126
    
* **Subnet Ranges:**
    
    * Subnet 1: 10.0.0.0 - 10.0.0.127
        
    * Subnet 2: 10.0.0.128 - 10.0.0.255
        
    * Subnet 3: 10.0.1.0 - 10.0.1.127
        
    * Subnet 4: 10.0.1.128 - 10.0.1.255
        
    * Subnet 5: 10.0.2.0 - 10.0.2.127
        
    * Subnet 6: 10.0.2.128 - 10.0.2.255
        
    * Subnet 7: 10.0.3.0 - 10.0.3.127
        
    * Subnet 8: 10.0.3.128 - 10.0.3.255
        

### **Example 3: Small Business Network**

* **Network Address:** 172.16.0.0
    
* **Subnet Mask:** 255.255.255.240 (Class B)
    
* **Number of Subnets:** 16
    
* **Number of Hosts per Subnet:** 14
    
* **Subnet Ranges:**
    
    * Subnet 1: 172.16.0.0 - 172.16.0.15
        
    * Subnet 2: 172.16.0.16 - 172.16.0.31
        
    * ...
        
    * Subnet 16: 172.16.0.240 - 172.16.0.255
        

Now, here are 10 subnet practice questions for study:

1. Given the IP address 192.168.1.100 with a subnet mask of 255.255.255.192, what is the network address?
    
2. How many subnets can you create from the IP address range 172.16.0.0 to 172.16.15.255 with a subnet mask of 255.255.240.0?
    
3. What is the broadcast address for the subnet 10.0.5.0/24?
    
4. If you have a Class C network with a subnet mask of 255.255.255.192, how many usable IP addresses are available per subnet?
    
5. Given the IP address 10.10.10.200 and a subnet mask of 255.255.255.128, what subnet does it belong to?
    
6. How many host bits are available in a subnet with a CIDR notation of /28?
    
7. What is the CIDR notation for the subnet mask 255.255.255.248?
    
8. If a network address is 192.168.1.0/24, what is the last valid host address?
    
9. How many bits are borrowed for subnetting in a Class B network with a subnet mask of 255.255.252.0?
    
10. What is the subnet address for the IP address 172.16.32.100/22?
    

For the answer key, leave a comment.
