Networking

Linux/RHEL networking notes for checking connectivity, IP addresses, routes, DNS, ports, and firewall basics.

Use this page when a server cannot be reached, a service is not accessible, DNS is not resolving, or a port is not listening.


Basic network information

Show IP addresses

ip a

Alternative shorter command:

ip addr

Show IPv4 addresses only

ip -4 a

Show network interfaces

ip link

Show routes

ip r

Alternative:

ip route

Show default gateway

ip route | grep default

Connectivity tests

Ping a host

ping example.com

Limit to 4 pings:

ping -c 4 example.com

Ping an IP address

ping -c 4 8.8.8.8

Useful to test basic network connectivity without DNS.


Test HTTP/HTTPS connection

curl -I https://example.com

Show full HTTP request details

curl -v https://example.com

Useful when troubleshooting TLS, redirects, or connection failures.


Test a specific port with curl

curl -v telnet://HOSTNAME:PORT

Example:

curl -v telnet://server01:443

DNS checks

Resolve a hostname with dig

dig example.com

Short DNS answer

dig +short example.com

Query a specific DNS server

dig @8.8.8.8 example.com

Resolve with nslookup

nslookup example.com

Check local resolver config

cat /etc/resolv.conf

Check hostname resolution order

cat /etc/nsswitch.conf

Look for the hosts: line.

Example:

hosts: files dns

This means the system checks /etc/hosts first, then DNS.


Check local hosts file

cat /etc/hosts

Ports and listening services

Show listening TCP/UDP ports

ss -tulpn

Show listening TCP ports only

ss -tlpn

Search for a specific port

ss -tulpn | grep :PORT

Example:

ss -tulpn | grep :22

Search for a process using a port

sudo lsof -i :PORT

Example:

sudo lsof -i :443

If lsof is not installed, use ss.


Routing checks

Show route to a specific IP

ip route get 8.8.8.8

Trace route

traceroute example.com

If traceroute is not installed:

tracepath example.com

Check ARP/neighbour table

ip neigh

NetworkManager / nmcli

RHEL commonly uses NetworkManager.

Show NetworkManager status

nmcli general status

Show connections

nmcli connection show

Show devices

nmcli device status

Show details for one connection

nmcli connection show CONNECTION_NAME

Bring connection up

sudo nmcli connection up CONNECTION_NAME

Bring connection down

sudo nmcli connection down CONNECTION_NAME

Use carefully on remote servers. Bringing down the wrong connection can disconnect you.


Firewall basics

RHEL often uses firewalld.

Check firewall state

sudo firewall-cmd --state

List active firewall configuration

sudo firewall-cmd --list-all

List open ports

sudo firewall-cmd --list-ports

List allowed services

sudo firewall-cmd --list-services

Show active zones

sudo firewall-cmd --get-active-zones

Add temporary port

sudo firewall-cmd --add-port=8080/tcp

Temporary means it will not survive reload/reboot.


Add permanent port

sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

Remove permanent port

sudo firewall-cmd --remove-port=8080/tcp --permanent
sudo firewall-cmd --reload

Common network troubleshooting flow

When a server or service is not reachable:

1. Is the server up?
2. Does the server have the expected IP address?
3. Is the route/default gateway correct?
4. Does DNS resolve correctly?
5. Is the service listening on the expected port?
6. Is the firewall allowing the port?
7. Is the issue local, network, DNS, firewall, or application-related?

First commands for network issues

hostnamectl
ip a
ip r
ip route get 8.8.8.8
cat /etc/resolv.conf
dig example.com
ping -c 4 example.com
ss -tulpn
sudo firewall-cmd --list-all

DNS troubleshooting flow

1. Does ping to IP work?
2. Does ping to hostname fail?
3. What does /etc/resolv.conf show?
4. Does dig return an answer?
5. Does dig with another DNS server work?
6. Is /etc/hosts overriding anything?
7. Is the DNS issue only on one server?

Commands:

ping -c 4 8.8.8.8
ping -c 4 example.com
cat /etc/resolv.conf
dig example.com
dig @8.8.8.8 example.com
cat /etc/hosts

Port troubleshooting flow

1. Is the service running?
2. Is the service listening?
3. Is it listening on the correct IP?
4. Is it listening on the correct port?
5. Is the local firewall open?
6. Is there an external firewall/load balancer/security group?

Commands:

systemctl status SERVICE_NAME
ss -tulpn | grep :PORT
sudo firewall-cmd --list-all
curl -v telnet://HOSTNAME:PORT

Safe notes

Be careful when changing network configuration remotely.

Dangerous commands during remote work:

nmcli connection down ...
systemctl restart NetworkManager
ip link set ... down
firewall-cmd --reload

These can disconnect the session if used incorrectly.


Personal notes

Add work-specific lessons here, but sanitize:

- No real hostnames
- No real IP addresses
- No customer names
- No internal URLs