Networks Training

  • About
  • My Books
  • SUGGESTED TRAINING
  • HOME
  • Cisco Networking
    • Cisco General
    • Cisco IOS
    • Cisco VPN
    • Cisco Wireless
  • Cisco ASA
    • Cisco ASA General
    • Cisco ASA Firewall Configuration
  • Certifications Training
    • CCNA Training
    • Cisco Certifications
    • I.T Training
  • General
    • General Networking
    • IP Telephony
    • Network Security
    • Product Reviews
    • Software
  • Cisco Routers
  • Cisco Switches
You are here: Home / General Networking / What is a Subnet Mask Used For (on Routers and Hosts)

What is a Subnet Mask Used For (on Routers and Hosts)

Written By Harris Andrea

This is a post for people new to networking that have just started learning IP addressing and the basis of routing and subnetting.

explanation of subnet masks

Every host or device on a TCP/IP network MUST have an IP address assigned in order to communicate with other devices.

An IP address consists of a network part and a host part. Think about the Network part as a multi dueling Building Address number, and the Host part as your apartment number inside this building.

For example, building address “Building XYZ” is the network IP address part, and “Apartment number 2” is the host address part.    

For example IP address 10.0.0.2 which identifies a single host, contains the network part 10.0.0 and the host part 2.

Now, how do devices on the network know which portion is the network part and which is the host part of their assigned IP address?

They know this information using the “Subnet Mask”. Every host on a TCP/IP network is configured with an IP address AND a subnet mask.

The subnet mask is the one which identifies the Network Part portion of the IP address assigned to the host.

For our example above, the host with IP 10.0.0.2 is assigned also a subnet mask 255.255.255.0. If you do a logical AND operation between the IP address and the subnet mask, you will find the Network potion of the address:

MORE READING:  10 Networking Companies Like Cisco (Competitors)

10.0.0.2 AND 255.255.255.0 = 10.0.0.0  (The network part is 10.0.0 and the remaining part is the host part. i.e 2 ).

Let’s see a diagram below:

From the picture above, Host A and Host B belong to the same local subnetwork (10.0.0.0/24) and are connected to the same switch together with a router interface. The router interface has also an IP address 10.0.0.254 with the same subnet mask 255.255.255.0 as the two Hosts.

Also, two other hosts (Host C, Host D) belong to another subnetwork (10.1.1.0/24) together with the second interface of the router which has address 10.1.1.254.

Each host has also a default gateway assigned (in addition to IP address and Subnet Mask). Hosts A and B must be configured with a default gateway address of the router interface which is 10.0.0.254.

Similarly, Hosts C and D must be configured with a default gateway address of their router which is 10.1.1.254.

How Hosts use the Subnet Mask

When a host wants to communicate with another host, it uses its subnet mask to compare the network portion of its local network IP address with the destination network address of the packet to be sent.

Before an end system can send a packet to its destination, it must first determine whether the destination address is on the local network.

This is done by comparing the bits in the destination address with the network bits of its own IP address. For example, if Host A wants to send a packet to Host B, it will take the destination address 10.0.0.2 (Host B) and perform an AND operation with its subnet mask.

MORE READING:  Best Network Ethernet Switches - Gigabit-Managed-Unmanaged

The result will be 10.0.0.0 which will tell Host A that the destination address belongs to the same subnetwork as itself.

Therefore it will NOT send the packet to the default gateway (router). Rather, Host A will perform an ARP request (Address Resolution Protocol) to find out the destination MAC address of Host B (ARP protocol maps an IP address with a MAC address).

Therefore, Host A will send the packet directly to Host B through the switch without going through the router.

Now, if Host A wants to send a packet to Host C, it will take the destination address 10.1.1.1 of Host C and perform an AND operation with its subnet mask.

The result will be
10.1.1.1 AND 255.255.255.0 = 10.1.1.0

which will tell Host A that the destination address has a different network portion than itself (10.1.1).

Therefore Host A will have to send the packet to its default gateway (router address 10.0.0.254) in order to reach Host C on the other side of the router.

The router will check the destination IP address in the IP packet and will forwards the traffic to the correct interface (according to its routing table).

Related Posts

  • Comparison of EIGRP vs OSPF Routing Protocols
  • 12 Best Computer Networking Books for Beginners & Experts
  • 10 Networking Companies Like Cisco (Competitors)
  • Comparison of VLAN vs Subnet in TCP/IP Computer Networks
  • All About Syslog Protocol (What is Syslog, Default Port, Purpose etc)

Filed Under: General Networking

Download Free Cisco Commands Cheat Sheets

Enter your Email below to Download our Free Cisco Commands Cheat Sheets for Routers, Switches and ASA Firewalls.

We use Elastic Email as our marketing automation service. By submitting this form, you agree that the information you provide will be transferred to Elastic Email for processing in accordance with their Terms of Use and Privacy Policy. Also, you allow me to send you informational and marketing emails from time-to-time.

About Harris Andrea

Harris Andrea is an Engineer with more than two decades of professional experience in the fields of TCP/IP Networks, Information Security and I.T. Over the years he has acquired several professional certifications such as CCNA, CCNP, CEH, ECSA etc.

He is a self-published author of two books ("Cisco ASA Firewall Fundamentals" and "Cisco VPN Configuration Guide") which are available at Amazon and on this website as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search this site

About Networks Training

We Provide Technical Tutorials and Configuration Examples about TCP/IP Networks with focus on Cisco Products and Technologies. This blog entails my own thoughts and ideas, which may not represent the thoughts of Cisco Systems Inc. This blog is NOT affiliated or endorsed by Cisco Systems Inc. All product names, logos and artwork are copyrights/trademarks of their respective owners.

Amazon Disclosure

As an Amazon Associate I earn from qualifying purchases.
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.

Search

Suggested Cisco Training

CISCO CERTIFICATION TRAINING
CISCO CCNA 200-120 TRAINING
CCNA SECURITY 640-554 TRAINING
CCENT ICND1 TRAINING
CISCO ICND2 TRAINING
CISCO CCNP TRAINING

BLOGROLL

Tech21Century
Firewall.cx

Copyright © 2022 | Privacy Policy | Terms and Conditions | Hire Me | Contact | Amazon Disclaimer | Delivery Policy

0 shares