2

I have 17.10 server with LXD installed via snap (2 containers).

I've configured host to have static IP and let containers be accessible from LAN.

My 01-netcfg.yaml in /etc/netplan:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: no
      dhcp6: no
  bridges:
    lxdbr0:
      dhcp4: no
      interfaces:
        - enp1s0
      addresses: [192.168.0.10/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.1,8.8.8.8,8.8.4.4]
      parameters:
        stp: false
        forward-delay: 0

After running sudo netplan apply everything works, I have internet access from host.

ifconfig gives the following:

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 2c:4d:54:4f:33:30  txqueuelen 1000  (Ethernet)
        RX packets 5412  bytes 5196030 (5.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4483  bytes 624400 (624.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 222  bytes 19478 (19.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 222  bytes 19478 (19.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lxdbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::60c5:c9ff:fee3:a28f  prefixlen 64  scopeid 0x20<link>
        ether 62:c5:c9:e3:a2:8f  txqueuelen 1000  (Ethernet)
        RX packets 2646  bytes 1973322 (1.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2640  bytes 332354 (332.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethAUK196: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::fca4:95ff:fed5:a908  prefixlen 64  scopeid 0x20<link>
        ether fe:a4:95:d5:a9:08  txqueuelen 1000  (Ethernet)
        RX packets 1787  bytes 291994 (291.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2916  bytes 3204729 (3.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethBY974H: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::fccc:7dff:fe51:3ae6  prefixlen 64  scopeid 0x20<link>
        ether fe:cc:7d:51:3a:e6  txqueuelen 1000  (Ethernet)
        RX packets 23  bytes 1958 (1.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 326  bytes 26711 (26.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethP62W14: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::fce2:c7ff:fe4d:d7da  prefixlen 64  scopeid 0x20<link>
        ether fe:e2:c7:4d:d7:da  txqueuelen 1000  (Ethernet)
        RX packets 46  bytes 3508 (3.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 317  bytes 26407 (26.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

After reboot there's no internet in host (though, ping inside LAN subnet works and internet in containers works).

ifconfig shows exactly the same, except lxdbr0 has broadcast 0.0.0.0 instead of original value broadcast 192.168.0.255.

After running sudo netplan apply after reboot it starts working again and broadcast for lxdbr0 again fills with working value.

Any ideas?

Upd: installed NetworkManager and tried to use it as renderer - no effect, everything works like with networkd :(

1

Copied in solution as answer, as I missed it the first time I looked at this (in the comments) Credit to @user4124, marked this as community wiki.

Install LXD (host only)

sudo apt remove --purge lxd lxd-client && apt install bridge-utils
sudo snap install lxd
sudo reboot
sudo lxd init

While installing, don't create network bridge.

Setup network for host

sudo nano /etc/netplan/01-netcfg.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      dhcp4: no
      dhcp6: no
      interfaces:
        - enp1s0
      addresses: [ 192.168.0.2/24 ]
      gateway4: 192.168.0.1
      nameservers:
          addresses:
              - 192.168.0.1
              - 8.8.8.8
              - 8.8.4.4
      parameters:
          stp: false
          forward-delay: 0

sudo netplan --debug apply

Reboot and confirm that config is fine:

sudo reboot
ifconfig -a
ping google.com

Edit default profile to make sure only bridge is present in config, with no extra nic's

sudo lxc profile show default // add '> out.yaml' to output to file
sudo lxc profile edit default // add '< out.yaml' to read from file

Example out.yaml:

### This is a yaml representation of the profile.
### Any line starting with a '# will be ignored.
###
### A profile consists of a set of configuration items followed by a set of
### devices.
###
### An example would look like:
### name: onenic
### config:
###   raw.lxc: lxc.aa_profile=unconfined
### devices:
###   eth0:
###     nictype: bridged
###     parent: lxdbr0
###     type: nic
###
### Note that the name is shown but cannot be changed

config: {}
description: Default LXD profile
devices:
  br0:
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by:
- /1.0/containers/apache

Setup network for container

Run:

sudo lxc exec <container> bash
nano /etc/netplan/50-cloud-init.yaml

Insert:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses:
        - 192.168.0.5/24
      gateway4: 192.168.0.1
      nameservers:
        addresses:
          - 192.168.0.1
          - 8.8.8.8

    netplan --debug apply

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.