Networking Fundamentals
Summary
This chapter introduces essential networking concepts and commands. You'll learn about IP addresses, DNS, and network interfaces, then master diagnostic tools like ping, traceroute, netstat, and ss. You'll also learn to transfer files with curl and wget. These networking fundamentals are crucial for troubleshooting connectivity issues and working with remote systems.
Concepts Covered
This chapter covers the following 17 concepts from the learning graph:
- Network Basics
- IP Address
- MAC Address
- DNS
- Hostname Resolution
- Network Interfaces
- Ifconfig Command
- Ip Command
- Ping Command
- Traceroute Command
- Netstat Command
- Ss Command
- Curl Command
- Wget Command
- Network Ports
- WiFi Configuration
- Network Troubleshooting
Prerequisites
This chapter builds on concepts from:
Welcome to the Network Layer!
Every time you open a website, send a message, or stream a video, your computer is having thousands of tiny conversations with other computers around the world. Understanding networking is like learning to read the mail system of the internet—and trust me, it's WAY more interesting than actual mail!
In this chapter, you'll learn how data travels across networks, how to diagnose problems when things go wrong, and how to become the person everyone calls when "the internet is broken." (Spoiler: it's usually DNS. It's ALWAYS DNS.)
Network Basics: How Computers Talk
At its core, network basics boil down to this: computers need a way to find each other and send messages back and forth. Think of it like a massive postal system, but instead of addresses like "123 Main Street," we use numbers.
Networks are organized in layers, with each layer handling a specific job. This is formalized in the OSI Model (Open Systems Interconnection)—a seven-layer cake of networking goodness.
MicroSim: OSI Seven-Layer Network Stack
Description: Interactive diagram showing the OSI seven-layer networking stack with hover-based explanations.
Layout: - Left side: Vertical stack of 7 colored layers (Application at top, Physical at bottom) - Right side: Info box that updates when user hovers over each layer - Each layer should have: name, number, brief description, example protocols, and a real-world analogy
Layers (top to bottom): 1. Application (Layer 7) - HTTP, FTP, SMTP - "The app you're using" 2. Presentation (Layer 6) - SSL/TLS, JPEG, ASCII - "Data formatting and encryption" 3. Session (Layer 5) - NetBIOS, RPC - "Managing connections" 4. Transport (Layer 4) - TCP, UDP - "Reliable delivery vs speed" 5. Network (Layer 3) - IP, ICMP - "Routing between networks" 6. Data Link (Layer 2) - Ethernet, WiFi - "Local network communication" 7. Physical (Layer 1) - Cables, Radio waves - "Actual electrical signals"
Interactivity: - Hover over any layer to see detailed explanation in info box - Info box shows: Layer name, protocols, analogy (e.g., "Like the envelope for your letter") - Optional: Click to "freeze" info box content - Visual indication of which layer is currently selected
Colors: Use distinct, professional colors for each layer (rainbow gradient works well)
Skill: Use microsim-p5 to implement this visualization
The Postal Analogy
When you send a letter:
- You write the message (Application layer)
- Put it in an envelope with an address (Network layer)
- The mail carrier picks it up (Data Link layer)
- Trucks and planes move it physically (Physical layer)
Networks work the same way, just MUCH faster and with more acronyms!
IP Address: Your Computer's Phone Number
An IP address is a unique number that identifies your computer on a network. Without it, other computers wouldn't know where to send data back to you.
There are two versions:
IPv4 (The Classic)
1 | |
Four numbers from 0-255, separated by dots. That's 4 billion possible addresses, which seemed like a lot in the 1980s. (Narrator: It was not enough.)
IPv6 (The Future)
1 | |
Eight groups of hexadecimal numbers. That's 340 undecillion addresses—enough for every grain of sand on Earth to have billions of IP addresses. We're set for a while.
Special IP Addresses
| Address | Meaning |
|---|---|
127.0.0.1 |
Localhost (your own computer) |
192.168.x.x |
Private network (home/office) |
10.x.x.x |
Private network (larger organizations) |
0.0.0.0 |
"Any" address (used in configurations) |
255.255.255.255 |
Broadcast to everyone on network |
1 2 3 4 5 6 | |
Public vs Private IP
Your home network uses private IPs (like 192.168.1.x). Your router has ONE public IP that the whole internet sees. This is called NAT (Network Address Translation)—it's how millions of devices share limited IPv4 addresses.
MAC Address: The Hardware Fingerprint
A MAC address (Media Access Control) is a unique identifier burned into your network card at the factory. It's like a serial number that never changes.
1 | |
Six pairs of hexadecimal digits. Every network device in the world has a unique one!
1 2 3 4 | |
IP vs MAC: What's the Difference?
| Feature | IP Address | MAC Address |
|---|---|---|
| Assigned by | Network/DHCP | Manufacturer |
| Can change? | Yes (dynamic) | No (permanent) |
| Scope | Global routing | Local network only |
| Format | Numbers (IPv4/IPv6) | Hexadecimal pairs |
Think of it this way: your MAC address is like your name (permanent), while your IP address is like your current phone number (can change when you move).
DNS: The Internet's Phone Book
DNS (Domain Name System) translates human-readable names into IP addresses. Because nobody wants to memorize 142.250.80.46 when they can just type google.com.
1 2 3 4 5 6 7 8 9 10 | |
How DNS Works
- You type
example.comin your browser - Your computer asks your router's DNS server
- That server asks a root DNS server
- The root server points to the
.comservers - The
.comserver points toexample.com's DNS - Finally, you get the IP address!
All this happens in milliseconds. DNS is basically magic.
MicroSim: DNS Resolution Journey
Description: Animated visualization showing a DNS query traveling through the DNS hierarchy.
Elements: - User's computer (left side) - Local DNS resolver - Root DNS server (labeled with ".") - TLD server (labeled ".com", ".org", etc.) - Authoritative DNS server - Final response traveling back
Animation: - Packet (small envelope icon) travels from computer to resolver - Resolver checks cache (show "Cache Miss" or "Cache Hit") - If miss: packet travels through hierarchy - Each server responds with "Ask this server instead" until final answer - Response travels back through chain - Total time counter showing milliseconds
Interactivity: - Slider to control animation speed - Dropdown to select different domains to resolve - Toggle to show/hide cache at each level - "Break" button to simulate a DNS failure
Skill: Use microsim-p5 to implement this visualization
When the Internet is 'Down'
90% of "the internet is broken" problems are actually DNS issues. If you can ping an IP address but not a domain name, DNS is your culprit!
Hostname Resolution: Local Name Lookups
Hostname resolution is the process of turning a name into an IP address. DNS is part of this, but there's also a local file:
1 2 3 4 5 6 7 | |
The /etc/hosts file is checked BEFORE DNS. This is useful for:
- Blocking websites (point them to 127.0.0.1)
- Testing local servers with friendly names
- Overriding DNS for development
1 2 3 4 5 6 | |
Network Interfaces: Your Network Connections
Network interfaces are the connection points between your computer and networks. Each physical or virtual network connection gets its own interface.
Common interface names:
| Name | Type |
|---|---|
eth0, enp0s3 |
Wired Ethernet |
wlan0, wlp2s0 |
Wireless WiFi |
lo |
Loopback (localhost) |
docker0 |
Docker bridge |
virbr0 |
Virtual machine bridge |
1 2 3 4 5 6 | |
The weird names like enp0s3 are "predictable network interface names"—they describe the hardware location so the name doesn't change if you add more network cards.
The Ifconfig Command: The Classic Tool
The ifconfig command was the original tool for viewing and configuring network interfaces. It's been around since the 1980s!
1 2 3 4 5 6 7 8 | |
Deprecated but Not Dead
ifconfig is from the net-tools package and is considered deprecated. Modern Linux uses ip from iproute2. However, you'll still see ifconfig in tutorials and older scripts everywhere.
The Ip Command: The Modern Way
The ip command is the modern replacement for ifconfig, route, and other network tools. One command to rule them all!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Configuring Interfaces with ip
1 2 3 4 5 6 7 8 9 10 11 12 | |
The Ping Command: Are You There?
The ping command sends a small packet to another computer and waits for a response. It's the "Hello? Can you hear me?" of networking.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Reading Ping Output
1 2 3 4 | |
| Field | Meaning |
|---|---|
64 bytes |
Response packet size |
icmp_seq |
Sequence number (should increment) |
ttl |
Time To Live (hops remaining) |
time |
Round-trip time in milliseconds |
Ping Troubleshooting
- No response: Host is down, blocking ICMP, or network issue
- High time: Network congestion or long physical distance
- Packet loss: Unreliable network or overloaded server
- TTL decreasing: Normal for different hosts; very low TTL might indicate routing loops
MicroSim: Ping Packet Journey
Description: Visual simulation of ICMP ping packets traveling through a network.
Layout: - Source computer (left) - Multiple network hops (routers/switches in middle) - Destination server (right) - Path visualization connecting all nodes
Animation: - Packet (small colored dot) travels from source - Passes through each hop, with hop count decreasing (TTL) - Arrives at destination - Response packet travels back (different color) - Timer shows round-trip time
Interactivity: - Select destination: Local (fast), Same city (medium), International (slow) - Simulate packet loss checkbox - Simulate high latency checkbox - "Break" a hop to show how failures appear - Counter for packets sent/received/lost
Failure Modes: - Timeout (packet disappears at broken hop) - Packet loss (random packets vanish) - High latency (packets slow down visibly)
Skill: Use microsim-p5 to implement this visualization
The Traceroute Command: Map the Journey
The traceroute command shows every hop (router) between you and a destination. It's like GPS tracking for your network packets!
1 2 3 4 5 6 7 8 9 10 11 | |
Reading Traceroute Output
1 2 3 4 5 | |
Each line is a hop: - Number: Hop count from you - Name/IP: Router at that hop - Three times: Three probe results
The * * * means that hop didn't respond (many routers hide from traceroute for security).
MicroSim: Network Traceroute Visualization
Description: Interactive map showing packet route through multiple network hops.
Layout: - World/network map background - Nodes representing routers/hops - Animated packets traveling between nodes - Timing information displayed at each hop
Elements: - Source node (your computer) - Multiple intermediate hops (routers) - Destination node (target server) - Path lines connecting nodes - Latency labels on each segment
Animation: - TTL-limited packets sent (stop at each hop) - Each hop sends back "time exceeded" message - Build up the complete path progressively - Show timing for each segment
Interactivity: - Select different destination types (local/regional/international) - Click on any hop to see detailed info - Simulate a "dead" hop to show how traceroute reveals failures - Toggle between geographic view and logical network view
Skill: Use microsim-p5 to implement this visualization
The Netstat Command: Network Statistics
The netstat command displays network connections, routing tables, and interface statistics. It's your network's status dashboard!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Common netstat Combinations
| Command | Shows |
|---|---|
netstat -tulnp |
TCP/UDP listening ports with processes |
netstat -an |
All connections, numeric (no DNS) |
netstat -r |
Routing table |
netstat -i |
Interface statistics |
netstat is Deprecated
Like ifconfig, netstat is from net-tools and is deprecated. Use ss instead—it's faster and more powerful!
The Ss Command: Socket Statistics
The ss command is the modern replacement for netstat. It's faster and provides more information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
Comparing netstat and ss
| netstat | ss | Purpose |
|---|---|---|
netstat -tulnp |
ss -tulnp |
Listening ports |
netstat -an |
ss -an |
All connections |
netstat -r |
ip route |
Routing table |
Network Ports: The Apartment Numbers
Network ports are like apartment numbers in a building. The IP address gets you to the building (computer), and the port number gets you to the specific service.
Ports range from 0-65535:
| Range | Type | Examples |
|---|---|---|
| 0-1023 | Well-known (privileged) | 22 (SSH), 80 (HTTP), 443 (HTTPS) |
| 1024-49151 | Registered | 3306 (MySQL), 5432 (PostgreSQL) |
| 49152-65535 | Dynamic/Private | Temporary connections |
Common Ports to Know
| Port | Service | Description |
|---|---|---|
| 20, 21 | FTP | File Transfer Protocol |
| 22 | SSH | Secure Shell |
| 23 | Telnet | Insecure remote access (don't use!) |
| 25 | SMTP | Email sending |
| 53 | DNS | Domain name resolution |
| 80 | HTTP | Unencrypted web |
| 443 | HTTPS | Encrypted web |
| 3389 | RDP | Windows Remote Desktop |
1 2 3 4 5 6 | |
MicroSim: Network Ports and Firewalls
Description: Visual simulation of how ports and firewalls control network traffic.
Layout: - Client computer (left) - Firewall wall in the middle with numbered "doors" (ports) - Server with multiple services (right)
Elements: - Port doors: Some open (green), some closed (red), some filtered (yellow) - Service icons behind doors: Web server (80/443), SSH (22), Database (3306) - Packet animations trying to enter through ports
Animation: - Packets approach firewall - Open ports: Packet passes through - Closed ports: Packet bounces back with "Connection Refused" - Filtered ports: Packet disappears (dropped silently) - Response packets return through same port
Interactivity: - Click ports to open/close them - Toggle firewall on/off - Send test packets to different ports - Show SYN/ACK/RST responses
Skill: Use microsim-p5 to implement this visualization
The Curl Command: Transfer Data from URLs
The curl command transfers data from or to a server. It's incredibly powerful for testing APIs, downloading files, and debugging web issues.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Curl for API Testing
1 2 3 4 5 6 7 8 9 10 11 | |
The Wget Command: Download Files
The wget command is specialized for downloading files. It's simpler than curl but better for recursive downloads and continuing interrupted transfers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Curl vs Wget
| Feature | curl | wget |
|---|---|---|
| Protocols | Many (HTTP, FTP, SFTP, SCP, etc.) | HTTP, HTTPS, FTP |
| Recursive download | No | Yes |
| Resume downloads | Manual | Automatic with -c |
| API testing | Excellent | Basic |
| Output | stdout by default | File by default |
WiFi Configuration: Wireless Networking
WiFi configuration on Linux can be done through various tools depending on your distribution.
Using NetworkManager (Most Distributions)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Using wpa_supplicant (Lower Level)
1 2 3 4 5 6 7 8 | |
WiFi Troubleshooting
1 2 3 4 5 6 7 8 9 10 11 | |
Network Troubleshooting: Debug Like a Pro
Network troubleshooting is a systematic process. When "the internet is broken," here's how to figure out what's actually wrong.
The Troubleshooting Ladder
Work from bottom to top:
- Physical: Is the cable plugged in? Is WiFi enabled?
- Link: Do you have a connection to the router?
- IP: Do you have an IP address?
- Gateway: Can you reach your router?
- Internet: Can you reach external IPs?
- DNS: Can you resolve domain names?
- Application: Does the specific service work?
Step-by-Step Network Debugging
Here's a complete example of debugging an internet outage:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
Quick Debug Commands
1 2 3 4 5 6 7 | |
MicroSim: Network Troubleshooting Simulator
Description: Interactive simulation where students diagnose network problems.
Layout: - Network diagram: Computer → Switch → Router → Firewall → Internet → DNS → Website - Control panel to "break" different components - Terminal panel showing command outputs - Status indicators for each component
Scenarios: 1. Cable unplugged (no link light) 2. No DHCP (no IP address) 3. Wrong gateway (can't reach internet) 4. DNS failure (can ping IP but not domains) 5. Firewall blocking (connection refused/timeout) 6. Website down (everything else works)
Interactivity: - Click components to "break" them - Type commands in terminal (ping, traceroute, etc.) - See realistic output based on what's broken - Hints available for each scenario - Score/timer for gamification
Learning Goals: - Understand the troubleshooting ladder - Learn to isolate problems systematically - Practice reading command output
Skill: Use microsim-p5 to implement this visualization
The "Wait for Network" Script
Here's a script that beeps when your network comes back up—perfect for when you're waiting for your ISP to fix an outage:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
Make it executable and run:
1 2 3 4 5 6 7 8 9 10 | |
Pro Tip: Background It
Run the script in the background while you do other things:
1 | |
MicroSim: Packet Journey Through the Internet
Description: Comprehensive animated visualization showing how data travels across the internet.
Layout: - Full network diagram with multiple paths - Your computer → Local network → ISP → Internet backbone → Destination - Multiple potential routes shown - Firewalls, routers, DNS servers all visible
Journey Steps: 1. Application creates data 2. Data broken into packets 3. Packets get IP headers 4. ARP resolves gateway MAC 5. Packets sent to gateway 6. Router forwards based on routing table 7. Packets traverse multiple hops 8. NAT translation occurs 9. Packets reach destination 10. Response travels back
Interactivity: - Follow a single packet (highlight its journey) - Speed control (slow-mo to understand, fast to see volume) - Click any node to see its routing table - Inject failures at any point - Toggle encryption visualization (HTTPS wrapping) - Show/hide different protocol layers
Failure Simulations: - DNS server unreachable - Router failure (show alternate routing) - Firewall blocks connection - Packet loss (some packets disappear) - High latency (packets slow down)
Skill: Use microsim-p5 to implement this visualization
Putting It All Together: Network Commands Cheat Sheet
| Task | Command |
|---|---|
| Show IP addresses | ip addr show |
| Show routing table | ip route show |
| Test connectivity | ping -c 4 host |
| Trace route to host | traceroute host |
| Show listening ports | ss -tulnp |
| Look up DNS | nslookup domain |
| Download file | wget URL or curl -O URL |
| Test HTTP response | curl -I URL |
| Show WiFi networks | nmcli device wifi list |
| Connect to WiFi | nmcli device wifi connect "SSID" password "pass" |
Key Takeaways
Congratulations, network ninja! You now understand:
- IP addresses: Your computer's identity on the network
- MAC addresses: Hardware-level identifiers
- DNS: The phone book that maps names to IPs
- Interfaces: Your connection points to networks
- Ping: Testing if a host is reachable
- Traceroute: Mapping the path to a destination
- Ports: Service addresses on a computer
- curl/wget: Transferring data from the internet
- Troubleshooting: Systematic approach to finding problems
You're Network-Savvy Now!
The next time someone says "the internet is broken," you'll be the one who figures out it's actually DNS. (It's always DNS.)
What's Next?
Now that you understand networking, it's time to connect SECURELY! The next chapter covers SSH—the secure way to access remote systems.
Quick Quiz: Networking Fundamentals
- What's the difference between an IP address and a MAC address?
- What command shows your computer's IP address?
- What does DNS do?
- How would you test if a remote server is reachable?
- What's the difference between
pingandtraceroute? - Which port does HTTPS use?
- If you can ping 8.8.8.8 but not google.com, what's likely broken?
Quiz Answers
- IP is assigned by network and can change; MAC is hardware-burned and permanent
ip addr show(orhostname -Ifor just the IP)- Translates domain names (like google.com) into IP addresses
ping hostnameorping ip-addresspingtests if a host is reachable;tracerouteshows every hop along the path- Port 443
- DNS is broken (you can reach the internet but can't resolve names)
References
- TCP/IP Guide - Classic introduction to TCP/IP networking fundamentals
- IP Command Tutorial - Comprehensive guide to the modern ip command with examples
- DNS Explained - Cloudflare's clear explanation of how DNS works
- Understanding IPv4 vs IPv6 - Why IPv6 exists and the transition from IPv4
- NetworkManager Guide - Complete guide to NetworkManager and nmcli for WiFi configuration
- Ping Command Tutorial - GeeksForGeeks guide to using ping for network diagnostics
- Traceroute Explained - How traceroute works and how to interpret results
- Common Network Ports - Official IANA port number registry
- curl Tutorial - Official curl manual with comprehensive examples
- wget Command Guide - GNU wget official documentation
- NetworkManager nmcli Examples - Red Hat guide to managing network connections with nmcli
- OSI Model Explained - Understanding the seven-layer network model
- Netstat vs SS Command - Modern ss command replacing deprecated netstat
- Network Troubleshooting Guide - DigitalOcean's systematic approach to network issues
- Understanding MAC Addresses - HowToGeek explanation of MAC addresses and their purpose
- curl vs wget Comparison - When to use curl versus wget for downloads
- NAT Explained - Understanding Network Address Translation and port forwarding
- DNS Resolution Process - Detailed walkthrough of how DNS queries work
- Linux Network Commands - Linux Journey's beginner-friendly networking lesson
- WiFi Configuration on Linux - Complete guide to wireless networking on Linux