I am tracking the 4.0/stable/ubuntu-20.04 LXD snap. My LXD server, which is running on a bare metal install of 20.04 server has internet access but the LXD container doesn’t (I want it to) and I have been unable to ping my running container from the LXD host. I want my container to be accessible on the same LAN as its host via a bridge and I want to bond the 4 gig ethernet connections of the LXD server and use this for the LXD bridge.
I am aware of macvlan profiles but I would like to know how to get a bridge working because that would seem like a better solution in the long run as I add extra containers. I know lxd init can create a bridge for you but my understanding is thats no use if you want access your container from your LAN.
I’m not running iptables or ufw on the LXD server and I have enabled ipv4 forwarding. I have tried with both netplan and networkmanager and whilst I can get a bonded connection working, I don’t seem to be able to create a working bridge that uses a bond. I would prefer to use NM to do this if possible, I’m really not a fan of netplan’s yaml config files and it doesn’t have proper alternatives to nmtui and nmcli - same goes for networkd.
I have read the notes on bridges, systemd-networkd and DNS in the LXD docs on the networking page and tried creating a systemd unit but I’m not sure my bridge was correctly configured as when I ran brctl show
it wasn’t showing a device (like bond0) in the interface column. Seemed like a red flag to me.
$ lxc profile show default
config: {}
description: Default LXD profile
devices:
br0:
nictype: bridged
parent: br0
type: nic
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/instances/hermes
$ lxc config show hermes
architecture: i686
config:
image.description: Ubuntu 18.04 LTS Intel 32bit
image.os: Ubuntu
image.release: bionic 18.04
volatile.base_image: 51a1b0053632c41f0a7d8d5cb24050665170dbf3a98e995922183ab743a84314
volatile.br0.hwaddr: 00:16:3e:67:e7:3f
volatile.br0.name: eth1
volatile.eth0.hwaddr: 00:16:3e:7f:35:db
volatile.idmap.base: "0"
volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.power: STOPPED
volatile.uuid: 75a90036-c157-4706-9bfd-55fd39bdad82
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
ephemeral: false
profiles:
- default
stateful: false
description: ""
Here’s my attempt at creating a bridge with netplan:
network:
bridges:
br0:
addresses:
- 146.87.15.153/24
dhcp4: false
gateway4: 146.87.15.1
nameservers:
addresses:
- 146.87.174.121
- 146.87.174.122
search:
- domainname
interfaces:
- bond0
bonds:
bond0:
interfaces:
- eno1
- eno2
- eno3
- eno4
parameters:
lacp-rate: fast
mode: active-backup
transmit-hash-policy: layer2+3
ethernets:
eno1: {}
eno2: {}
eno3: {}
eno4: {}
version: 2
That creates a working bond but the bridge doesn’t seem to work.
I was trying stuff like this with nmcli:
nmcli connection add type bond con-name Bond0 ifname bond0 bond.options "mode=active-backup,miimon=100"
nmcli connection add type ethernet con-name Slave2 ifname eno2 master bond0 slave-type bond
nmcli connection add type ethernet con-name Slave3 ifname eno3 master bond0 slave-type bond
nmcli connection add type ethernet con-name Slave4 ifname eno4 master bond0 slave-type bond
nmcli connection add type bridge con-name Bridge0 ifname br0 ip4 146.87.15.153/24
Then I used nmtui to add the gateway and DNS for the bridge. I cannot ssh into the machine when I give the ip to the bridge, even though nmcli con show
gives the green status to br0, but internet and ssh works fine if I create a bond with nmtui.
The container has a static IP configured with ifupdown, its gateway is set to the IP of br0 on the LXD host and there is no DHCP server on the LAN of the LXD host.
Please let me know what else you need to know to troubleshoot this or maybe I will just have to use macvlan?