Turning Learners Into Developers
Codekilla
CODEKILLA
Networking 8 min

Learn Domains, DNS, IP Addressing & Bit Concepts

Read on to explore learn domains, dns, ip addressing & bit concepts — a beginner-friendly walkthrough by Codekilla.

Rahul Chaudhary Thu Apr 30 2026
What is DNS and IP Addressing?

When you type google.com into your browser, you're not actually connecting to those letters. Computers communicate using IP addresses — numeric labels like 142.250.185.46 that identify devices on a network. The Domain Name System (DNS) is the internet's phonebook, translating human-readable domain names into machine-readable IP addresses. Think of it like calling someone by their name instead of memorizing their phone number.

At the foundation of all this sits binary — the language computers speak. Every IP address, every packet of data, every domain lookup ultimately gets processed as ones and zeros. Understanding how bits, bytes, and binary arithmetic work gives you X-ray vision into what's really happening when you "just browse the web."

Why It Matters
  • Every web request triggers DNS — without it, you'd need to memorize IP addresses for every site you visit
  • IP addressing determines network reach — private vs. public IPs control what devices can talk to each other
  • Binary math powers subnetting — network engineers use bit manipulation to divide networks efficiently
  • Debugging requires understanding layers — knowing whether an issue is DNS, routing, or IP conflict saves hours
  • Security depends on these concepts — DNS hijacking, IP spoofing, and network segmentation all stem from these fundamentals
How Domain Names Work

A domain name like blog.codekilla.com is hierarchical, read from right to left:

  • .com — top-level domain (TLD)
  • codekilla — second-level domain (the brand)
  • blog — subdomain (a specific section)

When you request this domain, your computer queries DNS servers in sequence: root servers point to TLD servers, TLD servers point to authoritative nameservers, and those finally return the IP address. This process happens in milliseconds through caching — your browser, OS, and ISP all store recent lookups.

DNS Record Types

RecordPurposeExample
AMaps domain to IPv4 addresscodekilla.com → 93.184.216.34
AAAAMaps domain to IPv6 addresscodekilla.com → 2606:2800:220:1:...
CNAMEAlias pointing to another domainwww.codekilla.com → codekilla.com
MXMail server for domainmail.codekilla.com (priority: 10)
TXTArbitrary text (SPF, verification)"v=spf1 include:_spf.google.com"
bash
# Query DNS records using dig (Linux/Mac)
dig codekilla.com A

# Output shows:
# ;; ANSWER SECTION:
# codekilla.com.  300  IN  A  93.184.216.34

# Query specific record type
dig codekilla.com MX
dig codekilla.com AAAA
Understanding IPv4 Addresses

An IPv4 address is a 32-bit number divided into four octets (8 bits each), written in decimal like 192.168.1.100. Each octet ranges from 0-255 because 8 bits can represent 2⁸ = 256 values. The address has two parts: the network portion (which subnet you're on) and the host portion (your specific device).

Private vs. Public IP Ranges

TypeRangeUse Case
Private10.0.0.010.255.255.255Large internal networks
Private172.16.0.0172.31.255.255Medium networks (AWS VPCs)
Private192.168.0.0192.168.255.255Home routers, small offices
PublicEverything elseInternet-routable addresses
Loopback127.0.0.1Localhost (your own machine)

Your home devices use private IPs behind a router performing NAT (Network Address Translation), which shares one public IP with all your devices. When you connect to a website, the router rewrites packets so responses come back to the right device.

python
# Convert IP address to binary representation
def ip_to_binary(ip):
    octets = ip.split('.')
    binary_octets = [format(int(octet), '08b') for octet in octets]
    return '.'.join(binary_octets)

# Example
ip = "192.168.1.100"
print(f"{ip} in binary:")
print(ip_to_binary(ip))
# Output: 11000000.10101000.00000001.01100100
Subnet Masks and CIDR Notation

A subnet mask tells computers which part of an IP is the network and which is the host. The mask 255.255.255.0 in binary is 24 ones followed by 8 zeros. This is written in CIDR notation as /24, meaning the first 24 bits are the network.

In 192.168.1.0/24, you have 256 total addresses (2⁸ = 256), but typically:

  • 192.168.1.0 — network address (reserved)
  • 192.168.1.1 to 192.168.1.254 — usable host addresses (254 devices)
  • 192.168.1.255 — broadcast address (reserved)

Common Subnet Cheat Sheet

CIDRSubnet MaskUsable HostsUse Case
/8255.0.0.016,777,214Massive networks
/16255.255.0.065,534Large enterprises
/24255.255.255.0254Standard small network
/30255.255.255.2522Point-to-point links
/32255.255.255.2551Single host (specific IP)
javascript
// Calculate number of usable hosts from CIDR
function usableHosts(cidr) {
    const hostBits = 32 - cidr;
    const totalAddresses = Math.pow(2, hostBits);
    // Subtract network and broadcast addresses
    return totalAddresses - 2;
}

console.log(usableHosts(24)); // 254
console.log(usableHosts(16)); // 65534
console.log(usableHosts(30)); // 2
Binary and Bit Manipulation Basics

Computers process everything in binary (base-2), using only 0 and 1. Each binary digit is a bit, and 8 bits make a byte. Understanding binary is crucial for subnetting, permissions (like Unix chmod 755), and low-level networking.

Decimal to binary conversion: repeatedly divide by 2 and track remainders.
Binary to decimal: multiply each bit by 2 raised to its position (right to left, starting at 0).

For example, binary 1010 = (1×2³) + (0×2²) + (1×2¹) + (0×2⁰) = 8 + 0 + 2 + 0 = 10 in decimal.

Bitwise operations let you manipulate individual bits:

  • AND (&) — both bits must be 1 → used in subnet calculations
  • OR (|) — either bit is 1 → used to combine flags
  • XOR (^) — bits differ → used in encryption/checksums
  • NOT (~) — flips all bits
python
# Practical example: Check if an IP is in a subnet
def ip_in_subnet(ip, network, cidr):
    # Convert to integers
    ip_int = sum(int(octet) << (8 * (3 - i)) for i, octet in enumerate(ip.split('.')))
    net_int = sum(int(octet) << (8 * (3 - i)) for i, octet in enumerate(network.split('.')))
    
    # Create mask (CIDR /24 = 24 ones)
    mask = (0xFFFFFFFF << (32 - cidr)) & 0xFFFFFFFF
    
    # Apply mask to both and compare
    return (ip_int & mask) == (net_int & mask)

# Test it
print(ip_in_subnet("192.168.1.50", "192.168.1.0", 24))   # True
print(ip_in_subnet("192.168.2.50", "192.168.1.0", 24))   # False
IPv6: The Future (Already Here)

IPv4's 4.3 billion addresses aren't enough for our connected world. IPv6 uses 128 bits, providing 340 undecillion addresses (that's 340 with 36 zeros). Written in hexadecimal with colons like 2001:0db8:85a3:0000:0000:8a2e:0370:7334, you can abbreviate consecutive zeros:

2001:db8:85a3::8a2e:370:7334 (the :: replaces one or more zero groups).

IPv6 eliminates NAT, gives every device a public IP, and simplifies routing. Most modern sites support both (called dual-stack). Your OS likely already uses IPv6 on local networks through link-local addresses starting with fe80::.

Quick Cheat Sheet
NeedReach For
Find IP for a domaindig example.com or nslookup example.com
Check your public IPcurl ifconfig.me or visit whatismyip.com
Test connectivityping <ip> (ICMP echo)
Trace route to servertraceroute example.com (shows each hop)
View local network configipconfig (Windows) or ifconfig/ip addr (Linux/Mac)
Calculate subnet rangesOnline calculator or binary AND with mask
Convert IP to binarySplit octets, use format(int, '08b') per octet
Flush DNS cacheipconfig /flushdns (Win) / sudo dscacheutil -flushcache (Mac)
Common Mistakes
  • Confusing DNS with IP — DNS is the lookup system; IP is the actual address. DNS failing doesn't mean the server is down.
  • Using private IPs for public access192.168.x.x won't work outside your local network without port forwarding/VPN.
  • Ignoring subnet masks — two devices on 192.168.1.5/24 and 192.168.1.10/16 are on different subnets despite similar IPs.
  • Forgetting network/broadcast addresses — in a /24 network, .0 and .255 are reserved; don't assign them to devices.
  • Hardcoding DNS servers — using 8.8.8.8 everywhere bypasses local caching and can break internal domain resolution.
  • Misunderstanding CIDR notation/32 is ONE address (used in firewalls), not a range; /0 is the entire internet.

💡 Think Like a Programmer: Every time you visit a website, you're triggering a chain reaction—DNS lookup, TCP handshake, HTTP request—all powered by binary math your computer does billions of times per second. Understanding these layers doesn't just make you better at networking; it makes you better at debugging everything.

// was this useful?
Did this article answer your question?
// Networking · published by Codekilla
// related articles

Keep Reading