[lxc-users] Macvlan setup issues

Dan Kegel dank at kegel.com
Fri Apr 29 21:45:19 UTC 2016


I'm playing with macvlan, too, which is a challenge as I am quite
ignorant about it, bridges, and lxc.

Novice gotchas so far:
- I have to run lxc under sudo (I think?), and after I do that,
.config/lxc is owned by root, and I can't even do lxc --help :-(
- I keep typing lxc when I mean lxd and vice versa, it'd be cool if
lxc and lxd detected that and said "Did you mean..."
- if you have btrfs, the right answer to lxd init's question about zfs
is "dir", maybe "btrfs" should be a synonym for "dir"
- if you don't care, the right answer to lxc init's question about
listening address is 0.0.0.0, that should be in the prompt, maybe
- After letting "lxd init" create a bridge, uninstalling doesn't get
rid of the bridge; use "ip link del lxdbr0"
(plus possibly "nmcli connection delete lxdbr0" if network manager has
gotten a whiff of it?)
- lxc init will abort if there are any cached images, have to do "lxc
image list" then "lxc image delete foo" (need 'lxc image delete all'?)
- there's no way to assign an alias when doing 'lxc launch", so it's
hard to write a demo script that cleans up after itself?
- lxc image list pretty-prints, not very scriptable

About macvlan:
I think the way to find the parent interface is to list 'em with
either ifconfig or "ip link".
Since "ip link" says I have two interfaces, lo and enp6s0, I gather
the commands to use macvlan are
  lxc profile device set default eth0 nictype macvlan
  lxc profile device set default eth0 parent enp6s0
Unfortunately, this fails for me with
error: Error calling 'lxd forkstart demo /var/lib/lxd/containers
/var/log/lxd/demo/lxc.conf': err='exit status 1'
sudo lxc info --show-log demo says
            lxc 20160429143729.079 ERROR    lxc_conf -
conf.c:instantiate_macvlan:2668 - failed to create macvlan interface
'mcFODJ4S' on 'eth0' : Invalid argument

And even trying lxd without macvlan now fails with that error message,
even after doing
sudo apt purge lxd lxd-client :-( :-(

sudo lxc profile device get default eth0 nictype still shows macvlan.
Where the heck is that stored?  Or is it the default?

Here's the script I was using to try to demo this:

-- snip ---

#!/bin/sh
set -ex
# Very destructive demo of lxd networking.  Read before running.

cleanup() {
    IMAGES=`sudo lxc image list  | grep UTC | awk '{print $3}'`
    if test "$IMAGES"
    then
        sudo lxc image delete $IMAGES
    fi
    sudo lxc delete demo || true
    sudo apt-get purge lxd lxd-client || true
    sudo rm -rf $HOME/.config/lxc
}

cleanup

# OK, now install lxc and configure it
sudo apt-get install lxd
sudo lxd init  \
       --auto \
       --network-address 0.0.0.0 \
       --network-port 8443 \
       --storage-backend dir \
       --trust-password demosecret \
       #

# Verify network works inside container
sudo lxc launch ubuntu: demo
sudo lxc exec demo ping -c 2 8.8.8.8
sudo lxc stop demo
sudo lxc delete demo

# Switch to macvlan
ip link
REAL_ETHERNET=enp6s0   # assume the non-lo interface ip link spits out is enp6s0
sudo lxc profile device set myvlan eth0 nictype macvlan
sudo lxc profile device set myvlan eth0 parent $REAL_ETHERNET

# Verify network works inside container with our special tweaks
sudo lxc launch -p default -p myvlan ubuntu: demo
sudo lxc exec demo ping -c 2 8.8.8.8
sudo lxc stop demo
sudo lxc delete demo

# Undo everything
cleanup

-- snip ---


More information about the lxc-users mailing list