I have a host A on which I have 2 lxc container (X and Y).
I originally had port 22 on my host (A) forwarded to X. Using this configuration, I wasn't able to ssh out of the container X and when ssh-ing out of contianer Y, it caused the ssh connection to be some how forwarded to X (even though I was ssh-in to an external computer).
When changing the port 22 fowarding from the host to forwarding port 2222 to X:22 then everything went back to normal...
Is there a way to forward port 22 to an lxc container?
Iptables command I used to forward port 22 on host A to container X:
iptables -t nat -A POSTROUTING -s 10.0.0.4 -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to-destination 10.0.0.4:22