Lab 20: Networking Basics (Capstone)

Objective

Understand Linux networking fundamentals: IP addresses, interfaces, routing, /etc/hosts, DNS, ping, curl, ss, and network troubleshooting. This capstone ties together everything from the Foundations level with a real-world network diagnostic workflow.

Time: 35 minutes | Level: Foundations | Docker: docker run -it --rm ubuntu:22.04 bash


Step 1: Network Interfaces

ip addr show

📸 Verified Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:42:ac:11:00:06 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.6/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

Key fields:

  • lo: Loopback interface — 127.0.0.1, traffic stays on this machine

  • eth0: Network interface — 172.17.0.6/16 is the container's IP

  • /16 = subnet mask (covers 172.17.0.0 to 172.17.255.255)

💡 Every Linux server has at least lo (loopback). Real servers have eth0, ens3, enp0s3, etc. Cloud VMs may have ens3 or ens160. The name depends on the driver and BIOS.


Step 2: Hostname and IP

📸 Verified Output:

📸 Verified Output:

📸 Verified Output:


Step 3: DNS Configuration

📸 Verified Output:

💡 nameserver 8.8.8.8 = Google's DNS. When you type curl google.com, the system asks 8.8.8.8 to resolve google.com to an IP address. Without a nameserver, hostnames won't resolve.

📸 Verified Output:


Step 4: Routing Table

📸 Verified Output:

  • default via 172.17.0.1 — all traffic not matching other routes goes to this gateway

  • 172.17.0.0/16 — this subnet is directly accessible via eth0

💡 The routing table is your network map. Traffic to 172.17.x.x goes directly. Everything else hits the default gateway. Misconfigured routing = no network access, even if the interface is up.


Step 5: Checking Open Ports with ss

📸 Verified Output:

📸 Verified Output:

💡 ss replaced netstat on modern Linux. -t=TCP, -u=UDP, -l=listening, -n=numeric (no DNS lookups), -p=show process. On a real server: ss -tlnp shows you every open port and which process owns it — essential for security audits.


Step 6: curl — HTTP from the Command Line

📸 Verified Output:

📸 Verified Output:

📸 Verified Output:


Step 7: ping — Connectivity Test

📸 Verified Output:

💡 ping sends ICMP echo requests. 0% packet loss = connectivity OK. High RTT = latency. Some hosts block ICMP (firewalls), so ping failure ≠ host is down — always verify with curl too.


Step 8: Capstone — Network Diagnostic Script

📸 Verified Output:


Summary

Command
Purpose

ip addr show

List network interfaces and IPs

ip route show

Routing table

hostname

Show hostname

hostname -i

Show primary IP

cat /etc/hosts

Local DNS overrides

cat /etc/resolv.conf

DNS server config

ss -tlnp

TCP listening ports

ping -c N host

ICMP connectivity test

curl -sI url

HTTP header check

curl -sL url -o file

Download file

getent hosts name

DNS lookup


Foundations Level Complete! 🎉

You have completed all 20 Linux Foundations labs. You can now:

  • Navigate the Linux filesystem and understand the FHS

  • Create, copy, move, and delete files safely

  • Read and modify file permissions and ownership

  • Manage users, groups, and service accounts

  • Use essential tools: grep, find, ps, df, du, curl

  • Write shell scripts with variables, loops, and functions

  • Understand I/O redirection and build command pipelines

  • Diagnose network issues and understand Linux networking

Next Level: Linux Practitioner — system services, cron, SSH hardening, firewalls, and log management.

Last updated