Network routes being reset after being modified

I’ve been following this guide to set up a VPC gateway:

My droplets are running Ubuntu 20.04

I’m using the runcmd section of userdata to modify my droplet’s routing table on boot. specifically, I’m changing the default gateway to point at another droplet. The commands are as follows:

  - ip route add via <OLD_GATEWAY> dev eth0
  - route delete default gw <OLD_GATEWAY> eth0
  - route add default gw <NEW_GATEWAY> eth1

These changes are visible if I connect to the droplet immediately after boot, as expected. However, after a few minutes the changes are overwritten and the routing table shows that the default gateway has returned to the original value.

I’m aware that these changes will not persist between boots, but it seems that they’re not sticking for more than a few minutes after first boot.

Why might this happen?

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer