Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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)?

Thanks.

share|improve this question
    
Possible duplicate of askubuntu.com/questions/256304/… –  sebgymn Sep 18 '13 at 11:31

2 Answers 2

up vote 4 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:

http://bj0z.wordpress.com/2011/08/19/howto-build-a-base-lxc-container-in-ubuntu-11-04/

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

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
    address 0.0.0.0

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 lxc.network.link = 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 at 8:58
1  
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 at 16:09

Your Answer

 
discard

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.