I'm running an Ubuntu 16.04 instance with multiple interfaces. I'm looking to configure some routes on the 2nd interface. While I can do this manually, that does not persist with a reboot.
Most methods suggest defining routes with the interface in /etc/network/interfaces, which translates to /etc/network/interfaces.d/50-cloud-init.cfg based on a call from the interfaces file.
What has me confused is that I am not sure where or how the 2nd interface is even defined.
The 2 interfaces are ens4 & ens5. Only ens4 is defined with
iface ens4 inet dhcp. I would expect to see something similar for ens5, but do not.
Running ifconfig shows ens5 as running. Also,
ip link show shows it.
It appears that I can add ens5 to /etc/network/interfaces without anything breaking. If I do that it seems some other things happen as well. For example, an "ifstate.ens5" file now appears in /run/network. Also, ifdown / ifup work on the interface.
However, even adding
post-up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1 does not result in the route being created on boot... But if I do an ifdown and then an ifup, the route is added as one would expect.
My additional research is that ens5 is defined via the cloud-init package from the Google GCE datasource, which is all well and good, but does not answer why only ens4 is in the 50-cloud-init.cfg file.
So where is ens5 defined and how can I add a static route for ens5?