usually, the DHCP is fine. but then its not. what to do?
I typically use a ubuntu distribution when trying stuff. and it works fine for most cases. it has an easy package manager and a lot of docmentation. plus, digitalocean and the other big hosting companys have done a pretty good job of making howtos available. sometimes though, i just need to set a static ip address and it seems unnecessarily complicated. so i made a post here to note the process since looking it up every time might get me eaten by an AI grue.
Ubuntu used Netplan for network configuration. It is trivial to configure Ubuntu to use a static IP by adding some yaml to /etc/netplan.
id the interface you want by running
ip a
then using your favorite editor (vim) add or edit 01-network-manager-all.yaml
something like this will do:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
put each directive on a separate line. im too lazy to figure out the formatting just now.
sudo netplan apply
will activate the settings
you can also just do it at the cli, but it wont survive a reboot: