Sub topic 12
Verifying from the Server and from Outside
Assume you know basic Linux commands, sudo, TCP and UDP ports, IPv4 CIDR notation, and systemctl. This chapter focuses on verification: proving that a process listens, that firewalld allows it, and that a remote client can reach it.
Three different questions
A port test can answer different questions. Test them in order:
- Is an application listening on the expected address and port?
- Does firewalld allow traffic to that port in the zone that handles the connection?
- Can a remote host reach the server through all network controls?
A successful local check does not prove remote access. An application can listen correctly while firewalld, a cloud security group, or an upstream router blocks the connection.
Check the listening process on the server
The ss command displays socket information. A listening TCP socket means a process has bound to a port and is waiting for connections.
For port 8080, run:
sudo ss -tlnp | grep ':8080'The options mean:
-tshows TCP sockets.-lshows listening sockets.-nshows numeric addresses and ports.-pshows the owning process.
A result such as 0.0.0.0:8080 means the process listens on all IPv4 interfaces. A result such as 127.0.0.1:8080 means it listens only on the local machine. Remote clients cannot connect to a service bound only to 127.0.0.1.
An address like [::]:8080 usually represents all IPv6 interfaces. Check whether the application supports the address family that your client uses.
Check firewalld's view
First inspect the active zones and their rules:
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all
sudo firewall-cmd --query-port=8080/tcpThe active zone is selected by an interface or a source address. Do not assume that the default zone handles every connection. To inspect a particular zone, specify it explicitly:
sudo firewall-cmd --zone=public --list-all
sudo firewall-cmd --zone=public --query-port=8080/tcp--query-port returns yes or no. A service rule can also allow the port indirectly, so inspect both services and ports. For example, HTTP normally allows TCP port 80 through the predefined http service.
| Check | What it proves |
|---|---|
| `ss -tlnp` | A local process is listening |
| `firewall-cmd --query-port` | The selected zone allows that port and protocol |
| `nc -zv host port` | A remote connection attempt succeeded or failed |
Test from another host
Run this command on a different machine, not on the server:
nc -zv server.example.com 8080The nc command, also called Netcat, attempts a TCP connection without sending application data. Success shows that the port is reachable from that host. Failure can mean that firewalld rejected the traffic, the application is not listening, or another network control blocked it.
Test the same hostname and address family that real clients use. A DNS name might resolve to IPv6 while the application or firewall is configured only for IPv4.
A connection that is refused usually means the host is reachable but no application accepts the connection. A timeout often indicates filtering or a routing problem. These signals are useful clues, not absolute proof.
Diagnose an unreachable port
Compare these results:
- No
ssoutput: start the application or correct its bind address. - The process listens, but
query-portisno: open the port in the correct zone, then reload if the change is permanent. - Both local checks pass, but
nctimes out: inspect cloud security groups, network ACLs, routers, and host routing. ncis refused: confirm the application is still running and listening on the tested address.- The expected zone is not active: inspect interface assignments and source-based zone assignments.
For a short investigation, temporarily enable denied-packet logging:
sudo firewall-cmd --set-log-denied=all
sudo journalctl -k --since "10 minutes ago" | grep -i reject
sudo firewall-cmd --set-log-denied=offLogging confirms that firewalld saw and denied traffic. Turn it off after testing because busy servers can generate many log entries.
Exercise
The application appears in ss on 0.0.0.0:8080, and firewalld reports yes for TCP port 8080, but a remote nc test times out. What should you check next?
Show answer
Check the active zone and interface, then inspect cloud security groups, network ACLs, routing, and any upstream firewall between the client and server.