- Ubuntu (derivative) or Arch with NetworkManager (ex: Antergos)
- Wired Connection (LAN)
- For the LXC part at the bottom: basic knowledge of LXC containers: Getting Started
I use a network bridge to connect my LXC containers to the same subnet as my other devices. This means that I can reach my containers from other machines/devices than my host. They (containers) have their own ip’s and look like any other equipment on the network.
I will use two different methods. The first, which is using NetworkManager will work on both ubuntu and Arch (with NetworkManager (Antergos)). The last will only to my knowledge work in ubuntu but is very useful if you are setting up a server to run a bunch of containers.
Open a terminal:
Select Add –> Bridge –> Create
Connection name, set br0 (or something else 🙂 )
Interface Name: br0 (Wrong in picture)
Click Add –> Ethernet
Device: Choose the NIC you want to bridge, if you only have one network card you only have one choice.
Cloned MAC address: Choose Preserve.
Save & save
Your bridge is ready, delete the Wired Connection 1 to use your bridge!
There will be some seconds when your network reconfigures, then you will be connected to your new bridge.
How to make LXC containers use your new bridge is at the bottom of the post.
Open a terminal
anders@ubuntults-vm:~$ ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:bb:0a brd ff:ff:ff:ff:ff:ff inet 10.0.1.41/24 brd 10.0.1.255 scope global dynamic ens33 valid_lft 86365sec preferred_lft 86365sec inet6 fe80::8fd0:7c43:56a4:ab90/64 scope link valid_lft forever preferred_lft forever
See ens33 ? (Yours will be different) That will be the “name” of your network interface. Take a note of that!
Now open /etc/network/interfaces
sudo nano /etc/network/interfaces
It should look like:
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback
We are going to change it to:
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback #bridge auto br0 iface br0 inet dhcp bridge-ifaces ens33 bridge-ports ens33 up ifconfig ens33 up iface eth0 inet manual
exit with ctrl-x –> Y –> Enter
sudo ifup br0
Now your bridge is ready! (Nothing happens? Reboot)
Configure lxc to use the bridge:
sudo nano /etc/lxc/default.conf
looks like: (Depending on distro).
lxc.network.type = veth lxc.network.link = lxcbr0 lxc.network.flags = up lxc.network.hwaddr = 00:16:3e:xx:xx:xx
change lxc.network.link = lxcbr0 to lxc.network.link = br0
Remember to change all your /var/lib/lxc/containername/config files to use lxc!