Cloudinit, Proxmox, Ubuntu & Static Routes

462 Views Asked by At

I'm creating instances on a development proxmox setup. To configure the networking inside the instance I am using Cloudinit and snippets. On Ubuntu distributions it appears I need to set up a static route to the gateway but, I can't figure out a way to do this that persists across reboots.

When the instance is configured, My cloud-init drive gets the correct IP and gateway and this is configured inside the instance but I have to manually specify a route using

IP route add gateway_ip dev eth0
IP route add default via gateway_ip

If I reboot the instance the routes are lost and I am back to square one. How can I ensure when an instance is configured the routes are also there. I thought about creating an OS template with the routes already configured but this does not work, they are wiped out on reboot too.

Can anyone suggest a way I can do this?

1

There are 1 best solutions below

0
On

I got around this by creating a new service that runs after the networking.service then running a bash script on startup to add the default routes. It's probably not the best way to achieve what I want but it gets me to where I need to be.