Networking Explained
Basic Linux networking concepts explained in a simple, public-safe way.
Use this page to understand IP addresses, routes, DNS, ports, listening services, firewalls, and common network troubleshooting.
What is networking?
Networking is how computers communicate with each other.
Examples:
your laptop connects to a server
a server connects to a database
a browser connects to a website
a server resolves a DNS name
an application listens on a port
IP address
An IP address identifies a device on a network.
Example documentation IPs:
192.0.2.10
198.51.100.10
203.0.113.10
Show IP addresses:
ip a
Show IPv4 only:
ip -4 a
Network interface
A network interface is the network card or virtual network adapter.
Common interface names:
eth0
ens192
eno1
bond0
lo
Show interfaces:
ip link
lo is the loopback interface.
Loopback
Loopback means the system talks to itself.
Common loopback address:
127.0.0.1
Common hostname:
localhost
Example:
curl -I http://localhost
Default gateway
The default gateway is where traffic goes when the destination is outside the local network.
Show routes:
ip r
Show default gateway:
ip route | grep default
Route
A route tells Linux where to send network traffic.
Check route to a destination:
ip route get 192.0.2.10
This helps identify which interface and gateway are used.
DNS
DNS translates names into IP addresses.
Example:
example.com โ 93.184.216.34
Check DNS:
dig example.com
or:
nslookup example.com
Short answer:
dig +short example.com
DNS resolver config
Check resolver config:
cat /etc/resolv.conf
Check hostname lookup order:
cat /etc/nsswitch.conf
Look for:
hosts:
Example:
hosts: files dns
This means Linux checks /etc/hosts first, then DNS.
/etc/hosts
/etc/hosts can manually map hostnames to IP addresses.
Check:
cat /etc/hosts
Example:
192.0.2.10 server01.example.com server01
Be careful: /etc/hosts can override DNS.
Port
A port identifies a service on a system.
Common ports:
22 = SSH
53 = DNS
80 = HTTP
443 = HTTPS
631 = IPP/CUPS
3306 = MySQL/MariaDB
5432 = PostgreSQL
Listening service
A service is listening when it is waiting for network connections on a port.
Show listening ports:
ss -tulpn
Show TCP listening ports only:
ss -tlpn
Search for a specific port:
ss -tulpn | grep :PORT
Example:
ss -tulpn | grep :22
TCP and UDP
Two common network protocols:
TCP = connection-based, reliable
UDP = connectionless, lightweight
Examples:
SSH uses TCP
HTTP/HTTPS uses TCP
DNS often uses UDP, but can use TCP too
Ping
ping tests basic reachability using ICMP.
ping -c 4 example.com
Ping an IP:
ping -c 4 192.0.2.10
If ping to IP works but ping to hostname fails, suspect DNS.
curl
curl can test HTTP/HTTPS and some TCP connections.
Check HTTP headers:
curl -I https://example.com
Verbose output:
curl -v https://example.com
Test a TCP port:
curl -v telnet://example.com:443
traceroute and tracepath
Trace network path:
traceroute example.com
If traceroute is not installed:
tracepath example.com
Firewall
A firewall controls allowed and blocked traffic.
On many RHEL systems:
firewalld
Check firewall state:
sudo firewall-cmd --state
List active rules:
sudo firewall-cmd --list-all
List open ports:
sudo firewall-cmd --list-ports
Common network troubleshooting flow
When a service is not reachable:
1. Is the server up?
2. Does it have the correct IP address?
3. Is the route/default gateway correct?
4. Does DNS resolve correctly?
5. Is the service running?
6. Is the service listening on the expected port?
7. Is the firewall allowing the traffic?
8. Is there another firewall/load balancer/security device in the path?
First command set
hostnamectl
ip a
ip r
ip route get 192.0.2.10
cat /etc/resolv.conf
cat /etc/hosts
dig example.com
ping -c 4 example.com
ss -tulpn
sudo firewall-cmd --list-all
DNS troubleshooting
Check IP connectivity:
ping -c 4 192.0.2.10
Check DNS:
dig example.com
nslookup example.com
cat /etc/resolv.conf
cat /etc/hosts
If IP works but DNS does not, the issue may be DNS-related.
Port troubleshooting
Check service:
systemctl status SERVICE_NAME
Check listening port:
ss -tulpn | grep :PORT
Check firewall:
sudo firewall-cmd --list-all
Test connection:
curl -v telnet://example.com:PORT