0

I have a LXC container inside a host. A program inside the container is trying to communicate with external nodes using port 9876. If I connect an external ip to the host VM, everything works.

I added a TCP load balancer for port 9876 between the external ip and the host VM, and now I am getting connection timeouts.

Do I need to set something in the host or container in order to allow the connections? I believe that I need to 'expose' the port using iptables, but I didn't find a clear explanation on how to do it.

this is the current iptables nat configuration on the host:

root@peer-1:/# iptables -L -n -t nat -v
Chain PREROUTING (policy ACCEPT 39 packets, 2510 bytes)
 pkts bytes target     prot opt in     out     source               destination
    2   120 DNAT       tcp  --  ens4   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:9876 to:10.0.11.10:8012

Chain INPUT (policy ACCEPT 10 packets, 770 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 28 packets, 1954 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 28 packets, 1954 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  *      *       10.154.105.0/24     !10.154.105.0/24      /* generated for LXD network lxdbr0 */
15424  926K MASQUERADE  all  --  *      *       10.0.11.0/24        !10.0.11.0/24

I am using google cloud, if it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.