LXC : ping host with 2 containers and access internet


Hello everybody,

I’m new to LXC so I’m not very strong. I want my 2 containers to be able to ping each other and ping the host, also have access to the internet. But after following this link > https://wiki.debian.org/LXC/SimpleBridge . My containers ping the host, but not each other, and the host don’t have access to the internet.

For now, I made these steps :
Host machine

brctl addbr br0
ip addr add dev br0

vim /var/lib/lxc/container1/config


lxc.utsname = container1
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0

lxc.network.ipv4 =
lxc.network.ipv4.gateway =

(same for container2)

Can somebody help me please ?


I do not know much about LXC to be of any help. If you are OK to switch to LXD, then the default configuration would do exactly what you are asking.
See Comparing LXD vs. LXC to decide whether LXD would be useful for your case.


The thing is that I want to do it with lxc :thinking:


I wrote a tutorial to setup a bridge using lxc-net: https://angristan.xyz/setup-network-bridge-lxc-net/

It’s pretty straightforward and easy to setup, you should try it.


I tried to follow your tutorial but it doesn’t work :frowning_face:


Did you try from scratch? :stuck_out_tongue:


It’s ok, with an other method, I can ping my containers and the containers can ping the host. But they don’t have access to the internet :roll_eyes:


What’s the output of

iptables -t nat -L -v -n



I tried to run iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE but nothing