[lxc-users] lxd "hello, network"?
Fajar A. Nugraha
list at fajar.net
Wed May 4 15:31:14 UTC 2016
On Wed, May 4, 2016 at 10:18 PM, Dan Kegel <dank at kegel.com> wrote:
> On Tue, May 3, 2016 at 10:08 PM, Fajar A. Nugraha <list at fajar.net> wrote:
>>> I haven't had much luck using lxd-init to set up working networking...
>>
>> dpkg-reconfigure -p medium lxd
>
> That's about the same as lxd-init, isn't it?
It can be called by lxd-init.
>
>> Note that it does not perform verification, so for example, if you put
>> 10.0.3.1 as bridge IP address but use 192.168.0.100 as DHCP start IP,
>> dnsmasq would simply won't start. Which might explain the problem you
>> experienced.
>
> I'm pretty sure my problem is I was trying to fully script everything
> from zero, and didn't know how to script "sudo lxd init". I used its --auto
> flag, and all the options it provides, but didn't realize that meant I
> had to set up the bridge manually. None of the doc I've seen
> actually shows the exact commands to script what lxd init does,
> or at least shows them in a way that's easy for an idiot to recognise.
> (I'm sure somebody who is fluent in linux bridges would say "not needed,
> it's obvious" :-)
you actually don't need a bridge for macvlan. This script works for
me, no user intervension needed
set -x
bash -c 'DEBIAN_FRONTEND=noninteractive apt-get -y install lxd < /dev/null'
lxd init --auto --storage-backend dir --network-address 0.0.0.0
--network-port 8443 --trust-password some-password
PARENT=$(ip route | awk '$1~/default/ {print $5}')
lxc profile device set default eth0 parent $PARENT
lxc profile device set default eth0 nictype macvlan
lxc profile unset default environment.http_proxy
lxc profile unset default user.network_mode
lxc launch images:ubuntu/xenial/amd64 demo
lxc exec demo bash -- -c 'while ! ip route | grep -q default; do sleep
1; done; ping -c 1 google.com'
lxc list demo
lxc stop demo
set +x
As a side note, I tested the above script inside a container (with
nested lxd capability enabled,
https://insights.ubuntu.com/2016/04/15/lxd-2-0-lxd-in-lxd-812/ ) so
that I can simply reset (well, rollback in my case, since I use zfs)
it if I needed a fresh start. The difference in my setup is that I
manually allocate a large-enough uid/gid range for root and lxd in the
physical server:
# egrep 'root|lxd' /etc/sub*
/etc/subgid:root:1000000:1000000
/etc/subgid:lxd:1000000:1000000
/etc/subuid:root:1000000:1000000
/etc/subuid:lxd:1000000:1000000
--
Fajar
More information about the lxc-users
mailing list