🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › Linux/Bash for Web & Software Development › Lesson 9
TEC-WEB46-06 · Lesson 9 · 14 clock hours · lab

Linux Networking for Developers

Objective. Students will inspect network interfaces, test connectivity, resolve hostnames, examine open ports, and apply basic ufw firewall rules on a Linux server.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Linux Networking for Developers

Understanding how a Linux server connects to the network is a core skill for anyone building or deploying web applications. This lesson covers inspecting network interfaces, testing connectivity, resolving hostnames, examining open ports, and applying firewall rules with `ufw`.

Inspecting Network Interfaces

The `ip` command from the iproute2 package is the modern tool for network interface management. To see all interfaces and their IP addresses, run:

```

ip addr

```

Each interface block shows the interface name (for example, `eth0` or `ens3`), its hardware (MAC) address, and any IPv4 or IPv6 addresses assigned. The loopback interface (`lo`) is always present and uses the `127.0.0.1` address for internal communication only.

To view the routing table — the map your system uses to decide where to send packets — run:

```

ip route

```

The line beginning with `default via` shows the default gateway, the address of the router that handles traffic destined outside the local network.

Testing Connectivity

`ping` sends ICMP echo requests to a target and reports round-trip time. It confirms basic reachability:

```

ping -c 4 8.8.8.8

```

The `-c 4` flag sends exactly four packets. If replies come back, the path to that host is open. If they do not, the host may be unreachable, offline, or blocking ICMP.

`traceroute` shows each hop (router) a packet passes through on its way to a destination. This helps isolate where a connection breaks:

```

traceroute example.com

```

Asterisks (` *`) at a hop mean that router is not responding to probes — this does not always indicate a fault.

Resolving Hostnames with dig

`dig` queries DNS servers and returns detailed records. To look up the IP address for a hostname:

```

dig example.com

```

The ANSWER SECTION shows the resolved IP address. You can request a specific record type with:

```

dig example.com MX

```

For quick checks, `dig +short example.com` returns only the IP address. DNS resolution failures are a common cause of web application errors, so being comfortable reading `dig` output is essential.

Examining Open Ports with ss

The `ss` command (from iproute2) replaces the older `netstat` for listing sockets. To list all TCP and UDP listening ports in numeric form:

```

ss -tuln

```

The output shows the local address and port a service is bound to. A web server on port 80 appears as `0.0.0.0:80` (all interfaces) or a specific IP. If Apache is not shown here, it is not running or is bound to the wrong port.

Making HTTP Requests with curl

`curl` transfers data to or from a server using URLs. For web development testing:

```

curl http://localhost

curl -v http://192.168.1.10

```

The `-v` flag shows verbose output including headers. A `200 OK` response confirms the web server is running and reachable. A `Connection refused` message means nothing is listening on that port.

Managing the Firewall with ufw

ufw (Uncomplicated Firewall) is a user-friendly front-end for Linux's built-in `iptables` packet filtering. Always configure the firewall carefully — locking yourself out of SSH is a real risk.

Safety point: Before applying a default-deny rule, confirm that SSH (port 22) is explicitly allowed. Losing SSH access to a remote server means you cannot recover without console access.

Basic ufw workflow:

```

sudo ufw default deny incoming

sudo ufw default allow outgoing

sudo ufw allow 22/tcp

sudo ufw allow 80/tcp

sudo ufw enable

```

To review the active rule set:

```

sudo ufw status verbose

```

This lists each rule, the direction it applies, and its action. To remove a rule:

```

sudo ufw delete allow 80/tcp

```

When you enable ufw with a default-deny policy, any port not explicitly allowed is refused. A `curl` request to a blocked port returns `Connection refused` or times out, confirming the firewall is working.

Troubleshooting Web Server Connectivity

A systematic approach saves time. When a web server does not respond:

1. Check the service is running: `systemctl status apache2`

2. Confirm which port it is listening on: `ss -tuln`

3. Check firewall rules: `sudo ufw status verbose`

4. Test locally first: `curl http://localhost`

5. Test remotely to isolate firewall vs. application issues.

Common root causes include Apache bound to `127.0.0.1` instead of `0.0.0.0` (unreachable from outside), a missing ufw allow rule for port 80, or Apache configured to listen on a non-standard port.

Safety and Best Practices

Key terms8

ip addrAn iproute2 command that displays all network interfaces and their assigned IP and MAC addresses on a Linux system.
Default gatewayThe router address a host sends packets to when the destination is outside the local network, shown in the output of 'ip route'.
ssA socket statistics utility from iproute2 that lists open, listening, and established network connections; replaces the older netstat command.
digA DNS lookup utility that queries name servers and returns detailed DNS records including A, MX, and CNAME record types.
ufwUncomplicated Firewall, a front-end for Linux iptables that provides straightforward commands for managing inbound and outbound traffic rules.
Default deny policyA firewall stance in which all inbound traffic is blocked unless an explicit allow rule exists for that port or protocol.
curlA command-line tool that transfers data using URLs; commonly used to test HTTP responses from web servers and APIs.
tracerouteA network diagnostic command that displays the sequence of routers (hops) a packet travels through to reach a destination host.
In class: Guided practice: students use ip addr, ip route, ss -tuln, ping, traceroute, dig, and curl to map the network configuration of their VM and document each command's output in a structured worksheet. · Firewall lab: students configure ufw to allow SSH and HTTP (ports 22 and 80), deny all other inbound traffic by default, verify the rule set with 'ufw status verbose', and test that a curl request to the Apache server succeeds while a connection to an unconfigured port is refused. · Troubleshooting scenario: instructor provides a VM with a broken web server (wrong port bound, ufw rule missing); students diagnose the issue using ss and ufw status, correct it, and document the root cause and fix in their lab log.
Materials: Student VMs, iproute2 and net-tools packages, ufw man page, curl, troubleshooting scenario VM snapshot
Check: Instructor tests connectivity to Apache on port 80 (must succeed) and to a blocked port (must fail); troubleshooting root cause must be correctly identified in the lab log — pass requires both connectivity outcomes and a correct written root cause.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Linux+ - Networking
1. A developer runs 'ip addr' on a VM and sees only the loopback interface (lo) and 'ens3'. The ens3 interface shows no IPv4 address. What is the most likely cause?
CompTIA Linux+ - Networking
2. Which command lists only TCP and UDP ports that are currently listening, displaying port numbers as integers rather than service names?
CompTIA Linux+ - Security
3. A student enables ufw with 'sudo ufw default deny incoming' but forgets to add an allow rule for port 22 before running 'sudo ufw enable'. What is the most likely consequence?
CompTIA Linux+ - Networking
4. After configuring ufw to allow port 80 and running Apache, a remote 'curl http://server-ip' returns 'Connection refused'. 'ss -tuln' shows Apache listening on 127.0.0.1:80. What is the root cause?
CompTIA ITF+ - Networking Concepts
5. What information does the ANSWER SECTION of a 'dig example.com' response contain?
CompTIA Linux+ - Security
6. A student runs 'sudo ufw status verbose' and sees no rules listed and the status shows 'inactive'. What must the student do to activate the firewall with the configured rules?
CompTIA ITF+ - Software and Application Concepts
7. Which command would a developer use to quickly confirm that a remote web server is returning an HTTP 200 status code?
CompTIA Linux+ - Networking
8. During the troubleshooting lab, a student finds Apache is running and listening on port 8080 instead of port 80, and ufw has no rule for port 8080. Which two actions will restore access on the standard HTTP port?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.