Skip to content
6 min read·Lesson 9 of 10

Networking in Linux

Check IP configuration, test connectivity, manage firewall rules, and use essential networking tools on Linux.

Linux networking skills are essential for cloud certification exams and real-world server administration. From checking IP addresses to debugging connectivity failures, these commands and concepts appear constantly in cloud environments.

Viewing Network Interfaces

The ip command is the modern tool for network configuration (replaces ifconfig):

ip addr show              # show all interfaces and IP addresses
ip addr show eth0         # show specific interface
ip link show              # show link-layer status (up/down)
ip route show             # routing table
ip route get 8.8.8.8      # which interface/gateway reaches this IP

Key interfaces you'll see:

  • eth0 or ens3 — primary Ethernet/network interface
  • lo — loopback (127.0.0.1) — used for internal communication
  • docker0 — Docker bridge network

Testing Connectivity

ping -c 4 google.com         # send 4 ICMP packets
ping -c 4 10.0.0.1           # test LAN connectivity
traceroute google.com        # trace route to destination
mtr google.com               # continuous traceroute (install mtr)
curl -I https://example.com  # HTTP headers only
curl -v https://api.example.com  # verbose HTTP request

DNS Tools

dig google.com            # full DNS query response
dig google.com A          # A record (IPv4 address)
dig google.com MX         # mail server records
dig @8.8.8.8 google.com   # query using specific DNS server
nslookup google.com       # simple DNS lookup
host google.com           # quick DNS lookup

Local DNS configuration

cat /etc/resolv.conf      # configured DNS servers
cat /etc/hosts            # local hostname overrides

# Add a local override
echo "192.168.1.100  myapp.local" >> /etc/hosts

Open Ports and Listening Services

ss -tulnp           # show TCP/UDP listening ports with process names
netstat -tulnp      # older alternative (install net-tools if missing)
lsof -i :80         # what process is using port 80?
lsof -i :443

Output columns for ss -tulnp: Netid (tcp/udp), State, Local Address:Port, Peer Address:Port, Process.

Firewall with ufw

ufw (Uncomplicated Firewall) is a user-friendly front end for iptables, available on Ubuntu/Debian:

sudo ufw status               # show firewall status and rules
sudo ufw enable               # activate the firewall
sudo ufw disable              # disable the firewall
sudo ufw allow 22             # allow SSH
sudo ufw allow 80/tcp         # allow HTTP
sudo ufw allow 443/tcp        # allow HTTPS
sudo ufw deny 3306            # block MySQL port
sudo ufw allow from 10.0.0.0/24  # allow from subnet
sudo ufw delete allow 80      # remove a rule

Network Configuration Files

  • /etc/network/interfaces — Debian legacy network config
  • /etc/netplan/*.yaml — Ubuntu 18.04+ network config
  • /etc/NetworkManager/ — NetworkManager configs (desktop/RHEL)
  • /etc/hosts — local hostname resolution
  • /etc/resolv.conf — DNS server addresses
  • /etc/hostname — machine hostname

SSH — Connecting to Remote Servers

ssh user@192.168.1.10               # connect by IP
ssh -i ~/.ssh/my-key.pem ec2-user@34.x.x.x  # AWS EC2 key-based auth
ssh -p 2222 user@host               # non-standard port
scp file.txt user@host:/tmp/        # copy file to remote
rsync -avz ./app/ user@host:/opt/app/  # sync directory

SSH key setup:

ssh-keygen -t ed25519 -C "your@email.com"   # generate key pair
ssh-copy-id user@host                        # copy public key to server
cat ~/.ssh/authorized_keys                   # view authorised keys

In the final lesson, you'll learn about user and group management — how Linux controls who can access what resources.

Key Takeaways

  • ip addr show replaces the older ifconfig for viewing network interfaces.
  • ping, curl, dig, and traceroute are your core connectivity troubleshooting tools.
  • ss -tulnp (or netstat -tulnp) shows what ports are open and listening.
  • iptables and nftables control packet filtering; ufw is a simpler frontend.
  • /etc/hosts and /etc/resolv.conf control local DNS resolution.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →