Most of our web applications run in LXD containers. Not without reason LXD is one of the of Ubuntu Server for me. There are many ways to access a web application in an LXD container from outside. For example, you can use a reverse proxy to control access to the containers. Another possibility is to set up a network bridge so that the containers are in the same network as the container host (the Ubuntu server). In this article I would like to describe how to set up a network bridge for LXD containers. most important features Network Bridge for LXD Containers To set up a network bridge under Ubuntu, you need to install the : bridge-utils $ apt install bridge-utils Then you can set up the network bridge. Ubuntu 16.04 Up to Ubuntu 16.04 Ubuntu uses to set network connection settings. The configuration is done in the files under . A simple network bridge — to get the containers into the host network — might look like this: ifupdown /etc/network/ $ cat /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interfaceauto loiface lo inet loopback # The main Bridgeauto br0iface br0 inet dhcpbridge-ifaces enp4s0bridge-ports enp4s0up ip link set enp4s0 up # The primary network interfaceiface enp4s0 inet manual In this example the bridge gets its address from a DHCP server. The real network card is set to manual mode and assigned to the bridge. enp4s0 Ubuntu 18.04 As of Ubuntu 18.04 is used to configure the network connections. The configuration files can be found under . A definition for the bridge could look like this: Netplan /etc/netplan/ $ cat /etc/netplan/50-cloud-init.yaml# This file is generated from information provided by# the datasource. Changes to it will not persist across an instance.# To disable cloud-init's network configuration capabilities, write a file# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:# network: {config: disabled}network:ethernets:enp3s0:dhcp4: noversion: 2bridges:br0:dhcp4: noaddresses:- 10.10.10.5/24gateway4: 10.10.10.254nameservers:addresses:- 10.10.10.254interfaces:- enp3s0 In the upper part you configure the real network card ( ) and don’t assign an address to it. Then the definition of the network bridge follows. It is set up like a static network connection and also contains the key . There you define which real network card should be “bridged”. You will find of network bridges on the official website. enp3s0 interfaces further (more complex) examples Now the following command applies the changes to the network settings: $ netplan apply --debug Assign Network Bridge Once you have finished setting up the network bridge and it gets the correct IP address, you have to tell the LXD container to get its IP address from the network bridge. This can be done with the following command: $ lxc config device add containername eth0 nictype=bridged parent=br0 name=eth0 With you define under which name the network card can be found in the container. Now you can configure eth0 in the container as you like. From now on the container will get an IP address from the host network. name=eth0 Conclusion You can set up a simple network bridge quit easily and assign it to a container. This allows other users on the network to access a web application without the need to set up a reverse proxy on the container host. More complex scenarios are also possible (VLANs, multiple bridges to get containers into different networks, etc.), but this would go beyond the scope of this short article. Originally published at openschoolsolutions.org .