System Networking – Linux Teaching Plan
This 2‑hour module introduces Linux networking fundamentals. Students will learn how to inspect, test, troubleshoot and configure network interfaces, routes, DNS, firewalls and basic client‑server utilities.
Learning Objectives
- View and modify network interfaces and routing tables.
- Diagnose connectivity with ping, traceroute and curl.
- Inspect TCP/UDP sockets with ss/netstat.
- Resolve DNS names with nslookup/dig.
- Capture and analyze packets with tcpdump.
- Configure SSH and SCP for secure file transfer.
- Set up a simple HTTP server with Python or Apache.
- Write basic iptables (or nftables) rules for a firewall.
- Monitor service status with systemctl.
- Automate basic networking tasks with shell scripts.
Schedule & Topics
- Intro & terminology (5 min)
- Interfaces –
ip (10 min)
- Routing –
ip route (5 min)
- Socket view –
ss (10 min)
- Connectivity –
ping, traceroute (10 min)
- HTTP & HTTPS –
curl, python -m http.server (10 min)
- DNS –
nslookup/ dig (10 min)
- Packet capture –
tcpdump (10 min)
- SSH/SCP –
ssh, scp (10 min)
- Firewall –
iptables (or nft) (10 min)
- Service monitoring –
systemctl (10 min)
- Mini‑project: “Set up a secure web service & firewall” (15 min)
- Q&A & wrap‑up (5 min)
Command Topics & Hands‑On Exercises
1. ip – View & Configure Interfaces
Inspect current interfaces and assign an IP address.
ip link show
ip addr show eth0
sudo ip addr add 192.168.200.10/24 dev eth0
sudo ip link set eth0 up
- List all interfaces and note the MAC address of
lo.
- Bring down
eth0 (`ip link set eth0 down`), then back up.
- Assign a temporary IP to a dummy interface (`ip link add dummy0 type dummy; ip addr add 10.10.10.1/24 dev dummy0`).
2. ip route – Routing Table
Show and add routes.
ip route show
sudo ip route add 10.20.0.0/16 via 192.168.200.1 dev eth0
- Add a static route to a network you control, then test reachability with ping.
- Delete the route you just added.
3. ss – Socket Statistics
Inspect listening and established sockets.
ss -tuln
ss -a | grep LISTEN
- Start a Python HTTP server (`python3 -m http.server 8080 &`) → use ss to see the LISTEN socket.
- Find the socket that connects to
example.com after a `curl` command.
4. netstat – Traditional Socket Viewer
Often installed by default.
netstat -tulpen
- Verify that the same port is shown by `netstat` and `ss`.
- Show only the listening TCP ports.
5. ping – Basic Connectivity Test
Send ICMP echo requests.
ping -c 4 google.com
ping -I eth0 8.8.8.8
- Ping a local IP on the same subnet and a host on a different subnet.
- Use the -I option to specify the outgoing interface.
6. traceroute – Path Discovery
Shows each hop along a route.
traceroute google.com
traceroute -I google.com
- Run traceroute to an external site, note the number of hops.
- Repeat to a host that is unreachable and observe the timeout behavior.
7. nslookup / dig – DNS Resolution
Query DNS servers for records.
nslookup google.com
dig google.com +short
dig @8.8.8.8 example.com MX
- Resolve the IP of
stackoverflow.com with both tools.
- Query a specific DNS server (e.g., 1.1.1.1) for MX records of a domain.
8. curl – HTTP/HTTPS Client
Retrieve web content and test TLS.
curl -I https://www.example.com
curl --version
curl -v http://localhost:8080
- Use curl to download the homepage of your own local server (after it’s started).
- Show the response headers only with `-I`.
- Test a non‑existent page and note the 404 status.
9. tcpdump – Packet Capture
Sniff traffic on a specific interface.
sudo tcpdump -i eth0 -c 10
sudo tcpdump -i eth0 port 80 -w http.pcap
sudo tcpdump -r http.pcap -nn
- Capture the first 10 packets on the loopback interface.
- Filter HTTP traffic on
eth0 and write to a file.
- Read back the capture file and decode the packets.
10. ssh – Secure Remote Shell
Connect to a remote host securely.
ssh -p 2222 user@remote-host
ssh -i ~/.ssh/id_rsa user@remote-host
- Log in to the student’s personal VM using the default SSH port.
- Test key‑based authentication by generating a new key pair.
- Use `ssh -v` to view the authentication flow.
11. scp – Secure Copy
Transfer files between hosts.
scp file.txt user@remote-host:/home/user/
scp -P 2222 file.txt user@remote-host:/tmp/
- Copy a local file to a remote server and back.
- Use the `-r` flag to copy an entire directory tree.
12. iptables (or nft) – Basic Firewall
Block or allow traffic on the system.
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -j DROP
sudo iptables -L -n -v
- Allow SSH traffic only from a specific IP.
- Drop all inbound traffic except HTTP and SSH.
- View the rule table and the packet counts.
13. systemctl status networking – Service Status
Check the systemd networking unit.
systemctl status systemd-networkd
sudo systemctl restart systemd-networkd
- Restart the networking service and ensure the interface comes up again.
- Check the journal for any error messages (`journalctl -u systemd-networkd`).
14. iptables-save / nft flush – Persisting Rules
Save or clear rules.
sudo iptables-save > /etc/iptables/rules.v4
sudo nft flush chain inet filter INPUT
- Save the current iptables table to a file.
- Reload the saved rules with `iptables-restore`.
- For nftables users: create a minimal table/chain, add a rule, then flush it.
15. curl – FTP & File Upload
Use curl to upload or download files via FTP.
curl -u user:pass ftp://localhost/file.txt
curl -T localfile.txt ftp://user:pass@localhost/remote/
- Start an FTP daemon on the local host.
- Use curl to upload a small text file.
- Download the same file back to confirm integrity.
Mini‑Project: “Secure Web Service & Firewall”
Students will perform the following steps on a fresh VM (or a student’s own server):
- **Configure a network interface** – assign a static IP (e.g., 192.168.10.10/24) and add a default gateway.
- **Verify connectivity** – ping the gateway and a public site (e.g., 8.8.8.8, `ping -c 4 google.com`).
- **Start a simple HTTP server** – `python3 -m http.server 8000 &` (or install & start Apache). Log its PID.
- **Create firewall rules** – allow inbound TCP 8000 and SSH (22) only from a specific IP, drop everything else.
- **Test the firewall** – from another machine in the same subnet, try to access the web page; attempt to connect on a blocked port (e.g., 22 from a non‑whitelisted IP).
- **Capture traffic** – use `tcpdump -i eth0 port 8000 -w webtraffic.pcap` while accessing the page; then analyze the capture with Wireshark or `tcpdump -r`.
- **Transfer a file** – copy a test file via `scp` to the server; verify permissions and timestamps.
- **Automate** – write a shell script that restarts the HTTP server if it crashes, logs the restart time, and updates a firewall rule if the IP changes.
Students will present the steps they took, the commands they used, and the results of their packet capture.
Assessment
- Quiz (5 min) – 5 multiple‑choice questions covering ping, traceroute, DNS and firewall basics.
- Hands‑on exercise (10 min) – each student brings up a network interface, sets a route, and confirms connectivity with ping.
- Project demo (10 min) – students walk through the mini‑project steps and answer questions from peers.
Resources
Feel free to adjust the timeline or swap iptables for nftables depending on the distribution students are using. The goal is to give them a practical, step‑by‑step understanding of how Linux interacts with the network stack and how to diagnose real‑world problems.