| Command | Use |
|---|---|
ip addr | Show network interfaces and addresses |
ping host | Test whether a host responds |
ssh user@host | Log in securely to another machine |
scp file user@host: | Copy a file over SSH |
ss -tulpn | List listening ports |
Firewalls
Desktop and server distributions include firewall front ends such as ufw or firewalld. Allow only the services you need, for example SSH on a server.
Routes, gateways and name lookups
An address on an interface is only part of the picture. To reach another machine, Linux also needs a route. ip route shows the kernel routing table. The line starting with default via is your usual path off the local network. On a typical home or office network in Australia, that will often be your router. If you have both Ethernet and Wi-Fi, ip route get 203.0.113.10 is handy: it shows which interface, source address and gateway Linux would choose for that destination.
Name lookups are separate from raw connectivity. getent hosts hostname asks the system resolver for an address using the same rules that most programs use. If a remote IP responds but getent fails, the network path is probably fine and the problem is DNS or local name configuration.
On many current distributions, resolvectl status shows which DNS servers and search domains are in use. On others, /etc/resolv.conf still shows the active resolver settings. /etc/hosts is also worth knowing about. It lets you pin a small set of names to fixed addresses, which can be useful for test machines or small embedded devices. Keep entries simple and comment them clearly, otherwise old overrides are easy to forget. The order of sources, such as files before dns, is usually set in /etc/nsswitch.conf, which is why an /etc/hosts entry can override DNS. For a refresher on reading command output, see Command line. If a route or resolver change has odd side effects, the checks on Troubleshooting help narrow it down.
A quick troubleshooting sequence
When a connection fails, work from nearest to furthest. It avoids guesswork and stops you changing three things at once.
- Check link state with
ip link. An interface that isUPbut notLOWER_UPoften means no carrier: a cable issue, a switch port problem or Wi-Fi that is not associated. - Check addressing with
ip -br addr. The brief format is easier to scan than fullip addr, especially on a system with several virtual interfaces. - Check the default gateway from
ip route, then test it directly withping -c 3 <gateway-ip>. If the gateway does not respond, there is little point testing anything beyond it. - Check a remote address by IP first, for example
ping -c 3 <remote-ip>. If that works, test the name withgetent hosts hostname. This separates routing problems from name resolution problems. - If the host is reachable but an application still fails, test the service rather than the machine.
nc -vz host 22checks whether a TCP port can be opened, andssh -v user@hostgives useful connection details for SSH. - On the local machine,
ss -tn state establishedshows current TCP sessions and can confirm whether a connection was made and then dropped. - If packets seem to disappear somewhere beyond the first hop,
tracepath hostcan show where the path stops. It is often installed by default whentracerouteis not.
Write down the first step that fails. That single note often tells you whether to look at cabling, Wi-Fi, DNS, a route or the service itself. It also makes later fixes easier to explain to someone else.
SSH keys and safer remote access
If you log into the same machine often, SSH keys are more practical than typing a password every time. Generate a key pair with ssh-keygen -t ed25519. That creates a private key, which stays on your machine, and a public key, which you install on the server. The easiest method is usually ssh-copy-id user@host. If that tool is not available, append the contents of your .pub file to ~/.ssh/authorized_keys on the remote side.
A few points matter in practice:
- Pay attention to the host key on the first connection. SSH uses it to prove you are talking to the same machine next time. If the fingerprint changes unexpectedly, stop and confirm why before accepting it.
- Permissions matter. OpenSSH normally expects
~/.sshto be700andauthorized_keysto be600; loose permissions can cause key login to be ignored. This ties in with Users & permissions. - Put repeated settings in
~/.ssh/configto save typing. For example:
Host vr3
HostName 192.168.0.50
User user
After that, ssh vr3 and scp notes.txt vr3: use the saved details.
- Use a passphrase on keys that leave your desk, especially on laptops and small devices. For unattended scripts, create a separate key with only the access that job needs.
SSH is simple to start with, but it is also part of your security boundary. Review broader hardening choices on Security, especially if you expose SSH beyond a trusted local network.
