We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

LXD Containers


Darth Android
2016-12-17, 11:49 AM
You can do what you want, but you'll need 3 IP addresses - one for the host, and one for each container. First, go into your OVH control panel, and create a Virtual MAC for each container IP (type = OVH). Note the MAC and which IP it goes to, you'll need that later.

You've already created a bridge device and configured that with your host IP (71.X.X.X).

Now, we need to tell LXD to not use a NAT configuration and instead bridge the container directly to the internet. I'm not familiar with LXD, only the old-style LXC configs, but you should be able to convert the following to work with LXD:

Code:
# Network configuration
lxc.network.type = veth
lxc.network.veth.pair = conainer0 #name of the container's interface on the host, not important, just better than vethXXXXX. Must be unique
lxc.network.link = br0
lxc.network.flags = up
lxc.network.hwaddr = 02:00:00:XX:XX:XX # This must match the virtual MAC you set for the IP in your OVH control panel. 
lxc.network.ipv4 = 213.Y.Y.Y/32 213.Y.Y.Y # 213.X.X.X is the container IP
lxc.network.ipv4.gateway = 71.X.X.254 # Gateway of the host IP
Apply that to both containers, each with a different ip and virtual MAC that correspond to the IPs you set up in your control panel.

qwerty
2016-11-14, 09:45 AM
Hi,

I have rent a dedicated server (SUPERMICRO) where I have install Ubuntu 16.04.

Using the LXD in Ubuntu 16.04 I have create two LXC containers and what I what to achieve is to assign two different public IP addresses to those containers.

I already have the two IP addresses 71.X.X.X and 213.X.X.X.

Using the 71.X.X.X I have create the bridge "br0" which has connection to internet and I can ping the server.
Here is the /etc/network/interfaces configuration:
+++++++++++++++++++++
auto lo
iface lo inet loopback

auto br0
iface br0 inet static
address 71.X.X.X
netmask 255.255.255.0
gateway 71.X.X.254
dns-nameservers 8.8.8.8
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

iface eth0 ine manual
+++++++++++++++++++++

Next, using the LXC I created the container "test1" and I change the /etc/network/interfaces to this, but it is not working (no internet access):
+++++++++++++++++++++
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 71.X.X.X
netmask 255.255.255.0
gateway 71.X.X.254
dns-nameservers 8.8.8.8
+++++++++++++++++++++

Next, using the LXC I created the container "test1" and I change the /etc/network/interfaces to this, but it is not working (no internet access):
+++++++++++++++++++++
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 213.X.X.X
netmask 255.255.255.0
gateway 213.X.X.254
dns-nameservers 8.8.8.8
+++++++++++++++++++++

I am using the same configuration on a Ubuntu server that I am running on a physical machine with six containers and six different IPs and it works without any problem, but using the configuration and many many different configurations and OS, I am not able to make it work.

From what I have read is that probably my problem is that "switch" (or vSwitch) is not in promiscuous mode and for that I am not able to assign the IPs to the containers.

Do you know how to enable the promiscuous mode or any other solution that could make the trick?

Best regards,
Q