[Lxc-users] Running LXC containers on a laptop
    Daniel Lezcano 
    daniel.lezcano at free.fr
       
    Fri Sep 24 15:20:04 UTC 2010
    
    
  
On 09/24/2010 05:01 PM, matto fransen wrote:
> Hi,
>
> When I use br0 on my laptop (with wifi connection) I can connect from
> the container to the laptop, but not outside the laptop.
>
> What is the most easy way to setup wlan0 as gateway for
> the containers?
>    
Keep separate the bridge and wlan nic.
Assign an IP address to the bridge : 172.20.0.1/24
Assign an IP address to the container : 172.0.0.10/24
Add the default route in the container: route add default gw 172.20.0.1
On the host:
echo 1 > /proc/sys/net/ipv4/ip_forward
and
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
You can make this automatised by adding a dnsmasq on your host which 
will act as a dhcp server for the container.
On my host I have also in /etc/network/interfaces:
auto br0
iface br0 inet static
     address 172.20.0.1
     netmask 255.255.255.0
     bridge_stp off
     bridge_maxwait 5
     pre-up  /usr/sbin/brctl addbr br0
     post-up /usr/sbin/brctl setfd br0 0
     post-up /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
     post-up echo 1 > /proc/sys/net/ipv4/ip_forward
(the host is an ubuntu).
    
    
More information about the lxc-users
mailing list