My setup: LXD cluster running on 3 cloud servers on Hetzner, with a private network between them.
Defining a bridge is not possible, so that automatic assignment of private IPs in the 10.0.0.0 range is not an option and OVN neither.
As a workaround, it is possible to use “Alias IPs”, up to 5 per server, and assign them to the containers. This works with the solution described here, with a routed network with parent interface the one assigned to the private network.
My goal is to have containers with a shared network and with connectivity to the Internet. So that I attached another network interface to the profile to be applied to the containers:
# lxc profile show myprofile
devices:
eth0:
nictype: bridged
parent: lxdbr0
type: nic
eth1:
nictype: routed
parent: enp7s0
type: nic
# lxc init images:ubuntu/22.04/default c1 --profile myprofile --target node01
# lxc config device override c1 eth1 ipv4.address=10.0.0.11
# lxc start c1
# lxc init images:ubuntu/22.04/default c2 --profile myprofile --target node02
# lxc config device override c2 eth1 ipv4.address=10.0.0.21
# lxc start c2
At this point I can ping the containers on their private addresses but I cannot access the internet from them.
# lxc exec c1 ip r
default via 169.254.0.1 dev eth1
default via 10.46.229.1 dev eth0 proto dhcp src 10.46.229.32 metric 100
10.46.229.0/24 dev eth0 proto kernel scope link src 10.46.229.32 metric 100
10.46.229.1 dev eth0 proto dhcp scope link src 10.46.229.32 metric 100
169.254.0.1 dev eth1 scope link
If I add an entry for eth1
in the Netplan file, and do a netplan apply
also access to the internet is possible, however on container restart I need to manually run a netplan apply.
This is the “correct” routing table:
# lxc exec c1 ip r
default via 10.46.229.1 dev eth0 proto dhcp src 10.46.229.32 metric 100
10.46.229.0/24 dev eth0 proto kernel scope link src 10.46.229.32 metric 100
10.46.229.1 dev eth0 proto dhcp scope link src 10.46.229.32 metric 100
So the question is how I can obtain this routing table without manually running netplan apply? Or is there a way to avoid using 2 network interfaces?