There've been a lot of questions and threads about this but none of them solves my problem.

I want to assign a specific ip to a specific container WITHOUT configuring it inside the container. The goal is to BIND the container to a specific ip.

  • The containers CAN'T use the same bridge as interface due to ip/packet spoofing.

  • There are 2 public ip's pointing to my host server. The first one should stay to the host, the second to a specific container.

1. Try: Using the lxd bridge

If i use the lxd bridge, i can assign every container a fixed ip address from the lxd bridge network (meaning: the lxd bridge creates a private network with an ip range that is NOT public but can be accessed from the host server)

My host system has access to the private lxd network and the public network. Now i could route (on the host system) a public ip to a private ip and therefore a specific container but i haven't found a way to do this since the incoming traffic from the public ip needs to be forwarded to the private ip und the outgoing traffic from the private ip to the public ip.

2. Try: Creating a network interface for every ip and assign the specific interface to the container

Since this is much more complicated (and i'm a newbie in linux) i've tried following the instructions from https://lists.linuxcontainers.org/pipermail/lxc-users/2016-March/011271.html

But it didn't work out.

I would go with the first attempt cause it should work if i can route the ip's to each other but i don't know how.


Just saw this answer How can I restrict an LXD guest to using a single public IP address?

Seems like this could work. Can'T test it at the moment because my home router can't assign free ip adresses to devices..

2 Answers 2

  1. configure standard lxd bridge

  2. create file /etc/default/lxd-static-ip.conf with 1 line per host as:

  3. edit /etc/default/lxd-bridge, set LXD_CONFILE variable to:

  4. restart lxd-bridge (e.g. systemctl restart lxd-bridge), restart your containers

  • Under 1. there is exactly explained what you say. The problem is solved, but thanks for the effort
    – SEUH
    Feb 15, 2017 at 22:36

The solution is to create multiple bridged interfaces on your host machine and then assign one bridge to one container.

This is a perfect tutorial: https://wiki.hetzner.de/index.php/KVM_mit_Nutzung_aller_IPs_aus_Subnetz/en

  • 1
    Does anyone have this tutorial since the link no longer works? In the future please post the comments not just a link! :-) Thanks
    – rik-shaw
    Jan 18 at 21:31

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.