More
    Ethical HackingSubnetting & Subnet Mask - The Complete Guide

    Subnetting & Subnet Mask – The Complete Guide

    Before jumping into the context of Subnet Mask, Subnetting, and what actually are subnets, let us take a simple example.

    - 'A' wants to send a letter to 'B' in the same city. There are about 1000's of people out there inside the city.
    - The delivery agent will go to each of the person inside the city, and ask them if they are 'B'. This will take a lot of time to search 'B' this way.
    - What we can do, is to tell the delivery agent, that 'B' belongs to a colony with address 'Addr'.
    - The delivery agent will go to the colony with address 'Addr', and then search for 'B'.
    - This reduced the time of searching for 'B' exponentially. 

    Similarly, whenever a packet is sent by one machine to another machine over a network, the router needs to find the location of the target machine.

    To make this process faster, a network is divided into multiple subnets, which we can relate to colonies inside a city, as we discussed in the example above.

    Let’s understand, how this actually works.

    But before that, we need to understand the basic structure of an IP Address.

    IP Address:

    An IP Address is a notation which is used to assign a unique identifier to every device, connected over a network.

    An example of an IPv4 address is 192.168.4.2

    IPv4 means that an IP address is separated into 4 parts using a period (.)

    The IP Address is further classified into different classes.

    Class A:

    The IP Addresses, which fall under Class A denotes that the part that appears before the first period will be used for Network Addressing, and rest of the part will be used for Host Addressing.

    For example,

    192.168.4.8

    In this IP Address, 192 represents the network address, and 168.4.8 represents host address.

    Class B:

    The IP Addresses, which fall under Class B denotes that the part that appears before the 2nd period will be used for Network Addressing, and rest of the part will be used for Host Addressing.

    For example,

    192.168.4.8

    In this IP Address, 192.168 represents the network address, and 4.8 represents host address.

    Class C:

    The IP Addresses, which fall under Class C denotes that the part that appears before the third period will be used for Network Addressing, and rest of the part will be used for Host Addressing.

    For example,

    192.168.4.8

    In this IP Address, 192.168.4 represents the network address, and 8 represents host address.

    More about IP Address:

    In our previous example, 192.168.4.8, this IP Address is divided into 4 parts, and each of these parts consists of number ranging from 0 to 255.

    Each part of an IP Address is made up of 8 bits. This means that the maximum IPv4 Address which we can have is 255.255.255.255, and the minimum is 0.0.0.0

    When you would write 255 into binary form, you would get something like,

    11111111.11111111.11111111.11111111

    This is the binary form of 255.255.255.255

    If you count up the bits, there are exactly 32 bits, and mathematically, there can be 232 (4,29,49,67,296) unique IPv4 addresses.

    Subnet Mask:

    A subnet mask is basically an IP Address that remains constant throughout a network.

    It is used to define the part which will be used for network, and which for host.

    For example,

    Group A has a Subnet Mask of 255.0.0.0

    Group B has a Subnet Mask of 255.255.0.0

    Group C has a Subnet Mask of 255.255.255.0

    Let us take another example,

    We have a router connected to a network. It has a subnet mask of 255.255.224.0
    
    Converting this mask into its binary form will give us,
    11111111.11111111.11100000.00000000
    
    Here,
    255 in binary format is 11111111
    224 in binary format is 11100000
    
    Thus, the devices connected over this network will have their network addressing as [11111111.11111111.111] and host addressing as [00000.00000000]
    Suppose, you have an IP Address 192.168.5.6
    
    How would you know which subnet mask, or group this IP address belong to?
    
    For that, we write an IP Address in CIDR notation.
    CIDR notation is a compact representation of an IP address and its associated network mask.
    
    If we write 192.168.5.6/24
    This means that, we have 24 bits covered by the subnet mask for network address. Thus, this IP Address belong to Group C, as in Group C, we have 255.255.255.0 subnet mask, which in binary notation is,
    11111111.11111111.11111111.00000000
    We have 24 ones here.
    
    If we write 192.168.9.10/16
    This means that, we have 16 bits covered by the subnet mask for network address. Thus, this IP Address belong to Group B, as in Group B, we have 255.255.0.0 subnet mask, which in binary notation is,
    11111111.11111111.00000000.00000000
    We have 16 ones here.

    Subnetting:

    Subnetting is the process of dividing a network into various subnets/subnetworks.

    Let us take an example to understand it

    One day, your supervisor walks to you, saying, here is the network ID 192.168.4.0/24.
    Please create three separate networks for a coffee shop. One for the cash counter, one for the front desk, and one is for public use.
    
    You task is to list each network ID, Subnet Mask, Host ID range, Number of Usable Host IDs, and Broadcast ID.

    In the task above, we have to create 3 subnets, out of 192.168.4.0/24 network ID.

    Since this network ID belong to Group C, we can draw table like this,

    subnetting-group-c

    We will select the column with 4 subnets, as we have to create 3 subnets, and minimum number of subnets greater than 3 are 4.

    The new subnet mask is /26, and there are 64 hosts per subnet. Out of that 64 hosts, we have 2 hosts pre-occupied.

    One for the subnet IP, and the other for Broadcast ID.

    subnet-answer

    Thus, we will have 4 subnets, with Network ID, Subnet Mask, Host ID Range, # of Usable Host, and Broadcast ID, as shown in table above.

    Now, we can use any 3 subnets of these 4 subnets created.

    Read More: Sherlock – Passive Reconnaissance Tool

    Sponsored

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    Subscribe Today

    GET EXCLUSIVE FULL ACCESS TO PREMIUM CONTENT

    Get unlimited access to our EXCLUSIVE Content and our archive of subscriber stories.

    Exclusive content

    Latest article

    More article