Fundamentals 35 min read

Master IP Basics: From Address Types to Subnetting, NAT and IPv6

This comprehensive guide explains the fundamentals of IP networking, covering IP address structure, classful and classless addressing, subnetting techniques, public and private address allocation, routing, fragmentation, IPv6 features, and essential protocols such as DNS, ARP, DHCP, NAT, ICMP and IGMP.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master IP Basics: From Address Types to Subnetting, NAT and IPv6

IP Fundamentals Overview

IP operates at the network layer (layer 3) of the TCP/IP model and provides end‑to‑end host communication across non‑directly connected networks. MAC addresses work only on a directly linked segment (data‑link layer). The source IP address and destination IP address remain unchanged throughout the packet’s journey, while MAC addresses may change at each hop.

IPv4 Address Basics

IPv4 addresses are 32‑bit unsigned integers usually written in dotted‑decimal notation (four octets). The theoretical address space is 2³² ≈ 4.3 billion addresses, but practical usable hosts are fewer because each address is split into a network prefix and a host identifier.

Classful Addressing

Historically the address space was divided into five classes:

Class A : 0‑7 leading bits, network / host split 8 / 24, range 1.0.0.0 – 126.255.255.255, ~16 million hosts per network.

Class B : 10 leading bits, split 16 / 16, range 128.0.0.0 – 191.255.255.255, ~65 000 hosts per network.

Class C : 110 leading bits, split 24 / 8, range 192.0.0.0 – 223.255.255.255, 254 hosts per network.

Class D : 1110 leading bits, reserved for multicast.

Class E : 1111 leading bits, reserved for future use.

Two addresses in each network are reserved: the all‑zero host address (network address) and the all‑one host address (broadcast address). This inflexibility leads to inefficient utilization, which CIDR resolves.

Classless Inter‑Domain Routing (CIDR)

CIDR expresses an address as a.b.c.d/x, where /x indicates the number of leading bits that form the network prefix (0 ≤ x ≤ 32). The network portion is obtained by a bitwise AND between the address and its subnet mask.

How are the network and host portions determined?

Example: 10.100.122.2/24 uses the first 24 bits as the network ID and the remaining 8 bits for host IDs.

Subnetting Example

Given a Class C network 192.168.1.0 with mask 255.255.255.192 (binary 11111111.11111111.11111111.11000000), two host bits are borrowed for subnet IDs, yielding four subnets (00‑11). Each subnet has 62 usable host addresses (64 total minus network and broadcast).

Public vs. Private IPv4 Addresses

Private address blocks (not routable on the public Internet) are:

10.0.0.0/8

172.16.0.0/12

192.168.0.0/16

Public addresses are allocated globally by IANA and regional registries (ARIN, LACNIC, RIPE NCC, AfriNIC, APNIC). In China, the allocation is managed by CNNIC.

Routing and Loopback

Routers perform longest‑prefix matching on the network portion to forward packets. The loopback address 127.0.0.1 (hostname localhost) is used for intra‑host communication and never leaves the host.

Fragmentation and Reassembly

Each link layer defines a Maximum Transmission Unit (MTU). If an IP packet exceeds the MTU, it is fragmented. Only the destination host reassembles fragments; routers forward fragments unchanged. TCP mitigates loss by limiting segment size (MSS) to avoid fragmentation, while UDP applications should keep payloads ≤ MTU.

IPv6 Fundamentals

IPv6 expands the address space to 128 bits, providing 2¹²⁸ possible addresses. It eliminates the need for NAT, includes built‑in security extensions, and simplifies the header.

Address Representation

IPv6 addresses consist of eight groups of four hexadecimal digits separated by colons. Consecutive zero groups can be compressed with :: (once per address). Example: 2001:0db8::1.

Header Differences

No header checksum.

Fragmentation is performed only by the source host; routers never fragment.

Optional fields are moved to extension headers, making the base header a fixed 40 bytes.

Address Types

Unicast : one‑to‑one communication.

Multicast : one‑to‑many, uses D‑class range 224.0.0.0 – 239.255.255.255.

Anycast : one‑to‑nearest of a group of hosts.

No broadcast address in IPv6.

Related IP Protocols

Domain Name System (DNS)

DNS translates human‑readable domain names (e.g., www.example.com) to IP addresses. Resolution proceeds through client cache → OS cache → hosts file → local DNS server → root servers → TLD servers → authoritative server.

Address Resolution Protocol (ARP) and Reverse ARP (RARP)

ARP maps an IP address to a MAC address by broadcasting an ARP request and receiving a unicast ARP reply. RARP performs the opposite mapping (MAC → IP) and requires a dedicated RARP server.

Dynamic Host Configuration Protocol (DHCP)

DHCP automatically assigns IP configuration to clients via a four‑step exchange:

Client broadcasts DHCPDISCOVER (source IP 0.0.0.0, destination 255.255.255.255, ports 68→67).

Server replies with DHCPOFFER containing an IP lease, subnet mask, gateway, DNS servers, and lease time.

Client selects an offer and sends DHCPREQUEST.

Server finalizes with DHCPACK.

When clients and servers reside in different subnets, a DHCP relay agent forwards the broadcast as a unicast to the server.

Network Address Translation (NAT) and Port Translation (NAPT)

NAT allows multiple private hosts to share a single public IP by translating source addresses. NAPT (also called PAT) extends this by translating source ports, enabling many internal hosts to use the same public IP simultaneously.

Limitations of NAT/NAPT include:

Inbound connections to internal servers require explicit port mappings.

Translation tables add processing overhead.

Router reboot clears the table, breaking existing TCP sessions.

Mitigation strategies are to adopt IPv6 (eliminating the need for translation) or use NAT traversal techniques that let applications discover the external IP and set up port mappings automatically.

Internet Control Message Protocol (ICMP)

ICMP reports errors and operational information for IP packets (e.g., destination unreachable, time exceeded). It is essential for diagnostics (ping, traceroute) and for informing senders about delivery problems.

Internet Group Management Protocol (IGMP)

IGMP manages multicast group membership between hosts and the last‑hop router. Hosts send IGMP membership reports to join a multicast group; routers periodically query the group (e.g., to 224.0.0.1). IGMPv2 defines leave messages (to 224.0.0.2) and specific‑group queries to prune empty groups.

Key Takeaways

IPv4 uses classful addressing historically, but CIDR provides flexible prefix lengths and efficient address utilization.

Subnet masks and CIDR notation define the boundary between network and host bits, enabling subnetting.

Private address ranges allow internal reuse; public addresses are globally unique and allocated by regional registries.

Routing decisions rely on the network prefix; longest‑prefix match selects the most specific route.

Fragmentation occurs only when a packet exceeds the link‑layer MTU; reassembly is performed solely by the destination host.

IPv6 solves address exhaustion, removes the need for NAT, and simplifies packet processing.

Supporting protocols (DNS, ARP/RARP, DHCP, NAT/NAPT, ICMP, IGMP) are integral to the operation of IP networks.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

IPv6NetworkingNATDNSipDHCPCIDRSubnetting
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.