
When a server cannot be reached, or cannot reach something else, you need a short, reliable routine: is the network interface up, does it have an address, is there a route out, does DNS work, is the port open, is the firewall in the way? This guide teaches the commands for each step: ip, ping, ss, curl, dig, nmcli and firewall-cmd. Examples use RHEL 9, AlmaLinux 9 and Rocky Linux 9, where NetworkManager and firewalld are the defaults. The addresses in the examples are private or documentation ranges, so replace them with your own.
A troubleshooting order that saves time
Work from the bottom of the network stack upward and stop at the first step that fails:
- Link: is the interface up? (
ip link) - Address: does it have an IP address? (
ip address) - Gateway: is there a default route, and can you reach the router? (
ip route,ping) - Internet by number: can you reach
1.1.1.1? (ping) - DNS: do names resolve? (
dig) - Port: is the service listening, and is the port reachable? (
ss,curl,nc) - Firewall: does the firewall allow it? (
firewall-cmd)
Interfaces and addresses with ip
ip replaced the old ifconfig and route. Add -br for a compact, readable table:
$ ip -br link
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
ens18 UP 52:54:00:ab:cd:ef <BROADCAST,MULTICAST,UP,LOWER_UP>
$ ip -br address
lo UNKNOWN 127.0.0.1/8 ::1/128
ens18 UP 192.168.1.50/24 fe80::5054:ff:feab:cdef/64
- The name (
ens18here) varies by machine.lois the loopback interface,127.0.0.1. UPmeans the interface is enabled. If the flags do not includeLOWER_UP, there is no physical link, for example an unplugged cable or a disconnected virtual NIC.192.168.1.50/24is the address and the prefix length (the network size). If you see only anfe80::address and no IPv4 address, DHCP or your static configuration has failed.
The routing table
$ ip route
default via 192.168.1.1 dev ens18 proto dhcp src 192.168.1.50 metric 100
192.168.1.0/24 dev ens18 proto kernel scope link src 192.168.1.50 metric 100
ip route get 8.8.8.8 # which path will traffic to this address take?
The line starting with default via is your gateway. No default line means the machine can talk to its own network and nowhere else.
Reaching things with ping and traceroute
ping -c 4 192.168.1.1 # your gateway
ping -c 4 1.1.1.1 # the internet, by number
ping -c 4 example.com # the internet, by name (needs DNS)
tracepath example.com # the hops along the path (no root needed)
sudo dnf install traceroute # for the classic traceroute command
Use -c to stop after a set number of packets, otherwise ping runs until you press Ctrl+C. How to read the result:
| Result | What it tells you |
|---|---|
Gateway works, 1.1.1.1 works, name fails |
The network is fine; the problem is DNS |
Gateway works, 1.1.1.1 fails |
Problem at the router or your provider, or traffic is blocked |
| Gateway fails | Wrong address or netmask, wrong VLAN, bad cable or virtual switch |
Replies show high or varying time= |
Congestion or a poor link |
Many servers and firewalls deliberately ignore ping. A failed ping does not always mean a host is down, so confirm with a test to the actual service port.
DNS: does the name resolve?
dig example.com +short # the address records
dig example.com @1.1.1.1 +short # ask a specific DNS server
cat /etc/resolv.conf # which DNS servers this machine uses
nmcli device show ens18 | grep DNS
If the answer from @1.1.1.1 is right but your default lookup fails, the DNS server your machine uses is the problem. dig is in the bind-utils package (sudo dnf install bind-utils). Our DNS troubleshooting guide goes much deeper.
What is listening? ss
ss replaced netstat. The most useful form lists every listening TCP and UDP socket with the owning program:
$ sudo ss -tulpn
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=812,fd=3))
tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1204,fd=6))
udp UNCONN 0 0 127.0.0.1:323 0.0.0.0:* users:(("chronyd",pid=745,fd=5))
The letters mean: t TCP, u UDP, l listening, p show the process (needs sudo for other users’ programs), n numbers instead of names.
0.0.0.0:80or[::]:80means the service accepts connections on every interface.127.0.0.1:5432means it listens only on the machine itself. Nobody else can connect, which is correct for a database that should not be public, and the reason a “port is closed” complaint sometimes is not about the firewall at all.
sudo ss -ltnp 'sport = :8080' # who owns port 8080?
ss -tn state established # current TCP connections
ss -s # a summary of socket counts
Testing a port and a web service
curl -I https://example.com # response headers only
curl -sS -o /dev/null -w '%{http_code}\n' https://example.com # just the status code
curl -v http://192.168.1.50:8080/ # full detail: connection, headers
nc -zv 192.168.1.50 22 # is the TCP port open?
sudo dnf install nmap-ncat # provides nc on RHEL
Test from the machine that has the problem. A service can work locally (curl localhost) and still be unreachable from outside because of the firewall, a cloud security group or a listener bound to 127.0.0.1. For a slow, rather than unreachable, site, measure each stage with curl.
| Symptom | Likely meaning |
|---|---|
Connection refused |
The machine answered, but nothing listens on that port (or it listens on another address) |
Connection timed out |
Packets are being dropped: firewall, wrong IP, or route problem |
No route to host |
No path, or the firewall actively rejects the connection |
Could not resolve host |
DNS failure |
The firewall: firewalld
RHEL-family systems use firewalld. It groups rules into zones. The default zone is usually public, which allows SSH and blocks most other incoming traffic.
sudo firewall-cmd --state # running?
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all # services, ports and settings of the default zone
$ sudo firewall-cmd --list-all
public (active)
target: default
interfaces: ens18
services: cockpit dhcpv6-client ssh
ports:
...
To open a service or port:
sudo firewall-cmd --permanent --add-service=http # a named service (port 80)
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-port=8080/tcp # a single port
sudo firewall-cmd --reload # apply the permanent rules
sudo firewall-cmd --permanent --remove-port=8080/tcp # close it again
sudo firewall-cmd --reload
Two things trip people up. Runtime versus permanent: without --permanent a change disappears at the next reload or reboot, and with --permanent it does not apply until you run --reload. And never remove the SSH service from a server you manage remotely, or you will lock yourself out. Keep --add-service=ssh in place, and test any firewall change from a second session before you close the first.
Also remember that a cloud provider may add its own firewall (security groups) in front of the server. Both must allow the traffic.
Changing the network settings with nmcli
NetworkManager manages connections on RHEL 9. nmcli is its command-line client:
nmcli device status # interfaces and their state
nmcli connection show # saved connection profiles
nmcli device show ens18 # live details, including DNS
hostnamectl # the host name and system info
sudo hostnamectl set-hostname web01.example.com
To give an interface a fixed address, change the connection profile and bring it up again:
sudo nmcli connection modify ens18 ipv4.method manual \
ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns "1.1.1.1 8.8.8.8"
sudo nmcli connection up ens18
Be careful over SSH: if you mistype the address or the gateway, the connection drops and you may need the console to repair it. Do this from the console if you can, or schedule a safety net such as an automatic revert. The connection name often matches the interface name, but check with nmcli connection show first.
Quick reference
| Question | Command |
|---|---|
| What is my IP address? | ip -br address |
| What is my gateway? | ip route (the default via line) |
| Is the internet reachable? | ping -c 4 1.1.1.1 |
| Does DNS work? | dig example.com +short |
| What is listening? | sudo ss -tulpn |
| Is a remote port open? | nc -zv host port |
| What does the website return? | curl -I https://site |
| Open a port in the firewall | firewall-cmd --permanent --add-port=PORT/tcp then --reload |
After you open the firewall for a new service, secure it too. For SSH, see SSH key login and disabling passwords, and for the many commands you will use alongside these, the Linux commands guide.
Frequently asked questions
What replaced ifconfig and netstat?
ip replaced ifconfig and route, and ss replaced netstat. The old tools come from the net-tools package, which is not installed by default on modern systems.
Why can I reach a service locally but not from another machine?
Check three things in order: the service listens on a public address and not only 127.0.0.1 (ss -tulpn), the firewalld zone allows the port (firewall-cmd --list-all), and no cloud or network firewall sits in between.
What is the difference between “refused” and “timed out”?
“Refused” means a machine answered and nothing is listening on that port. “Timed out” means no answer came back, which usually points to a firewall dropping packets or a wrong address.
Do I need to reload firewalld after every change?
Only for permanent rules. A rule added without --permanent takes effect at once but is lost at reload or reboot. A rule added with --permanent is saved but only active after firewall-cmd --reload.
Is it safe to turn the firewall off to test?
Avoid it on a server connected to the internet. Instead, open the one port you need and test, or use firewall-cmd --list-all to see what is allowed. Stopping the firewall exposes every listening service.
More tutorials like this
Linux Permission Denied Error: Causes and How to Fix It (chmod, namei, id)
Fix the Linux Permission denied error: read ls -l, namei -l and id, then add only the permission letter you need with chmod. Real…
Why Is My Website Slow? Measure DNS, TLS and Server Time with curl
Use curl to split a web request into DNS, connection, TLS, server and download time, read the numbers correctly and fix the slow part.
systemd Basics: Manage Services and Read Logs with systemctl and journalctl
Start, stop and enable services with systemctl, read logs with journalctl, write your own service and timer, and troubleshoot a service that will not…


