Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Essentials of IP Addressing, Subnetting, and DNS Resolution

Tech May 15 1

IP Address Allocation and Ranges

To manage network resources efficiently, IPv4 addresses are categorized into classes. Specific ranges are reserved for private internal networks to conserve global public addresses.

Private Adress Spaces (RFC 1918)

Class A:   10.0.0.0      -> 10.255.255.255   (Mask: /8)
Class B:   172.16.0.0    -> 172.31.255.255   (Mask: /16)
Class C:   192.168.0.0   -> 192.168.255.255  (No Mask specified, typically /24)

Strategies for IP Scarcity

When available IPv4 pool is exhausted, two primary methods address connectivity:

  1. Network Address Translation (NAT) This technique maps multiple private internal IPs to a single or fewer public IP addresses. It allows thousands of devices to share internet access through one gateway IP. Benefits include conservation of public address space and inherent network obfuscation against direct external attacks.

  2. IPv6 Adoption The successor protocol utilizes 128-bit addressing represented in hexadecimal groups. Format: Group 1 : Group 2 ... where each group contains up to 4 hex digits.

Subnet Masks and CIDR

The subnet mask defines which portion of an IP address identifies the network versus the specific host device. If two devices reside in the same logical segment (subnet), they communicate directly via Layer 2 switches. Cross-subnet communication requires a router.

Calculating Network Segments

To determine if hosts belong to the same subnet:

  1. Convert the IP address and Subnet Mask into binary format.
  2. Perform a bitwise AND operation between the IP and the Mask.
  3. Compare the resulting network IDs.
  4. Identical results indicate the devices are on the same local segment.

Calculation Example

Given Host A (172.16.10.1) and Host B (172.16.10.2) with Mask 255.255.255.0:

Component Binary Representation
Host A IP 10101100.00010000.00001010.00000001
Mask 11111111.11111111.11111111.00000000
AND Result 10101100.00010000.00001010.00000000 (172.16.10.0)

Both yield the same network ID (172.16.10.0). Thus, they are neighbors on the same LAN.

CIDR Notation

Using slash notation simplifies mask definition (e.g., /24). The number represents the count of leading 1s in the binary mask.

  • /24 implies 24 bits to the network and 8 bits for hosts ($2^8 = 256$ total).
  • Reserved Addresses: The first address (network ID) and last address (broadcast) are not assignable to hosts.
  • Usable Hosts: Total - 2.

Default Gateway

The gateway acts as the bridge to external networks. In home/office environments, this is the internal interface IP of the local router. It is distinct from the public WAN IP assigned by the ISP.

Domain Name System (DNS)

Because numeric IP addresses are difficult for humans to memorize, the DNS maps human-readable domain names to corresponding IPs.

Locators and Cache Hierarchy

Before querying remote servers, the system checks several local stores:

  1. Local Hosts File: Static mapping stored at %SystemRoot%\System32\drivers\etc\hosts. Has highest priority.
  2. Browser Cache: Recent queries are stored locally by the browser engine.
  3. OS Resolver Cache: The operating system maintains its own lookup cache. Command: ipconfig /displaydns (View), ipconfig /flushdns (Clear).
  4. Router DNS Cache: Local network hardware may cache results.
  5. ISP/Recursive DNS Server: If missed locally, the query goes to the configured upstream resolver (e.g., Cloudflare, Google, Alibaba DNS).

Public DNS Resolvers

Common recursive resolvers include:

  • Google: 8.8.8.8, 8.8.4.4
  • Cloudflare: 1.1.1.1
  • Aliyun: 223.5.5.5
  • Public: 114.114.114.114

Resolution Process Flow

  1. Check Local Hosts file.
  2. Check Browser/OS Cache.
  3. Query Recursive DNS Server.
  4. If unknown, Resolver queries Root Servers (13 logical sets).
  5. Root directs to TLD Server (Top-Level Domain, e.g., .com).
  6. TLD directs to Authoritative Server (specific domain holder).
  7. Authoritative server returns the final IP address to the client.

Domain Architecture

A Fully Qualified Domain Name (FQDN) consists of segments separated by dots, read right-to-left in terms of hierarchy.

  • Root Level: Implicitly the trailing dot . representing the root zone.
  • TLD (Top-Level Domain): e.g., .cn (Country), .com (Commercial), .org (Organization).
  • SLD (Second-Level Domain): The registered name, e.g., example in example.com.
  • Subdomains: Defined by the SLD owner, e.g., mail.example.com.

Example Structure:

http://www.sfn.cn
          ^^^      ^^^
        Subdomain  TLD
             \\
              \-- SLD

Concept Review

Insure mastery of the following topics:

  1. Function of subnet masks in determining network boundaries.
  2. Methodology for verifying if two IPs share a subnet via Boolean logic.
  3. Interpretation of CIDR notation (e.g., /16 vs /24).
  4. Relationship between Gateways and Routing tables.
  5. Step-by-step mechanics of DNS resolution and caching commands.
  6. Distinction between different domain types and ownership levels.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.