<div dir="ltr">Thanks so much Brian for sharing the concise writeup. I've been wondering how to pull that kind of networking off.<div><br></div><div>Sincerely,</div><div>Jeremiah</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 29, 2016 at 3:11 PM, Brian Candler <span dir="ltr"><<a href="mailto:b.candler@pobox.com" target="_blank">b.candler@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think I have this working by using proxyarp instead of bridging.<br>
<br>
On the EC2 VM: leave lxdbr0 unconfigured. Then do:<br>
<br>
sysctl net.ipv4.conf.all.forwarding=1<br>
sysctl net.ipv4.conf.lxdbr0.proxy_arp=1<br>
ip route add 10.0.0.40 dev lxdbr0<br>
ip route add 10.0.0.41 dev lxdbr0<br>
# where 10.0.0.40 and 10.0.0.41 are the IP addresses of the containers<br>
<br>
The containers are statically configured with those IP addresses, and 10.0.0.1 as gateway.<br>
<br>
This is sufficient to allow connectivity between the containers and other VMs in the same VPC - yay!<br>
<br>
At this point, the containers *don't* have connectivity to the outside world. I can see the packets are being sent out with the correct source IP address (the container's) and MAC address (the EC2 VM), so I presume that the NAT in EC2 is only capable of working with the primary IP address - that's reasonable, if it's 1:1 NAT without overloading.<br>
<br>
So there's also a need for iptables rules to NAT the container's address to the EC2 VM's address when talking to the outside world:<br>
<br>
iptables -t nat -A POSTROUTING -s <a href="http://10.0.0.0/8" rel="noreferrer" target="_blank">10.0.0.0/8</a> -d <a href="http://10.0.0.0/8" rel="noreferrer" target="_blank">10.0.0.0/8</a> -j ACCEPT<br>
iptables -t nat -A POSTROUTING -s <a href="http://10.0.0.0/8" rel="noreferrer" target="_blank">10.0.0.0/8</a> -o eth0 -j MASQUERADE<br>
<br>
And hey presto: containers with connectivity, albeit fairly heavily frigged.<br>
<br>
But this is quite a useful outcome. You can run a single EC2 VM, and run multiple containers on it for separate services, reached via separate VPC IP addresses as if they were separate VMs, albeit ones without their own public IP addresses.<br>
<br>
Regards,<br>
<br>
Brian.<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org" target="_blank">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" rel="noreferrer" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a></div></div></blockquote></div><br></div>