P
P
Pavel Bezrukov2015-02-11 21:34:48
SSH
Pavel Bezrukov, 2015-02-11 21:34:48

Why is ssh connection with port forwarding buggy?

Good afternoon
On a remote host raised 2 containers - lxc virtualization.
If in 2 windows I connect to the host machine and connect to containers in it and run ping site.ru on both windows, they work stably.
If in 2 windows I connect to machines via ssh using port forwarding, for the 1st machine host_ip:2210 on local_ip1:22 and for the second host_ip:2211 on local_ip:22, then I have a disconnect on the 1st window, then on friend. And if not disconnect, then 1 of the windows is wildly stupid, but at the same time in the 3rd window, where the connection to the host machine always works stably without interruptions. I tried to do forwarding 2210 to 2210 and 2211 to 2211 does not change the situation.
It feels like one of my connections clogs or clogs the communication channel.

Таблица маршутизации ядра протокола IP
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0         0.0.0.0         255.255.255.255 UH        0 0          0 eth0
0.0.0.0         111.111.111.1     0.0.0.0         UG        0 0          0 eth0
111.111.111.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 lxcbr0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 lxcbr0

iptables
*nat
:PREROUTING ACCEPT [5:1076]
:INPUT ACCEPT [2:92]
:OUTPUT ACCEPT [31:1928]
:POSTROUTING ACCEPT [3:984]
-A PREROUTING -p tcp -m tcp --dport 2210 -j DNAT --to-destination 192.168.0.10:22
-A PREROUTING -p tcp -m tcp --dport 2211 -j DNAT --to-destination 192.168.0.11:22
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Wed Feb 11 21:22:40 2015
# Generated by iptables-save v1.4.21 on Wed Feb 11 21:22:40 2015
*filter
:INPUT ACCEPT [185:20398]
:FORWARD ACCEPT [25:8200]
:OUTPUT ACCEPT [185:40181]
-A FORWARD -d 192.168.0.11/32 -p tcp -m tcp --dport 22 -j ACCEPT
-A FORWARD -d 192.168.0.10/32 -p tcp -m tcp --dport 22 -j ACCEPT
COMMIT

Please help me figure out what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-02-11
@rostel

add filter by destination host -d

-A PREROUTING -p tcp -m tcp -d <host_ip>/32 --dport 2210 -j DNAT --to-destination 192.168.0.10:22
-A PREROUTING -p tcp -m tcp -d <host_ip>/32 --dport 2211 -j DNAT --to-destination 192.168.0.11:22

optionally replace MASQUERADE with SNAT
find out why two identical routes
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 lxcbr0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 lxcbr0

find out why the "Lead Programmer" is in administration

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question