Briding LXD Containers to VLAN – A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about Briding LXD Containers to VLAN was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, networking, vlan, bridge, lxd.
I was trying to do something that is supposed to be pretty easy but for some reason it not work.
I want to bridge two LXD containers to the same VLAN.
To do this I create the VLAN interface over the physical one and then I assign this to the same virtual bridge used by the LXD container.
This is the script that I use for creating the interface and the bridge
#!/usr/bin/env bash
sudo ip link add link $1 name $1.$2 type vlan id $2
sudo ifconfig $1.$2 $3 # this is useless I think
sudo ip link add vnet$2 type bridge
sudo ip link set vnet$2 up
sudo ip link set $1.$2 up
sudo ip link set dev $1.$2 master vnet$2
read -n 1 -s -r -p "Press any key to destroy..."
sudo ip link del vnet$2
sudo ip link del $1.$2
And this is the profile used by the containers
lxc profile show vlan
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: vnet2
type: nic
root:
path: /
pool: default
type: disk
name: vlan
used_by:
- /1.0/containers/lxd1
I assing two ip address in the same subnet for the two containers, but if I try to ping, using tcpdump, I can see that one of the two host is receives the ARP requests and send the replies, while the other one does not receive the replies.
Any suggestion?
This picture represents my testbed
+-------------------------+ +-------------------------+
| Host1 | | Host2 |
|-------------------------| |-------------------------|
| | | |
| +---------+ +----------+ +----------+ +----------+ |
| | ens2.2 +-------> |ens2 <---+ ens2 | <----+ ens2.2 | |
| +----^----+ +----------+ +----------+ +------^---+ |
| | | | | |
| +----+----+ | | +------+---+ |
| | vnet2 | | | | vnet2 | |
| +---^-----+ | | +------^---+ |
| | | | | |
| | | | | |
| +-----+-------------+ | | +------------+-----+ |
| | LXD Container | | | | LXD Container | |
| +-------------------+ | | +------------------+ |
| | | |
+-------------------------+ +-------------------------+
Actually the LXD and Bridge configuration was Ok, for some reason the switch was not able to manage the VLANs