I’m trying to get lxd containers to connect to different vlans.
Initially I tried setting the vlan id on the container nic lxc config device override test eth0 vlan=3 but I got Error: Failed to start device "eth0": VLAN filtering is not enabled in parent bridge "br0" so I enabled vlan filtering in the bridge config VLANFiltering=yes this got rid of the error but it doesn’t actually seem to work.
Could someone please tell me what I’m doing wrong/point me in the right direction, many thanks!
Apologies perhaps my question is poorly worded,
To be clear vlan_filtering (initially) wan’t enabled which is why I was getting the error so I just enabled that so LXD is actually detecting it correctly. However the container/nic isn’t able to communicate with the tagged network and I’ve already checked the network on VLAN3 on a physical device to make sure it works (and it does) My question is how do I connect a LXD container to a VLAN is there a step/additional configuration I’m missing?
I was following this article but I’m using systemd-networkd instead of manually setting everything up using ip.
Firewall’s completely off.
I will report back with the tcpdump results.
So there’s nothing wrong with my config then, right? I mean theoretically this should (have) just work(ed)?
tcpdump revealed the vlan wasn’t being forwarded to the underlying interface, after some digging around, turns out it was a misconfiguration issue. According to man 5 systemd.network you must configure allowed VLAN id(s) under [BridgeVLAN] for whatever the slave bridge interface is e.g. bond, physical interface or whatever else.
Example 6. Bridge port with VLAN forwarding
# /etc/systemd/network/25-bridge-slave-interface-1.network
[Match]
Name=enp2s0
[Network]
Bridge=bridge0
[BridgeVLAN]
VLAN=1-32
PVID=42
EgressUntagged=42
[BridgeVLAN]
VLAN=100-200
[BridgeVLAN]
EgressUntagged=300-400
This overrides the configuration specified in the previous example for the interface "enp2s0", and enables VLAN on that bridge
port. VLAN IDs 1-32, 42, 100-400 will be allowed. Packets tagged with VLAN IDs 42, 300-400 will be untagged when they leave on
this interface. Untagged packets which arrive on this interface will be assigned VLAN ID 42.
So here’s a simple and quick config for setting up a bond and a vlan aware bridge on top.
I Should Note that having fixed one problem now I’m facing another, in that, once VLANFiltering is enabled the bridge doesn’t automatically acquire a dhcp lease unless/until something is “plugged into” it for example if I have LXD.service disabled so that I can start it manually after boot the host system doesn’t have a routable IP until I start lxd which “plugs in” its interfaces into the bridge and suddenly the bridge starts working and gets an IP from the DHCP server.
I don’t know if this is a bug, But I’ve done quite a bit of digging around and this doesn’t seem to be documented/intended behaviour
PS, the following article from Red Hat is a pretty good read for anyone interested.
negative, bridge is enabled and comes up on boot it just refuses to get a dhcp lease on its own (until something gets plugged in) note that this behaviour is only present/observed when VLANFiltering is enabled