๐Ÿ“˜ Visual Posts About Contact
Explore ๐Ÿ“‹ Cheat Sheets โœ๏ธ Practice ๐ŸŽฎ Games ๐ŸŽฌ Simulations ๐Ÿƒ Flashcards ๐ŸŽฏ Interactive Layers ๐Ÿ“– Storytelling
๐Ÿ’œ Support my site

Server Networking: Opening the Pipes

Module 08 โ€ข Aโ€“Z Server Course Zero to Hero 2026 Edition

A server with no network is just an expensive space heater. In this module, you will learn how a server gets its address, why DHCP is great for laptops but risky for servers, how DNS turns names into IPs, what 0.0.0.0 vs 127.0.0.1 really means, and how host firewalls protect every open port.

Open the Pipes โ†“
SERVER NETWORK PIPELINE Client app.site.com Port 443 DNS Record (A) โ†’ 203.0.113.10 FIREWALL ufw / nftables 443 ALLOW 5432 DENY SERVER (10.0.1.50) Nginx Web 0.0.0.0:443 Front Door PostgreSQL DB 127.0.0.1:5432 Internal Hallway Direct DB blocked!

01 Server IP Addressing: IP, Subnet Mask & Default Gateway

Define: Every server on a network needs three core numbers to communicate: an IP Address (its unique identifier), a Subnet Mask (which defines who is local), and a Default Gateway (the router that leads to the outside world).

๐Ÿ˜๏ธ Universal Analogy: Street, Neighborhood & Highway Exit

Imagine mailing a letter in a city. Your IP Address (e.g., 192.168.10.50) is your house number and street. Your Subnet Mask (255.255.255.0 or /24) is your neighborhood boundaryโ€”it tells you which houses you can walk to directly without getting on a highway. Your Default Gateway (192.168.10.1) is the highway on-ramp: if a packet needs to visit Google or another subnet, your server hands it to the gateway to leave the neighborhood.

Understand How the Three Numbers Work Together

  • Static IP Address: A permanent, manually assigned IP (or DHCP reservation) so users, load balancers, and DNS records can always find the server at the exact same address.
  • Subnet Mask / CIDR (/24): Splits the IP into a Network portion (192.168.10) and a Host portion (.50). Any IP from 192.168.10.1 to 192.168.10.254 is in the same local neighborhood.
  • Default Gateway: Almost always the .1 (or .254) address on that subnet. Without a valid gateway, your server can talk to machines in the same room, but cannot reach the internet.
HOW A SERVER READS ITS NETWORK ADDRESS LOCAL SUBNET: 192.168.10.0/24 (Mask: 255.255.255.0) Your Web Server IP: 192.168.10.50 Mask: /24 (.0) GW: 192.168.10.1 Neighbor DB Server 192.168.10.60 Same 192.168.10.x street Direct Local Delivery (L2 Switch) No Gateway needed! Same subnet. DEFAULT GATEWAY 192.168.10.1 Highway Exit Router 8.8.8.8? OUTSIDE NETWORKS (Internet & Other Subnets) 8.8.8.8 (Google DNS) 10.20.0.15 (Cloud API)

Know When to Check & Execute on Linux and Windows

When: Run these commands right after provisioning a new server or whenever a server can ping its neighbor (192.168.10.60) but cannot reach the internet (8.8.8.8).

# Linux (Modern iproute2) โ€” Check IP, Subnet (/24), and Default Gateway
ip addr show
ip route show          # Look for: default via 192.168.10.1 dev eth0

# Linux (Netplan static config example: /etc/netplan/01-netcfg.yaml)
# addresses: [192.168.10.50/24]
# routes: [{ to: default, via: 192.168.10.1 }]

# Windows Server (PowerShell) โ€” View IP & Default Gateway
Get-NetIPConfiguration

๐Ÿงช Practice Problem 1: The Isolated Server

Your new Linux server has IP 10.0.5.25/24. You can successfully ping 10.0.5.10 (a neighbor server), but ping 1.1.1.1 fails with Network is unreachable. What is most likely missing?

Show Solution

The server is missing a Default Gateway (default route) in ip route show. Because 10.0.5.10 is in the same /24 neighborhood, the server reaches it directly without a gateway. Reaching 1.1.1.1 requires a highway exit (e.g., default via 10.0.5.1).

02 DHCP & the DORA Process

Define: DHCP (Dynamic Host Configuration Protocol) automatically assigns an IP address, subnet mask, default gateway, and DNS servers to a device when it joins a networkโ€”using a 4-step conversation called DORA.

๐Ÿง  Memory Trick: D-O-R-A

Think of a newcomer shouting in a crowded room to rent an apartment: Discover ("Any empty rooms?"), Offer ("Room 104 is free!"), Request ("I'll take Room 104!"), Acknowledge ("Deal! Here are your keys for 24 hours.").

THE DHCP DORA HANDSHAKE New Machine IP: 0.0.0.0 DHCP Server Pool: .100 - .200 1. DISCOVER (Broadcast) โ€” "Anyone have an IP?" 2. OFFER โ€” "You can lease 192.168.10.120" 3. REQUEST โ€” "I accept 192.168.10.120!" 4. ACK โ€” "Confirmed! IP + Mask + Gateway + DNS"

โš ๏ธ Why Production Servers Avoid Plain DHCP

DHCP leases expire. If a database server reboots after a power outage and gets a new random IP from DHCP (say .124 instead of .120), every web app pointing to .120 immediately crashes. Rule of thumb: Laptops and phones use DHCP; servers use either a Static IP configured on the OS or a DHCP Reservation (pinned to the server's MAC address).

03 DNS Records Every Server Admin Must Know

Define: DNS (Domain Name System) is the internet's phonebookโ€”it translates human-friendly names like api.shekharit.com into machine-friendly IP addresses like 203.0.113.10.

A

IPv4 Address

Maps a hostname to a 32-bit IPv4 address (e.g., web.site.com โ†’ 203.0.113.10).

AAAA

IPv6 Address

Maps a hostname to a 128-bit IPv6 address (e.g., 2001:db8::1). "Quad-A" = 4ร— bigger than A.

CNAME

Canonical Name

Creates an alias pointing one domain name to another name (e.g., www โ†’ site.com).

MX

Mail Exchange

Tells the world which mail servers accept email for your domain, ordered by priority.

TXT

Text Record

Stores arbitrary text for domain ownership verification and email security (SPF, DKIM, DMARC).

PTR

Pointer (Reverse)

Reverse DNS: maps an IP address back to a hostname. Critical for outbound mail servers.

The Local Override: /etc/hosts

Before your server ever asks a DNS server on the network, it checks its own local notepad first: /etc/hosts on Linux (or C:\Windows\System32\drivers\etc\hosts on Windows). Admins use this to test a new server before updating public DNS.

# Test DNS records from the terminal
dig +short shekharit.com A
dig +short shekharit.com MX
nslookup -type=TXT shekharit.com

# Check local /etc/hosts override
cat /etc/hosts
# 127.0.0.1   localhost
# 10.0.1.50   staging-api.internal

โœ“ DNS & DHCP Checkpoint

  • DORA = Discover, Offer, Request, Acknowledge.
  • Servers use Static IPs or DHCP Reservations so their IP never drifts.
  • A = IPv4, AAAA = IPv6, CNAME = Alias, MX = Mail, TXT = Verification/SPF, PTR = Reverse IPโ†’Name.

04 Listening Sockets: 0.0.0.0 vs 127.0.0.1

Define: When a server program starts (like Nginx, Node.js, or PostgreSQL), it must bind to an IP address and a port numberโ€”creating a listening socket. The IP you choose decides who can knock on that door.

๐Ÿšช Analogy: Front Door vs. Internal Hallway

Binding to 0.0.0.0:443 is like opening your Front Door to every network cable plugged into the server (public internet, LAN, and localhost). Binding to 127.0.0.1:5432 (the loopback address) is like putting a door inside an Internal Hallwayโ€”only programs already running inside the same server can walk through it. Anyone outside on the network is physically unable to reach it.

BIND ADDRESSES: 0.0.0.0 (ALL INTERFACES) vs 127.0.0.1 (LOCALHOST ONLY) External User From Internet / LAN Targets 10.0.1.50 INSIDE THE SERVER (eth0 = 10.0.1.50 | lo = 127.0.0.1) 0.0.0.0:443 (Nginx Web Server) Listens on EVERY network interface (eth0 + lo). External users CAN connect here (if firewall allows). 127.0.0.1:5432 (PostgreSQL Database) Listens ONLY on the internal loopback interface (lo). Unreachable from outside! Only local apps can connect. REACHES NO ROUTE

Execute: Inspect Open Sockets with ss

# Linux: Show all TCP & UDP listening sockets with process names
sudo ss -tulpn

# Example output:
# LISTEN  0  511  0.0.0.0:443      0.0.0.0:*   users:(("nginx",pid=1024,fd=6))
# LISTEN  0  128  127.0.0.1:5432   0.0.0.0:*   users:(("postgres",pid=890,fd=5))

๐Ÿงช Practice Problem 2: The "It Works on the Server, Not My Laptop" Mystery

You started a Python web app on your Linux server, and curl http://localhost:8000 works when you SSH into the server. But when you open http://<server-ip>:8000 from your laptop, it refuses to connect. Running ss -tulpn shows 127.0.0.1:8000. Why?

Show Solution

The app is bound to 127.0.0.1:8000 (the internal loopback), so it only accepts connections from inside the server itself. To accept external traffic (or traffic via a reverse proxy), bind it to 0.0.0.0:8000โ€”or keep it on 127.0.0.1:8000 and put Nginx on 0.0.0.0:443 in front of it!

05 Host Firewalls: Default Deny, Allow Specific Ports

Define: A Host Firewall is software running directly inside your server's OS kernel that inspects every incoming and outgoing packet. Golden Rule: Default Deny incoming, Allow only the specific ports you need.

HOST FIREWALL POLICY: DEFAULT DENY INCOMING TCP Port 22 (SSH) Admin Login TCP Port 443 (HTTPS) Encrypted Web Traffic TCP Port 3306 (MySQL) Database Scanner TCP Port 23 (Telnet) Unencrypted Bot FIREWALL RULES ALLOW 22/tcp ALLOW 443/tcp DEFAULT POLICY DENY ALL OTHER PORTS SERVER SERVICES sshd (:22) โœ“ nginx (:443) โœ“ Only approved doors open DROPPED AT GATE 3306 & 23 never reach running applications.

Comparison: Linux & Windows Host Firewalls

OS Family Firewall Tool Allow Port 443 Command
Ubuntu / Debian ufw (Uncomplicated Firewall) sudo ufw allow 443/tcp
RHEL / Rocky / Alma firewalld sudo firewall-cmd --permanent --add-service=https && sudo firewall-cmd --reload
Windows Server Windows Defender Firewall New-NetFirewallRule -DisplayName "HTTPS" -Direction Inbound -LocalPort 443 -Protocol TCP -Action Allow

๐Ÿšจ Never Lock Yourself Out of SSH!

When enabling ufw on a remote cloud server, ALWAYS run sudo ufw allow OpenSSH (or 22/tcp) before running sudo ufw enable. Otherwise, the default-deny policy will immediately drop your active SSH session.

# Safe UFW setup sequence on Ubuntu/Debian
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

๐ŸŽฏ Knowledge Check

Test your Module 08 mastery (4 Questions) Score: 0 / 4

1. Your server can ping another machine on the same /24 subnet, but fails to reach 8.8.8.8. Which setting is most likely missing or wrong?

PTR RecordโŒ
Default Gatewayโœ…
/etc/hostsโŒ

2. In the DHCP DORA process, what does the letter "O" stand for?

Offer (the DHCP server proposes an available IP lease)โœ…
Override (the client forces its own static IP)โŒ
Open (the firewall opens port 67)โŒ

3. You run ss -tulpn and see PostgreSQL listening on 127.0.0.1:5432. Who can connect to it?

Anyone on the public internetโŒ
Only applications running on the same serverโœ…
Any server in the same /24 subnetโŒ

4. On a fresh Ubuntu server, which UFW rule MUST you add before running sudo ufw enable so you do not lock yourself out?

sudo ufw allow 443/tcpโŒ
sudo ufw allow OpenSSHโœ…
sudo ufw default allow incomingโŒ