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.
- 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.
-
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.
-
Network Identification:
- Determines the network portion of an IP address.
-
Routing Decisions:
- Cisco routers use the subnet mask to decide whether to route a packet locally or to a remote network.
-
Subnetting:
- Helps in dividing a larger network into smaller sub-networks to improve security and reduce congestion.
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
-
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.
Suppose you need 4 subnets from the 192.168.1.0/24
network.
- Borrow 2 bits from the host portion → Subnet mask becomes
/26
or255.255.255.192
. - 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
- Subnet 1:
Let's break down the subnetting process step by step for the 192.168.1.0/24 network.




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 |
- 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.)
- 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.
- 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.
- 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.
- 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.
Given the following:
-
IP Address:
192.168.1.10
-
Subnet Mask:
255.255.255.0
(or/24
)
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 bits →
192.168.1.128
-
Host Part: Last 6 bits →
.2
-
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
- The network part is determined by the 1s in the subnet mask.
- The host part is determined by the 0s in the subnet mask.
- Devices on the same network part can communicate without a router.
- 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.
-
IP Address:
192.168.10.15
-
Subnet Mask:
255.255.255.0
Type | Decimal | Binary |
---|---|---|
IP Address | 192.168.10.15 | 11000000.10101000.00001010.00001111 |
Subnet Mask | 255.255.255.0 | 11111111.11111111.11111111.00000000 |
The AND operation compares each bit:
- If both bits are
1
, the result is1
. - If either bit is
0
, the result is0
.
IP Address: 11000000.10101000.00001010.00001111
Subnet Mask: 11111111.11111111.11111111.00000000
-------------------------------------------------
Network ID: 11000000.10101000.00001010.00000000
-
11000000
→192
-
10101000
→168
-
00001010
→10
-
00000000
→0
✅ Network ID = 192.168.10.0
- The bitwise AND operation resulted in the Network ID
192.168.10.0
. - This means the IP
192.168.10.15
belongs to the network192.168.10.0
. - All devices within this network will have IPs ranging from
192.168.10.1
to192.168.10.254
, with192.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!