1

I'm pretty new to linux, and I have been struggling with a problem for the past week or so...

I am trying to setup a cluster of LXC containers on a workstation (host) which is has IP 192.168.10.33 connecting to a gateway with IP 192.168.10.1

the LXC nodes are by default connected to the lxcbr0 bridge with IP 10.0.3.1, containers have IP between 10.0.3.111 and 10.0.3.120

I can ping each container from the host, I can ping the bridge (10.0.3.1) from the containers, as well as the host IP (eth0, 192.168.10.33) but I can't reach the gateway (192.168.10.1) I have read a multitude of posts and man pages about networking, iptables and routing, but nothing has worked so far (defining default gw, ip forwarding...)

If i configure the lxcbr0 bridge to be at 192.168.10.33 (the host IP) and my containers to take IP on the same IP range (192.168.10.111 to 120), then it works fine.

I would like to understand how I am supposed to bridge 2 networks with different IP ranges as mentioned (bridging 192.168.10.0/24 with 10.0.3.0/24) ???

(as a disclaimer, i disabled firewall and anything that could prevent reaching the gateway in the first place, i can reach it from the host)

any insight to point me in the right direction would be appreciated. Thank you

MrE
  • 408
  • 1
  • 5
  • 14
  • Is there a specific reason you aren't using Docker for LXC container management? It makes a lot of this stuff happen for you without any of this headache. – theterribletrivium Nov 03 '14 at 22:05

2 Answers2

0

You need to check your NAT settings or add a network route on gateway. For adding route you should run command on gateway(if it is Linux of course):

ip route add 10.0.3.0/24 via 192.168.10.1  

For adding NAT:

/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
user2986553
  • 390
  • 1
  • 4
  • This route is actually done by the LXCBR0 bridge already at config: i.e. the route was there on the host. What I realized though is that a LXC contained works fine out of the box with defaults when it is CREATED, but all subsequent CLONED containers had this connection problem, along with SSH stopped. I ended up creating all my containers and running my install scripts inside them, as opposed to cloning, and all is fine. I was not able to get the connection working from within cloned containers, and I still don't know why. – MrE Nov 16 '14 at 17:18
0

What I realized is that a LXC contained works fine out of the box with defaults when it is CREATED, but all subsequent CLONED containers had this connection problem, along with SSH stopped.

I ended up creating all my containers and running my install scripts inside them, as opposed to cloning the original container.

I was not able to get the connection working from within cloned containers, and I still don't know why, but i solved my problem.

MrE
  • 408
  • 1
  • 5
  • 14