Seven posts of the networking series went into what an IP address is — how it gets wrapped in envelopes, how it finds its way across a switch, how you carve a network into subnets, how a whole office hides behind one public address. All of it, so far, abstract. This is the post where you finally type one, on a machine with no graphical anything, and discover that Linux has opinions about who is allowed to set it.
The last post left us with a box that keeps its own services alive. It is not much use if it cannot talk to anything, so: addresses, routes, DNS, and the small matter of which of the three competing config systems is actually in charge of your machine.
First: it is not ifconfig any more
If you have ever googled a Linux networking question you have been told to run ifconfig. On a modern distro it will very likely not be there at all. The old net-tools package — ifconfig, route, netstat, arp — has been deprecated for well over a decade, superseded by ip and ss from iproute2. Half the internet has not caught up. Learn the new spellings and the old tutorials become readable anyway:
| What you want | The old way | The way that works now |
|---|---|---|
| Show addresses | ifconfig | ip addr (ip a) |
| Show the routing table | route -n | ip route (ip r) |
| Show listening sockets | netstat -tulpn | ss -tulpn |
| Show the ARP table | arp -a | ip neigh |
| Bring an interface up | ifconfig eth0 up | ip link set eth0 up |
Reading the current state
Four commands will tell you almost everything about a machine’s network life. Here is the whole tour:
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN
inet 127.0.0.1/8 scope host lo
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
inet 192.168.1.50/24 brd 192.168.1.255 scope global enp3s0
$ ip route
default via 192.168.1.1 dev enp3s0 proto static
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.50
Everything the series has been building toward is sitting in those eight lines. 192.168.1.50/24 — a private address and a prefix, exactly as promised. default via 192.168.1.1 — that is the default gateway, the “if you do not know where it goes, send it here” rule; the router that will do the NAT on the way out. The second route says “anything in 192.168.1.0/24 is on my own wire, no router needed” — the subnet, doing its actual job of deciding local versus not-local.
lo, the loopback, is the machine talking to itself on 127.0.0.1. It is always there, it is not a real card, and a surprising number of services listen only on it.
| Question | Command |
|---|---|
| What addresses do I have? | ip a |
| Where does traffic go? | ip route |
| Who is on my local wire? | ip neigh — the ARP table, MAC to IP |
| What is listening, and which process owns it? | ss -tulpn |
| Is the cable in? | ip link — look for LOWER_UP |
ip neigh deserves a moment, because it is the encapsulation post made visible: the machine’s cache of “this IP lives at this MAC address”, built by asking the local network and remembering the answer. It is how a frame knows which door on the street to knock at.
Why is it called enp3s0?
Older systems named cards eth0, eth1 and so on, handed out in whatever order the kernel happened to find them. That order was not guaranteed between boots — so a machine with two network cards could genuinely swap their names after a reboot, and your firewall rules would now be protecting the wrong interface. Not ideal.
Modern distros use predictable interface names derived from where the card physically sits: enp3s0 is ethernet, PCI bus 3, slot 0. Uglier to type, but it names the same card the same way every time, forever. Wireless gets wl instead of en, which is why you will meet wlp2s0 on laptops.
Setting an address: now, or permanently
This is the same split we met in the systemd post between start and enable, and it catches people just as often. You can set an address that applies right now:
$ sudo ip addr add 192.168.1.50/24 dev enp3s0
$ sudo ip link set enp3s0 up
$ sudo ip route add default via 192.168.1.1
Now, but not forever
Everything set with ip lives in memory only. Reboot and it is gone without trace. That is a genuine feature when you are rescuing a box and want a temporary address you know will not stick — and a genuine trap when you spend an afternoon getting a server working, reboot it, and watch the network vanish. If it must survive a reboot, it has to go in a config file, which is where the next section’s mess begins.
Who actually owns your network config?
Here is the honestly annoying part of Linux networking, and the thing worth knowing before you edit anything: there are three systems that might be in charge, and editing the wrong one changes precisely nothing while you slowly lose your mind.
| System | Where you find it | Config lives in |
|---|---|---|
| netplan | Ubuntu server (a front-end, not a network stack) | /etc/netplan/*.yaml |
| NetworkManager | Desktops, and RHEL / Alma / Fedora servers | nmcli, /etc/NetworkManager/ |
| systemd-networkd | Minimal and container-ish servers | /etc/systemd/network/*.network |
Netplan is the confusing one because it is not actually a network manager — it is a translator. You write YAML, and netplan renders it into config for whichever back-end is installed, either systemd-networkd or NetworkManager. That is what the renderer: line selects. So on Ubuntu you can be using NetworkManager and netplan at the same time, which explains a great many contradictory search results.
Find out who is driving before you touch anything:
$ systemctl is-active NetworkManager systemd-networkd
$ ls /etc/netplan/
$ netplan status # if netplan is present at all
A netplan static address, in full
Since Ubuntu is where most people meet this, here is a complete working file — a static address, a default route and two resolvers:
# /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: false
addresses:
- 192.168.1.50/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [1.1.1.1, 9.9.9.9]
Two details that trip people up. First, if you have found an older guide using gateway4: 192.168.1.1 — that key is deprecated and will warn or fail on current releases; the routes: block above is the replacement. Second, it is YAML, so indentation is two spaces and tabs are an error, which netplan will tell you about in the least helpful way available.
Tip
Netplan files are read in filename order and merged, so 50-cloud-init.yaml beats 01-netcfg.yaml — on a cloud image, your carefully written file may be quietly overridden by one cloud-init dropped there. Check what is actually in /etc/netplan/ before blaming yourself. Netplan will also nag that the file is world-readable; sudo chmod 600 /etc/netplan/*.yaml settles it.
DNS, and why resolv.conf lies to you
Everyone knows DNS servers live in /etc/resolv.conf. Everyone then edits it, reboots, and finds their change gone. On most modern systems that file is a symlink to something generated by systemd-resolved, and hand-edits are overwritten on the next boot or network change. Look before you edit:
$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 ... /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
$ resolvectl status # the real answer: which servers, per interface
$ resolvectl query example.com
If it is a symlink, set your resolvers where the owner expects them — the nameservers: block in netplan, or nmcli — not in the generated file. And that 127.0.0.53 you will see listed is not a mistake: it is the local stub resolver, forwarding on to the real servers.
Why ping and dig can disagree
A genuinely useful diagnostic quirk. ping resolves names through the system’s full name-service stack, which consults /etc/hosts first (the order is set in /etc/nsswitch.conf, typically hosts: files dns). dig ignores all of that and talks straight to a DNS server. So if ping myserver works but dig myserver returns nothing, the name is in /etc/hosts and not in DNS at all — and the day that host file goes missing, everything breaks mysteriously. If dig works and ping does not, suspect the resolver config rather than the DNS server.
Testing in layers
When something cannot reach something else, resist the urge to start at the top with “the website is down”. Walk up from the wire, and the fault tells you where it is by which rung fails first:
flowchart TD A["Is the link up? (ip link, look for LOWER_UP)"] --> B["Do I have an address? (ip a)"] B --> C["Can I reach my gateway? (ping 192.168.1.1)"] C --> D["Can I reach the outside by IP? (ping 1.1.1.1)"] D --> E["Can I resolve a name? (dig example.com)"] E --> F["Can I reach the service? (curl, ss)"]
Each rung tells you something specific. No link: cable, port, or the switch. Link but no address: DHCP, or a config that never applied. Address but no gateway: wrong subnet or wrong gateway. Gateway but no 1.1.1.1: routing or the firewall upstream. IP works but names do not: it is DNS, which it very often is. Names resolve but the service will not answer: you have arrived at the actual application, and the network has been exonerated.
Changing the network on a machine you are SSHed into
The recurring theme of this blog, in its Linux costume: apply a bad network change remotely and you cut the branch you are sitting on, instantly and completely. Netplan has a proper safety net for exactly this — sudo netplan try applies the config, waits 120 seconds for you to confirm, and automatically rolls back if you do not. If the change kills your session, you simply cannot confirm, and the box quietly restores itself. It is the direct cousin of reload in 10 from the Cisco cheatsheet. NetworkManager has no equivalent, so there you want console access or a scheduled reboot as your own rollback.
The one-sentence version
Use ip and ss rather than the deprecated ifconfig and netstat; ip a and ip route show you the address and the default gateway the networking series has been describing all along; anything set with ip dies at reboot, so persistent config goes to netplan, NetworkManager or systemd-networkd — and your first job is working out which of those three is actually in charge; DNS lives wherever resolv.conf‘s owner says it does; and you debug by walking up from the link, not down from the application. The commands are all in the Linux Networking Cheatsheet.
The box can now talk. The obvious next question is what it should be allowed to say, and to whom — which means firewalls. Next time: nftables, ufw and firewalld, and deciding what gets through the door.
