I am using the following cloud-init config to create two interfaces, eth0 which connects to incusbr0 so I can update my packages on an instance from the internet, and eth2 to test my stuff on a private LAN.
config:
user.vendor-data: |
#cloud-config
package_upgrade: true
packages:
- build-essential
user.network-config: |
network:
version: 2
ethernets:
eth0:
dhcp4: yes
eth2:
dhcp4: yes
description: my profile
devices:
eth0:
name: eth0
network: incusbr0
type: nic
root:
path: /
pool: default
type: disk
eth2:
name: eth2
network: mynet
type: nic
name: my-profile
used_by:
I create my private LAN using the following for my instances.
lxc network create mynet ipv4.address=192.168.1.1/24 ipv4.dhcp=true
As you can see, I get two default gateways from the DHCP server with two default static routes with the same metrics.
$ ip route s
default via 10.23.44.1 dev eth0 proto dhcp src 10.23.44.27 metric 100
default via 192.168.1.1 dev eth2 proto dhcp src 192.168.1.173 metric 100
10.23.44.0/24 dev eth0 proto kernel scope link src 10.23.44.27
10.23.44.1 dev eth0 proto dhcp scope link src 10.23.44.27 metric 100
192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.173
192.168.1.1 dev eth2 proto dhcp scope link src 192.168.1.173 metric 100
Although I get two default gateways from the DHCP server with two default static routes with the same metrics which tries to use them both, and fails, the bigger problem is that the packages I have listed in my packages: section of the cloud-init will never get called again by the time I remove one of the static routes, and so I’ve missed the chance to have cloud-init load these packages since they failed with two gateways.
I’d like to be able to turn one off when using the other, but this is proving difficult.
Anyone have thoughts on how to fix this?
Update:
I added the following runcmd which I thought got executed after most everything was done and didn’t seem to work. I log into the instance, and the route is still listed in the routing table.
runcmd:
- ip route delete default 192.168.1.1/24