Learn Domains, DNS, IP Addressing & Bit Concepts
Read on to explore learn domains, dns, ip addressing & bit concepts — a beginner-friendly walkthrough by Codekilla.
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."
- 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
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
| Record | Purpose | Example |
|---|---|---|
| A | Maps domain to IPv4 address | codekilla.com → 93.184.216.34 |
| AAAA | Maps domain to IPv6 address | codekilla.com → 2606:2800:220:1:... |
| CNAME | Alias pointing to another domain | www.codekilla.com → codekilla.com |
| MX | Mail server for domain | mail.codekilla.com (priority: 10) |
| TXT | Arbitrary 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
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
| Type | Range | Use Case |
|---|---|---|
| Private | 10.0.0.0 – 10.255.255.255 | Large internal networks |
| Private | 172.16.0.0 – 172.31.255.255 | Medium networks (AWS VPCs) |
| Private | 192.168.0.0 – 192.168.255.255 | Home routers, small offices |
| Public | Everything else | Internet-routable addresses |
| Loopback | 127.0.0.1 | Localhost (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
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.1to192.168.1.254— usable host addresses (254 devices)192.168.1.255— broadcast address (reserved)
Common Subnet Cheat Sheet
| CIDR | Subnet Mask | Usable Hosts | Use Case |
|---|---|---|---|
/8 | 255.0.0.0 | 16,777,214 | Massive networks |
/16 | 255.255.0.0 | 65,534 | Large enterprises |
/24 | 255.255.255.0 | 254 | Standard small network |
/30 | 255.255.255.252 | 2 | Point-to-point links |
/32 | 255.255.255.255 | 1 | Single 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
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
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::.
| Need | Reach For |
|---|---|
| Find IP for a domain | dig example.com or nslookup example.com |
| Check your public IP | curl ifconfig.me or visit whatismyip.com |
| Test connectivity | ping <ip> (ICMP echo) |
| Trace route to server | traceroute example.com (shows each hop) |
| View local network config | ipconfig (Windows) or ifconfig/ip addr (Linux/Mac) |
| Calculate subnet ranges | Online calculator or binary AND with mask |
| Convert IP to binary | Split octets, use format(int, '08b') per octet |
| Flush DNS cache | ipconfig /flushdns (Win) / sudo dscacheutil -flushcache (Mac) |
- 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 access —
192.168.x.xwon't work outside your local network without port forwarding/VPN. - Ignoring subnet masks — two devices on
192.168.1.5/24and192.168.1.10/16are on different subnets despite similar IPs. - Forgetting network/broadcast addresses — in a
/24network,.0and.255are reserved; don't assign them to devices. - Hardcoding DNS servers — using
8.8.8.8everywhere bypasses local caching and can break internal domain resolution. - Misunderstanding CIDR notation —
/32is ONE address (used in firewalls), not a range;/0is 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.
Keep Reading
Search Engine Working: Crawler, Sitemap & robots.txt
Read on to explore search engine working: crawler, sitemap & robots.txt — a beginner-friendly walkthrough by Codekilla.
VS Code Shortcut Keys (Complete List)
Read on to explore vs code shortcut keys (complete list) — a beginner-friendly walkthrough by Codekilla.
What is Elementor? Complete Beginner Guide
Read on to explore what is elementor? complete beginner guide — a beginner-friendly walkthrough by Codekilla.
