[lxc-users] Routable host IPs for containers

Michael Chinn michael.chinn at simpleprecision.com
Sun Sep 14 13:17:54 UTC 2014


LXC Networking --> Simple Bridge
Ref: https://wiki.debian.org/LXC/SimpleBridge

Requires bridge-utils package.
$ sudo apt-get install bridge-utils

1. Edit the host's /etc/network/interfaces

# for static ip setup on the host
iface br0 inet static
        bridge_ports eth0
        bridge_fd 0
        address 	192.168.0.x
        netmask 	255.255.255.0
        network 	192.168.0.0
        broadcast 	192.168.0.255
        gateway 	192.168.0.x
        dns-nameservers 8.8.8.8

2. Edit /etc/lxc/default.conf (on host):
Change:
lxc.network.link = lxcbr0
to
lxc.network.link = br0

3. Last, check if everything is prepared for LXC:
$ sudo lxc-checkconfig

4. Edit /etc/network/interfaces on each container (static IP):

auto lo
iface lo inet loopback

auto eth0
# iface eth0 inet dhcp

iface eth0 inet static
address         192.168.0.x
network         192.168.0.0
broadcast       192.168.0.255
netmask         255.255.255.0
gateway         192.168.0.x
dns-nameservers 8.8.8.8

I hope this helps.

Mike

On 09/14/2014 05:11 AM, Mark Constable wrote:
> This is probably dumb and asked a 1000 times before but I am totally
> confused by various tutorials that are either to old or do not apply
> to exactly my particular needs. For the purpose of ongoing/endless
> testing I'd like containers to be given an IP in the same network
> range via DHCP and my WIFI (wlan0) interface.
>
> Most examples presume an eth0 interface but that does not exist for
> my day to day laptop workstation.
>
> . router 192.168.0.1 via laptop wlan0
> . kubuntu 14.10 gets 192.168.0.209
>
> A ubuntu uptopic container currently gets 10.0.3.164 via the lxcbr0
> bridge with a gateway of 10.0.3.1. I can ping the outside world so
> the default ubuntu lxc networking system works just fine. I've tried
> a variety of combinations of br0 bridges and iptables rules but the
> right combination to "simply" allow a container to get another DHCP
> IP from my router on the same network as my main WIFI link so I can
> access those containers from other computers on the same 192.168.0.0/24
> network.
>
> Any tutorials or hints on how to do this?
>
> Maybe it's not possible for containers to appear on the same /24
> network as the host so surely there must be a "common" way to at least
> allow containers to be visible to other hosts on the same network segment?
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users

-- 
Michael Chinn
michael.chinn at simpleprecision.com

Simple Precision
mob: 510.908.3015
Skype: mchinnp2f


More information about the lxc-users mailing list