Objective. Students will inspect network interfaces, test connectivity, resolve hostnames, examine open ports, and apply basic ufw firewall rules on a Linux server.
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.
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`.
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.
`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.
`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.
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.
`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.
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.
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.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.