Week 9: Introduction of subnet mask - M199205zn/Datacomm-CS3 GitHub Wiki

In Cisco networking, a subnet mask is a fundamental concept used to divide an IP address into a network portion and a host portion. It helps routers and devices determine whether an IP address is within the same network or belongs to a different network.


🎯 What is a Subnet Mask?

  • A subnet mask is a 32-bit number that segments an IP address.
  • It uses binary 1s to represent the network part and binary 0s for the host part.
  • It is applied through a bitwise AND operation to determine the network ID of an IP address.

🔄 How Does It Work in Cisco Devices?

Example: IP Address and Subnet Mask

  • IP Address: 192.168.1.10
  • Subnet Mask: 255.255.255.0

Binary Representation:

  • IP Address:
    11000000.10101000.00000001.00001010
  • Subnet Mask:
    11111111.11111111.11111111.00000000

Applying Bitwise AND:

11000000.10101000.00000001.00001010 (IP Address)  
AND  
11111111.11111111.11111111.00000000 (Subnet Mask)  
=  
11000000.10101000.00000001.00000000 (Network Address: 192.168.1.0)
  • The network address is 192.168.1.0, which identifies the specific network.
  • The remaining bits (zeros) define the host range within that network.

Why is Subnet Mask Important in Cisco Networking?

  1. Network Identification:
    • Determines the network portion of an IP address.
  2. Routing Decisions:
    • Cisco routers use the subnet mask to decide whether to route a packet locally or to a remote network.
  3. Subnetting:
    • Helps in dividing a larger network into smaller sub-networks to improve security and reduce congestion.

⚙️ Subnet Mask in Cisco Router Configuration

Here's how you would configure a subnet mask on a Cisco router:

Router> enable
Router# configure terminal
Router(config)# interface GigabitEthernet0/0
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# exit
Router(config)# exit
Router# write memory

Explanation:

  • ip address 192.168.1.1 255.255.255.0 – Assigns the IP and subnet mask to the interface.
  • no shutdown – Activates the interface.
  • write memory – Saves the configuration.

image

🧮 Subnetting Example in Cisco

Suppose you need 4 subnets from the 192.168.1.0/24 network.

  1. Borrow 2 bits from the host portion → Subnet mask becomes /26 or 255.255.255.192.
  2. Subnet Ranges:
    • Subnet 1: 192.168.1.0 - 192.168.1.63
    • Subnet 2: 192.168.1.64 - 192.168.1.127
    • Subnet 3: 192.168.1.128 - 192.168.1.191
    • Subnet 4: 192.168.1.192 - 192.168.1.255

Let's break down the subnetting process step by step for the 192.168.1.0/24 network.


Screenshot 2025-03-12 at 8 28 31 AM
Screenshot 2025-03-12 at 8 29 57 AM
Screenshot 2025-03-12 at 8 30 43 AM
Screenshot 2025-03-12 at 8 31 10 AM
  • This means each subnet will increment by 64 in the last octet.

  • Subnet Breakdown

    Subnet Network Address First Host Last Host Broadcast Address
    1 192.168.1.0 192.168.1.1 192.168.1.62 192.168.1.63
    2 192.168.1.64 192.168.1.65 192.168.1.126 192.168.1.127
    3 192.168.1.128 192.168.1.129 192.168.1.190 192.168.1.191
    4 192.168.1.192 192.168.1.193 192.168.1.254 192.168.1.255

    5. How Many Hosts Per Subnet?

    • Remaining host bits: 6 bits (since we borrowed 2 out of 8).
    • Number of hosts per subnet: 26−2=62 usable hosts2^6 - 2 = 62 \text{ usable hosts} (Subtract 2 for the network and broadcast addresses.)

    Key Points to Remember:

    • Borrowing 2 bits gives you 4 subnets.
    • Each subnet supports 62 usable hosts.
    • The increment in each subnet is 64, based on the block size.
    • The subnet mask 255.255.255.192 reflects the 2 borrowed bits.

    🚀 Key Points to Remember

    • Subnet masks are essential for efficient IP addressing and routing decisions.
    • Cisco devices use subnet masks to differentiate between network and host portions.
    • Proper subnetting enhances network performance and security.

    In Cisco networking, mastering subnet masks is crucial for efficient network design and troubleshooting!


    In networking, an IP address consists of two main parts: the network part and the host part. These parts are determined by the subnet mask. Understanding these concepts is essential for subnetting, routing, and overall network design.


    🎯 1. Network Part

    • The network part of an IP address identifies the specific network to which the device (host) belongs.
    • It is defined by the binary 1s in the subnet mask.
    • All devices within the same network share the same network part of their IP addresses.
    • Routers use this part to determine how to route packets.

    📡 2. Host Part

    • The host part identifies the individual device (like a computer, printer, or router) within a network.
    • It is defined by the binary 0s in the subnet mask.
    • This part must be unique for each device within the same network to avoid IP conflicts.

    🔄 Example: IP Address Breakdown

    Given the following:

    • IP Address: 192.168.1.10
    • Subnet Mask: 255.255.255.0 (or /24)

    Binary Representation

    Type 1st Octet 2nd Octet 3rd Octet 4th Octet
    IP Address 11000000 10101000 00000001 00001010
    Subnet Mask 11111111 11111111 11111111 00000000
    • Network Part: First 26 bits192.168.1.128
    • Host Part: Last 6 bits.2

    Subnet Calculation

    • Network Address: 192.168.1.128
    • First Usable Host: 192.168.1.129
    • Last Usable Host: 192.168.1.190
    • Broadcast Address: 192.168.1.191

    Key Points to Remember

    1. The network part is determined by the 1s in the subnet mask.
    2. The host part is determined by the 0s in the subnet mask.
    3. Devices on the same network part can communicate without a router.
    4. The host part must be unique within the network.

    This distinction helps routers determine how to deliver packets efficiently across networks. 🚀


    Here's an example of how a bitwise AND operation is used to determine the Network ID of an IP address.


    🎯 Given:

    • IP Address: 192.168.10.15
    • Subnet Mask: 255.255.255.0

    🔄 Step 1: Convert to Binary

    Type Decimal Binary
    IP Address 192.168.10.15 11000000.10101000.00001010.00001111
    Subnet Mask 255.255.255.0 11111111.11111111.11111111.00000000

    ⚙️ Step 2: Apply Bitwise AND Operation

    The AND operation compares each bit:

    • If both bits are 1, the result is 1.
    • If either bit is 0, the result is 0.
    IP Address:    11000000.10101000.00001010.00001111  
    Subnet Mask:   11111111.11111111.11111111.00000000  
    -------------------------------------------------  
    Network ID:    11000000.10101000.00001010.00000000  
    

    🧮 Step 3: Convert Back to Decimal

    • 11000000192
    • 10101000168
    • 0000101010
    • 000000000

    Network ID = 192.168.10.0


    🚀 Summary

    • The bitwise AND operation resulted in the Network ID 192.168.10.0.
    • This means the IP 192.168.10.15 belongs to the network 192.168.10.0.
    • All devices within this network will have IPs ranging from 192.168.10.1 to 192.168.10.254, with 192.168.10.255 reserved for the broadcast address.

    This is how Cisco devices (and networks in general) determine if devices are within the same network!

    ⚠️ **GitHub.com Fallback** ⚠️