Module 12 · Networking
Networking sounds complicated. It really isn't. Underneath, it's just computers sending little messages to each other. This module shows you how to check if your computer is online, how to find what's wrong when it isn't, and how to log into another computer over the internet — all from the terminal.
By the end of this module, you will:
- Check IP address, gateway, and DNS configuration from the terminal
- Diagnose network connectivity problems using a five-step sequence
- Connect to a remote computer using SSH
- Transfer files between computers using scp and rsync
- Configure the ufw firewall to allow or block ports
- Identify which services are listening on which ports with ss
Coming from Windows? Here's the swap
On Windows you opened Settings → Network & Internet, or you typed ipconfig in the Command Prompt. On Linux you type ip addr and ip route instead. The ideas are the same — your IP address, your router (also called a gateway), and DNS — just a different way to look at them.
Every computer on a network has an IP address. Think of it like the address of your house. When you post a letter, you write your address on the envelope so the reply can find its way back. Your computer does the same thing — it writes its IP address on every message it sends, so the answer knows where to go.
On Windows you typed ipconfig to see your address. On Linux you type ip addr. The result looks a bit different but it tells you the same thing. Look for the line that says inet — that's your IP address. Ignore the lo bit at the top; that's just your computer talking to itself, which is normal.
ip addr (what's my address?), ping -c 4 google.com (can I reach the internet?), ip route (is my router set up right?). Run these three whenever the network isn't working — the one that fails tells you what's broken.Imagine you need to check something on a computer in another building, another city, or another country. You don't want to walk over and sit at it. SSH (it stands for Secure Shell) lets you open a terminal on that far-away computer, as if you were sitting right in front of it. It's a private encrypted tunnel — nobody else on the internet can see what you type or what comes back.
On Windows you might have used a program called PuTTY to do this. On Linux and macOS, SSH is already there — you just type it. The basic command is ssh username@serveraddress. The very first time you connect to a new computer, it shows you a "fingerprint" and asks you to confirm — that's a safety check, to make sure you're connecting to the right machine. Type yes.
SSH keys — getting in without a password. Typing your password every time you connect gets boring fast. You can set up an SSH key — think of it as a digital key-card that your laptop shows the server automatically. The server recognises your key-card and lets you in without asking for a password. It's also much safer than a password. We'll cover how to set this up in Module 13.
ssh username@ipaddress. The first time you connect, the "are you sure?" question shows up — type yes. To come back to your own computer, type exit.When the network stops working, most people restart the computer and cross their fingers. That fixes it maybe 30% of the time. The other 70% of the time there's a real reason — and finding it only takes about five minutes if you ask the right questions in the right order.
Network problems stack up like a ladder. Start at the bottom and work your way up. First, does your computer have an IP address at all? Then, can it reach your router? Then, can it reach the wider internet? Then, does DNS work? (DNS is the thing that turns a name like "google.com" into the number that computers actually use.) Each step narrows down where exactly the problem is.
Checking which doors are open. A port is like a door on your computer. Different programs use different doors. Web servers use door 80 (the normal one) and 443 (the secure one). SSH uses door 22. If a door is closed, that program can't be reached. Type ss -tlnp to see which doors are open on your computer right now — that tells you straight away whether a program is actually listening for visitors.
ss -tlnp to see which programs on your own computer are accepting visitors. Go top to bottom — the first step that fails is the one to fix.Sometimes you need to send a file from your laptop to a server, or pull one down from a server to your laptop. Linux gives you two tools for this that Windows doesn't have built in: scp (Secure Copy — copy and paste, but over the network) and rsync (a smarter copy that only sends the bits that have actually changed).
Think of scp like sending an email attachment — the whole file goes every time. Think of rsync like Google Drive syncing — it only uploads what's new or changed since last time. For big files, or backups you run every night, rsync saves a huge amount of time.
scp when you just need to send one file (like an email attachment). Use rsync when you're backing up or syncing a whole folder — it only sends what's changed. Both go over SSH, so you'll need the same login you'd use to SSH in.Every computer on a network has dozens of "doors" called ports. Each port is where a different program waits — port 22 is SSH, port 80 is web pages (HTTP), port 443 is secure web pages (HTTPS), port 3306 is a database called MySQL. A firewall is the bouncer at each door, deciding who's allowed in.
On Windows you've used Windows Defender Firewall, with its panel of tick-boxes. On Linux the standard tool is ufw — short for "Uncomplicated Firewall". The name is honest: it gives you a friendly front for Linux's deeper firewall, so you don't have to write tricky low-level rules.
The big mistake to avoid: never turn ufw on for a remote server before allowing SSH. ufw blocks every incoming connection by default — and that includes the SSH connection you used to log in. You'll be kicked out and locked out. The only fix is to plug in a keyboard and screen directly, which you probably can't do for a cloud server.
sudo ufw allow ssh, sudo ufw enable, sudo ufw status. On a remote machine, always allow SSH first — then turn the firewall on.Before you open a door in your firewall, you should know what's on the other side of it. The question "what programs are listening on which doors right now?" is answered by ss. (It's the modern replacement for an older command called netstat.) The first time you run it can be a real eye-opener — sometimes a bit alarming.
Look closely at the Local Address column. 0.0.0.0:22 means "listening on every network, on port 22" — anyone on the network can try to connect. 127.0.0.1:631 means "listening only on this computer itself" — safe, nobody outside can reach it. If you spot something on 0.0.0.0 that you didn't expect, you should be able to explain exactly why it's there.
sudo ss -tulnp is your one-line answer to "what on my computer is reachable from outside?" Run it whenever you install a new server-style program — lots of them start up on their own, and you want to know what's listening.