Most Linux network problems are found with a handful of commands. Here they are, next to the Windows commands you already know.
Cheat sheet
| Task | Windows | Linux |
|---|---|---|
| IP addresses | ipconfig / Get-NetIPAddress |
ip a |
| Routes / gateway | route print |
ip route |
| Listening ports | netstat -ano / Get-NetTCPConnection |
ss -tulpn |
| Test a port | Test-NetConnection -Port |
nc -zv host port |
| DNS lookup | Resolve-DnsName |
dig, host |
| Ping | ping |
ping -c 4 |
| Trace route | tracert |
traceroute / tracepath |
| HTTP request | Invoke-WebRequest |
curl |
Addresses and routes
ip a # all interfaces and IPs
ip -4 a show eth0 # IPv4 on one interface
ip route # routing table; 'default via' is the gateway
ip link # interfaces up/down
Permanent network settings on Ubuntu live in Netplan files under /etc/netplan/. Edit, then sudo netplan try (it reverts automatically if you lose connection – very handy on remote servers).
Who is listening?
sudo ss -tulpn
-t TCP, -u UDP, -l listening, -p process, -n numeric. If a service listens on 127.0.0.1:8080 it’s reachable only from the server itself; 0.0.0.0:8080 or *:8080 means all interfaces.
Testing connections
ping -c 4 10.0.0.25
nc -zv 10.0.0.25 443 # TCP port open?
curl -I https://app.contoso.local # HTTP headers only
curl -s https://api.contoso.local/health # API response
curl -v https://app.contoso.local 2>&1 | grep -i -e expire -e subject # certificate details
traceroute 10.0.0.25 # where does it stop?
DNS
dig app01.contoso.local +short # just the answer
dig @10.0.0.10 app01.contoso.local # ask a specific DNS server
dig -x 10.0.0.25 +short # reverse lookup
cat /etc/resolv.conf # which DNS servers are used
resolvectl status # on systemd-resolved systems
/etc/hosts works like the Windows hosts file and is checked first.
Firewall with ufw (Ubuntu)
sudo ufw status verbose
sudo ufw allow 22/tcp # SSH – allow this BEFORE enabling!
sudo ufw allow from 10.0.5.0/24 to any port 9100 proto tcp
sudo ufw enable
sudo ufw delete allow 8080/tcp
Always allow SSH before running ufw enable on a remote server, or you’ll lock yourself out. Red Hat-family systems use firewall-cmd instead. In the cloud, security groups / NSGs filter traffic too – check both.
A “can’t connect” routine
dig name– does it resolve to the right IP?ping -c 2 ip– is the host reachable? (ICMP may be blocked – not conclusive)nc -zv ip port– is the port open from here?- On the server:
ss -tulpn– is the service listening, and on which address? - Firewalls:
ufw status, cloud security groups, network firewalls. curl -v– what does the application actually answer?
What’s next
Next: Bash scripting basics.
LinuxNetworkingFirewallTroubleshootingIntermediate