[lxc-devel] Putting a VLAN on an LXD LXC container config - help

Gilbert Standen gilstanden at hotmail.com
Sat Sep 24 17:25:06 UTC 2016


So far I have come up with a workaround - again not very elegant - but at least it starts up the container so that it gets a DHCP IP address from my tagged VLAN 10.  I just use this little script to start it up - instead of using "lxc start lxdora7a" I use my script "lxdora7a.start" which contains this:


lxc start lxdora7a
sudo ovs-vsctl set port lxdora7a tag=10
sleep 2
lxc list

which reliably starts up the container and gets it an IP address.

What I'm looking for is a way to tag the created port "lxdora7a" within the config file so that I dont' have to start the containers with these scripts.

devices:
eth0:
host_name: lxdora7a <-- need to tell this to have "TAG=10" somehow...or maybe another parameter is added to this stanza?
name: eth0
nictype: bridged
parent: sw1
type: nic


________________________________
From: Gilbert Standen <gilstanden at hotmail.com>
Sent: Friday, September 23, 2016 6:58:28 PM
To: lxc-devel at lists.linuxcontainers.org
Subject: Putting a VLAN on an LXD LXC container config - help


help

oracle at g70:~ lxc config show lxdora7a

name: lxdora7a
profiles:
- default
config:
volatile.base_image: ad1d975af5bee4ef947ecca36084dbe2934277ed62e6a02c1fa60f1c902d2280
volatile.eth0.hwaddr: 00:16:3e:da:03:3e
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":231072,"Nsid":0,"Maprange":65536}]'
devices:
eth0:
host_name: lxdora7a
name: eth0
nictype: bridged
parent: sw1
type: nic
root:
path: /
type: disk
ephemeral: false

oracle at g70:~$

How do I put a VLAN TAG=10 on the above so that the lxdora7a port on my sw1 switch gets created with a TAG=10?


I could not find a reference for how to add VLAN tagging in the lxc config file above, but I was able to manually put the VLAN tag on the port that the LXD container automatically creates when it boots using the following command after it had already booted.  At that point, eth0 is still unconfigured even though onboot is set to YES in the ifcfg-eth0 because the VLAN 10 is not passing the traffic from the LXD container lxdora7a because of the VLAN'g.


So I ran this command to put a VLAN 10 on the port after the lxdora7a container had already booted:


sudo ovs-vsctl set port lxdora7a tag=10


Then I logged into the container using:


lxc exec lxdora7a /bin/sh


command and ran "ifup eth0" which brought up the network interface, got a dhcp address from my isc-dhcp-server and updated my DNS dynamically with the DNS IP info.  Again, not an elegant solution, but at least it gets me in business.  I'd like to have the lxdora7a port on sw1 created automatically with a vlan tag on it.


In LXC I do this by using a script - can the same be done with this LXD LXC container config ?  Here's how I do that with LXC:


lxc.network.script.up = /etc/network/if-up.d/openvswitch/ora72c10-pub-ifup-sw1
lxc.network.script.down = /etc/network/if-down.d/openvswitch/ora72c10-pub-ifdown-sw1


and then the up script looks like this:


root at g70:/var/lib/lxc/ora72c10# cat /etc/network/if-up.d/openvswitch/ora72c10-pub-ifup-sw1
#!/bin/bash
ovsBr='sw1'
ovs-vsctl add-port ${ovsBr} $5
ovs-vsctl set port $5 tag=10
root at g70:/var/lib/lxc/ora72c10#


Thanks,


Gilbert



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160924/af7556e1/attachment.html>


More information about the lxc-devel mailing list