Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I setup LXC using:

lxc-create -t ubuntu -n lxcguest1

But I can't access any services running on it from my LAN, it appears to be NATed. How do I set it up so that I can access it (it probably needs to get it's dhcp address from my Linksys router)?


share|improve this question
Possible duplicate of… – bekce Sep 18 '13 at 11:31
up vote 5 down vote accepted

I've just dealt with this issue myself. Basically you need to setup a bridge and bind your network card and container to it. Here is the article I followed:

Sounds as if like me, you require the 'bridge' solution rather than the NAT solution. I also turned off the default LXC bridge setup (which is NAT'ed). To do this just edit the file: /etc/default/lxc and change USE_LXC_BRIDGE="TRUE" to USE_LXC_BRIDGE="FALSE" and reboot.

share|improve this answer
I am a little confused by this solution: it says he needs to setup a bridge, then says the solution is to turn off the default bridge setup. Surely he must switch ON a bridge setup. The second thing I need help with is that User says that the bridge setup is NATed, Surely it's either bridged (so the containers is on the same network as the host) or is NATed (on a different network and requires routing). My understanding is that these are mutually exclusive? – John Little Mar 22 at 21:31

My setup on Ubuntu 14.04.1 LTS (Trusty Tahr) hosts

Add to /etc/network/interfaces on the host

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

auto br0
iface br0 inet dhcp
    bridge_ports eth0

(reboot after changes)

And on the container config files (/var/lib/lxc/containername/config) I set = br0

With this the container will get public ip addresses from the dhcp server just like the host.

share|improve this answer
@JonathanY. The br0 should appear after adding it to /etc/network/interfaces as stated in the answer. You might need a reboot. – Epeli Jan 14 '15 at 8:58
Thanks. What I was missing was needing to add <username> veth br0 2 to /etc/lxc/lxc-usernet in order to use br0 with unprivileged containers. – Jonathan Y. Jan 14 '15 at 16:09

I used the default Ubuntu LXC settings, and configured my router to send all traffic on to the Ubuntu machine. On a DD-WRT enabled router, the settings look something like the screenshot below. Replace with the IP of the machine running LXC. Other routers should have similar options to set up a static route (here are static route instructions for Linksys, for example).

DD-WRT settings for static routing to LXC

This is unrelated, but I also used the DNSMasq service to point a hostname to the LXC container's IP address. This way I can access the container at http://gitlab/ anywhere on the network. In my opinion it's a lot easier to use a hostname to access a container than remember the IP address.

DD-WRT DNSMasq settings

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.