My hosting provider unfortunately requires the use of static routes for network configuration (gateway is on a different subnet than the host IP). For that purpose I added the following lines to the network configuration file (/etc/network/interfaces):
post-up route add -host 172.31.1.1 dev ens3 && route add default gw 172.31.1.1
To unlock an encrypted root drive with cryptsetup I install dropbear, so that I can SSH into a busybox to provide the encryption password. I haven't found a way, however, to add static routes in the initramfs configuration file. Does anyone have an idea how this could be accomplished? The server in question is running Ubuntu 16.04.
Best Answer
Create a little helper script that configures your static routing. According to the initramfs-tools manual scripts in /etc/initramfs-tools/scripts/nfs-premount are executed after the network interface has been enabled, but you may need to place the script in another sub directory.
You'll need to use
ip route
syntax because AFAIK the olderroute
command won't be available:and ensure that the script is executable (
chmod 755 /etc/initramfs-tools/scripts/nfs-premount/static-routes
) before runningupdate-initramfs
.