Linux Networking from Scratch: TCP/IP, Sockets, Ports & DNS
පිටුව 08: Linux Networking බිංදුවේ සිට: TCP/IP, Sockets, Ports සහ DNS Resolution
IP ලිපින, Ports සහ Sockets, TCP 3-Way Handshake (SYN, SYN-ACK, ACK), ss -tuln භාවිතය, සහ DNS වැඩ කරන හැටි.
Lab 08 of 20 · Networking & DNS · 5 hands-on activities · bilingual (English + සිංහල)
පිටුව 08: Linux Networking බිංදුවේ සිට: TCP/IP, Sockets, Ports සහ DNS Resolution
IP ලිපින, Ports සහ Sockets, TCP 3-Way Handshake (SYN, SYN-ACK, ACK), ss -tuln භාවිතය, සහ DNS වැඩ කරන හැටි.
💡 සරල සිංහලෙන්: TCP 3-Way Handshake සහ DNS දුරකථන ඇමතුමක් වගේ
දුරකථන ඇමතුමක උපමාව (TCP 3-Way Handshake):
-
- SYN (අපි කෝල් එක ගන්නවා): "හෙලෝ, ඇහෙනවද?" කියලා අහනවා.
-
- SYN-ACK (අනෙක් පැත්තෙන් උත්තර දෙනවා): "ඔව් මට ඇහෙනවා! මාව ඔයාට ඇහෙනවද?" කියලා අහනවා.
-
- ACK (අපි තහවුරු කරනවා): "ඔව් මටත් ඇහෙනවා, අපි කතාව පටන් ගමු!" කියලා දත්ත හුවමාරුව පටන් ගන්නවා. මේ පියවර 3 සම්පූර්ණ නොවී කිසිම Web page එකක් load වෙන්නේ නෑ!
DNS කියන්නේ Phone Contacts List එක වගේ:
අපිට මිනිස්සුන්ගේ නම් මතක තියාගන්න ලේසියි (උදා: google.com), හැබැයි phone එකට ඕන අංක (IP Address). DNS එක කරන්නේ නම දුන්නම අදාළ IP අංකය හොයලා දෙන එකයි.
Architectural Foundation & Systems Diagram
In distributed systems and microservices, applications do not run on isolated islands. They communicate across network sockets governed by the TCP/IP stack.
-
🚪 Ports & Sockets — An IP Address identifies a host machine. A Port (0-65535) identifies the specific application listening. A Socket is the binding of
IP:Port(e.g.127.0.0.1:8080). -
🤝 TCP 3-Way Handshake — Before any HTTP data flows, a reliable bidirectional connection is negotiated:
- SYN (Client $ ightarrow$ Server: "Can we talk?")
- SYN-ACK (Server $ ightarrow$ Client: "Yes, I am ready!")
- ACK (Client $ ightarrow$ Server: "Acknowledged! Sending data.")
- 🔍 DNS Resolution Workflow — DNS converts human names (
google.com) to IP addresses (142.250.190.46). Linux checks/etc/hostsfirst, then queries nameservers defined in/etc/resolv.conf.
Step-by-step practical lab
Step 01: Inspect Available RAM & Swap Memory
සිංහලෙන් — RAM මතකය සහ Swap ඉඩ ප්රමාණය Megabytes වලින් මැනීම.
Display total, used, free, shared, buffer/cache, and available physical RAM and swap space in megabytes.
free -m-m: Megabytes (MiB) ඒකක වලින් මතකය ගණනය කරයි.
Expected output
total used free shared buff/cache available
Mem: 8192 3820 2480 48 1891 4120
Swap: 2048 0 2048SRE Tip: Always watch the available column, NOT free. Linux uses free RAM for buffers/cache to speed up disk reads!
Step 02: Search Kernel Ring Buffer for Out-of-Memory (OOM) Kills
සිංහලෙන් — RAM ඉවර වී Kernel OOM Killer විසින් processes මරා ඇත්දැයි බැලීම.
Inspect kernel dmesg logs for invocations of the Out-of-Memory (OOM) killer terminating runaway processes.
dmesg | grep -i oomdmesg: Kernel ring buffer logs පෙන්වයි.grep -i oom: OOM killer ක්රියාත්මක වූ සිදුවීම් සොයයි.
Expected output
[ 4120.184] Out of memory: Kill process 18240 (python3) score 842 or sacrifice child
[ 4120.185] Killed process 18240 (python3) total-vm:4194304kB, anon-rss:3670016kBSRE Tip: When a process suddenly disappears without an application error log, 95% of the time it was killed silently by the Linux OOM Killer.
Hands-on practice activities
Work through these yourself — tick them off as you go.
- Activity 36: Audit Active TCP/UDP Listening Ports (Drill) — Display all listening TCP and UDP sockets with port numbers and interface bindings.
- Activity 37: Audit Sockets via Legacy Netstat (Drill) — Query listening socket table via netstat to verify port 8080 and 80 bindings.
- Activity 38: Probe Web Server Response Headers via Curl (Drill) — Send an HTTP GET probe to confirm web listener is active and returning HTTP 200 OK.
- Activity 39: Inspect DNS Nameserver Configuration (Checkpoint) — Verify your system nameservers inside /etc/resolv.conf to troubleshoot DNS resolution timeouts.
- Activity 40: TCP 3-Way Handshake Order Quiz (Quiz) — What is the correct sequence of packets in the TCP 3-way handshake? Answer: SYN, SYN-ACK, ACK.
Keep going: ← Lab 07 · Lab 09 → · Track your progress in the Self Guide
ExerciseKnowledge check
What are the three packets exchanged in the standard TCP Three-Way Handshake? / TCP Handshake එකේ පැකට් 3 මොනවාද?
Finished this one?
Part of Self Guide · Stage 10: SRE Labs I — the machine underneath. Progress is saved in this browser.

