Fix
IP address and routes are gone after a reboot
Settings made with ip addr and ip route live only in the running kernel. Write them to the system's network configuration so they are applied at boot.
Likely causes
- The address and routes were set with
ipcommands only, never written to a file. - They were written, but to a file this system does not read (ifupdown, netplan and NetworkManager each have their own), or with a mistake in it.
Diagnose
Run these in order. The output is what each printed on a lab's real Linux machines.
-
leo:~# ip -br -4 addr - After the restart only
lohas an address: the card's is gone, and its routes went with it.lo UNKNOWN 127.0.0.1/8
Fix
-
/etc/network/interfaces - On Alpine and Debian (ifupdown), the card's address, mask and gateway go in
/etc/network/interfaces.auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.0.1.10 netmask 255.255.255.0 gateway 10.0.1.2 -
leo:~# ifup -v eth0 -
ifupreads the file and runs the sameipcommands, as the machine does at every start.run-parts /etc/network/if-pre-up.d ip addr add 10.0.1.10/24 dev eth0 label eth0 ip link set eth0 up ip route add default via 10.0.1.2 dev eth0 run-parts /etc/network/if-up.d
-
leo:~# curl -sS -m 5 http://zoe.lab/ - And the page loads by name.
Zoe's studio is open until six
Break it and fix it yourself
Each lab is a small network of real Linux machines in your browser, where this fault happens.
- Linux networking: bring a blank machine online by hand : its challenge "Fine until the restart" set the fault for you to find and fix.