Understanding IP Addressing and Subnetting

subham_nandi

Subham Nandi

Posted on August 17, 2024

Understanding IP Addressing and Subnetting

In networking, IP addressing is fundamental to routing and identifying devices on a network. IP addresses come in two major versions: IPv4 and IPv6. While IPv6 is gaining traction, IPv4 is still widely used. This article explores IPv4 addressing, subnetting, and provides some practical examples.

1. Physical vs Logical Addressing

  • Physical Addressing (MAC Address):

    • The MAC (Media Access Control) address is a unique identifier assigned to a network interface card (NIC) for communication on the physical network segment.
    • Format: 48-bit address represented in hexadecimal, e.g., 00:1A:2B:3C:4D:5E.
  • Logical Addressing (IP Address):

    • IPv4: A 32-bit logical address divided into 4 octets. Each octet ranges from 0 to 255. Example: 192.168.39.240.
    • IPv6: A 128-bit logical address used for the next generation of IP addressing, providing a vastly larger address space.

2. IPv4 Address Classes

IPv4 addresses are categorized into different classes, primarily A, B, C, D, and E:

  • Class A:

    • Range: 1.0.0.0 to 126.0.0.0
    • Default Subnet Mask: 255.0.0.0
    • Structure: N.H.H.H (N=Network, H=Host)
  • Class B:

    • Range: 128.0.0.0 to 191.255.0.0
    • Default Subnet Mask: 255.255.0.0
    • Structure: N.N.H.H
  • Class C:

    • Range: 192.0.0.0 to 223.255.255.255
    • Default Subnet Mask: 255.255.255.0
    • Structure: N.N.N.H
  • Class D:

    • Range: 224.0.0.0 to 239.255.255.255
    • Usage: Multicasting
  • Class E:

    • Range: 240.0.0.0 to 255.255.255.255
    • Usage: Reserved for research and future use
  • Special Address:

    • 127.0.0.1: Loopback address used for testing and troubleshooting on a local machine.

3. Subnetting

Subnetting is the process of dividing a network into smaller, more manageable sub-networks (subnets). This helps in optimizing the use of IP addresses and improving network performance.

Subnet Masks

A subnet mask is a 32-bit number that segments an IP address into network and host portions. For example:

  • Class A Default Subnet Mask: 255.0.0.0
  • Class B Default Subnet Mask: 255.255.0.0
  • Class C Default Subnet Mask: 255.255.255.0
Binary Conversion Example

To better understand how IP addresses are manipulated in subnetting, converting them to binary is crucial:

  • IP Address: 192.168.37.200
  • Binary Conversion:
    • 192: 11000000
    • 168: 10101000
    • 37: 00100101
    • 200: 11001000

Thus, 192.168.37.200 in binary is 11000000.10101000.00100101.11001000.

4. Private IP Address Ranges

Private IP addresses are used within a private network and are not routable on the public internet. Common ranges include:

  • Class A: 10.0.0.0 to 10.255.255.255
  • Class B: 172.16.0.0 to 172.31.255.255
  • Class C: 192.168.0.0 to 192.168.255.255

5. Network and Broadcast IDs

Each subnet has a Network ID and a Broadcast ID:

  • Network ID: The first address in the subnet, used to identify the network itself.
  • Broadcast ID: The last address in the subnet, used to send data to all devices within the network.

Example with the IP 150.10.20.30 in a Class B network:

  • Network ID: 150.10.0.0
  • Broadcast ID: 150.10.255.255
  • Number of Usable Hosts: 2^16 - 2 = 65,534

6. Practical Subnetting Example

Let's tackle this subnetting problem step by step, starting with Class C and then moving to Class A.

Problem Overview:

We need to subnet a network to create subnets that can support at least 40 hosts each.

Step 1: Subnetting a Class C Network

Original Network:

  • Address: 197.10.10.0/24
  • Default Subnet Mask: 255.255.255.0

Step 1.1: Calculate the Number of Bits for Subnetting

  • Hosts Requirement: At least 40 hosts per subnet.
  • Host Bits Calculation:
    • We need at least 6 bits for the host portion since (2^6 = 64) (where 64 - 2 = 62 usable hosts).

Thus, we’ll use the following subnet mask:

  • Subnet Mask: 255.255.255.192 (/26)

Step 1.2: Create Subnets

We now divide the network into smaller subnets using the /26 subnet mask:

  • Total Subnets: With 2 bits borrowed for subnetting, (2^2 = 4) subnets are created.
  • Hosts per Subnet: (2^6 - 2 = 62) usable hosts per subnet.

Here are the subnets:

  1. 1st Subnet:

    • Network ID: 197.10.10.0/26
    • Range: 197.10.10.0 to 197.10.10.63
    • Broadcast Address: 197.10.10.63
  2. 2nd Subnet:

    • Network ID: 197.10.10.64/26
    • Range: 197.10.10.64 to 197.10.10.127
    • Broadcast Address: 197.10.10.127
  3. 3rd Subnet:

    • Network ID: 197.10.10.128/26
    • Range: 197.10.10.128 to 197.10.10.191
    • Broadcast Address: 197.10.10.191
  4. 4th Subnet:

    • Network ID: 197.10.10.192/26
    • Range: 197.10.10.192 to 197.10.10.255
    • Broadcast Address: 197.10.10.255

Conclusion for Class C:

  • Limitation: While we successfully created 4 subnets, each supporting 62 hosts, a Class C network is limited in the number of subnets and hosts it can support. If you need more subnets or more hosts per subnet, a Class C address might not be sufficient.

Step 2: Subnetting a Class A Network

Let's apply the same logic to a Class A address.

Original Network:

  • Address: 12.0.0.0/8
  • Default Subnet Mask: 255.0.0.0

Step 2.1: Calculate the Number of Bits for Subnetting

  • Hosts Requirement: Again, we need at least 40 hosts per subnet.
  • Host Bits Calculation:
    • As before, we need 6 bits for the host portion, leaving 26 bits for the network portion.

Thus, the subnet mask is:

  • Subnet Mask: 255.255.255.192 (/26)

Step 2.2: Create Subnets

A Class A network offers significantly more flexibility and addresses. Let's create some subnets within the 12.0.0.0/8 range using a /26 subnet mask:

  1. 1st Subnet:

    • Network ID: 12.0.0.0/26
    • Range: 12.0.0.0 to 12.0.0.63
    • Broadcast Address: 12.0.0.63
  2. 2nd Subnet:

    • Network ID: 12.0.0.64/26
    • Range: 12.0.0.64 to 12.0.0.127
    • Broadcast Address: 12.0.0.127
  3. 3rd Subnet:

    • Network ID: 12.0.0.128/26
    • Range: 12.0.0.128 to 12.0.0.191
    • Broadcast Address: 12.0.0.191
  4. 4th Subnet:

    • Network ID: 12.0.0.192/26
    • Range: 12.0.0.192 to 12.0.0.255
    • Broadcast Address: 12.0.0.255

Conclusion for Class A:

  • A Class A address provides an enormous number of subnets and hosts per subnet, making it more suitable for larger networks.
  • Advantages: You can create many more subnets with a large number of hosts each, and even larger networks can be easily accommodated.
💖 💪 🙅 🚩
subham_nandi
Subham Nandi

Posted on August 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related