setting a static ip on ubuntu, netplan confuses me

Want my home server to keep the same address. Older guides talk about an interfaces file that doesn't exist on my install, and the netplan yaml I wrote throws an error. Ubuntu 22.04.
1

Leave A Reply

Log in to post an answer.

1 Answer

vikram_helpdesk
the file lives in /etc/netplan/, something like 01-netcfg.yaml or 50-cloud-init.yaml. run ip a first to get the real interface name, then it looks like this: network: version: 2 ethernets: enp3s0: dhcp4: no addresses: [192.168.1.50/24] routes: - to: default via: 192.168.1.1 nameservers: addresses: [1.1.1.1, 8.8.8.8] apply it with sudo netplan try rather than apply. if you lose the connection it rolls back on its own after two minutes, which is a lifesaver over ssh. what trips everyone up is indentation. spaces only, never tabs, and every level has to line up exactly or it fails with a vague error. also gateway4 is the old way of writing the gateway and newer versions complain about it, so use the routes block like above.