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

Gilbert Standen gilstanden at hotmail.com
Fri Sep 23 23:58:28 UTC 2016


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/20160923/baa229d2/attachment.html>


More information about the lxc-devel mailing list