[lxc-devel] Using VLAN with LXD config

Gilbert Standen gil.standen at gmail.com
Fri Sep 23 04:13:28 UTC 2016


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 to add VLAN tagging in the lxc config file above so that the ovs switch
port gets tagged when the container starts?

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 container had
already booted:

sudo ovs-vsctl set port lxdora7a tag=10

Then I logged into the container using the 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.

oracle at g70:~$ nslookup lxdora7a
Server:        127.0.1.1
Address:    127.0.1.1#53

Name:    lxdora7a.rs.com
Address: 10.207.39.26

oracle at g70:~$ ssh root at lxdora7a
root at lxdora7a's password:
Last login: Tue Sep 20 18:42:36 2016 from stlns01.rs.com

[root at lxdora7a ~]# cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search rs.com
nameserver 10.207.39.1

[root at lxdora7a ~]# nslookup stlns01
Server:        10.207.39.1
Address:    10.207.39.1#53

Name:    stlns01.rs.com
Address: 10.207.39.1

[root at lxdora7a ~]#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160922/f47e2c51/attachment.html>


More information about the lxc-devel mailing list