DEV Community

Yusuf Isah
Yusuf Isah

Posted on • Originally published at yuscode.hashnode.dev

Chapter 3 - IP Addressing

Introduction

IP addressing is a fundamental concept in networking. This chapter covers the basics of IPv4 and IPv6, including how IP addresses work, the differences between private and public IP addresses, and the principles of subnetting.

Table of Contents

IPv4 and IPv6

Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6) are the two versions of IP addresses used in networking. IPv4 is the most commonly used version, while IPv6 is designed to address the limitations of IPv4.

Understanding IP addresses, subnets, and CIDR notation

IP Addresses: An IP address is a unique identifier assigned to each device on a network.

  • IPv4 addresses are 32-bit numbers, typically represented as four decimal numbers separated by dots (e.g., 192.168.1.1).

  • IPv6 addresses are 128-bit numbers, represented as eight groups of four hexadecimal digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).

Subnets: A subnet divides a network into smaller, manageable sections. Each subnet has its own range of IP addresses.

CIDR (Classless Inter-Domain Routing) notation This specifies an IP address range using a combination of an IP address and a prefix length (e.g., 192.168.1.0/24). Let's breakdown this IP address (192.168.1.0/24) in relation to CIDR notation.

  • 192.168.1.0 is the IP address itself.

  • /24 indicates the number of leading bits (or digits) in the IP address that are fixed and cannot be changed.

In this case, /24 means that the first 24 bits (or 3 octets) of the IP address are fixed, and the remaining 8 bits (or 1 octet) are available for host addressing. When I say "available for host processing", I mean that the remaining 8 bits (or 1 octet) can be used to assign unique addresses to individual devices (hosts) on the network. This last octet (0-255) can be used to identify specific devices on the subnet.

This allows for 254 usable host addresses (since 0 and 255 are reserved). For example, with the subnet 192.168.1.0/24, the available host addresses would range between 192.168.1.1 and 192.168.1.254.
Enter fullscreen mode Exit fullscreen mode




Private vs. public IP addresses

Private IP addresses: These are used within private networks and are not routable on the internet. Common private IP address ranges include:

  • 10.0.0.0 to 10.255.255.255

  • 172.16.0.0 to 172.31.255.255

  • 192.168.0.0 to 192.168.255.255

Public IP addresses: are routable on the internet and must be unique across the entire internet. These addresses are assigned by the Internet Assigned Numbers Authority (IANA).

Subnetting

Subnetting is the process of dividing a network into smaller sub-networks, or subnets, each with its own subnet mask. This helps in efficient IP address management and improves network performance and security.

Subnet masks

A subnet mask is used to determine the scope of a subnet. In other words, it is used to define which part of an IP address belongs to the network and which part belongs to the host. For example:

  • IP address: 192.168.1.100

  • Subnet mask: 255.255.255.0

In this example, the subnet mask (255.255.255.0) determines that the first 24 bits (192.168.1) belong to the network (subnet) and the last 8 bits (.100) belong to the host.

What if you want to determine the subnet mask of an IP Address? How do you go about it? Well, worry not. Let's determine the subnet mask of "192.168.1.0/24".

The "/24" in the IP address is a CIDR (Classless Inter-Domain Routing) notation, which indicates the number of leading bits in the subnet mask that are set to 1. In this case, "/24" means that the first 24 bits (or 3 octets) of the IP address are fixed, and the remaining 8 bits (or 1 octet) are available for host addressing.

To convert "/24" to a subnet mask, you can use the following steps:

  • Start with a 32-bit binary number (all zeros): 00000000 00000000 00000000 00000000

  • Set the first 24 bits to 1: 11111111 11111111 11111111 00000000

  • Convert the binary number to decimal: 255.255.255.0

Therefore, the subnet mask for the IP address 192.168.1.0/24 is 255.255.255.0.

Let's determine the subnet mask of another IP Address (192.168.1.0/16):

The "/16" in the IP address indicates that the first 16 bits (or 2 octets) of the IP address are fixed, and the remaining 16 bits (or 2 octets) are available for host addressing.

To convert "/16" to a subnet mask, you can use the following steps:

  • Start with a 32-bit binary number (all zeros): 00000000 00000000 00000000 00000000

  • Set the first 16 bits to 1: 11111111 11111111 00000000 00000000

  • Convert the binary number to decimal: 255.255.0.0

Therefore, the subnet mask for the IP address 192.168.1.0/16 is indeed 255.255.0.0.

Conclusion

Understanding IP addressing and subnetting is crucial for anyone working in networking. By mastering these concepts, you can efficiently manage and configure networks, ensuring optimal performance and security.

Feel free to leave comments and share this article. Follow my blog for more insights on Networking!

Top comments (0)