[CentOS] Problem with disconnecting SSH-sessions

Thu Dec 26 19:47:49 UTC 2019
Gordon Messmer <gordon.messmer at gmail.com>

On 12/25/19 6:56 AM, H wrote:
> I have tried to make sure the sshd configuration on all servers are identical but still have this problem. I can rule out a general problem with the router in my office since all connections are via that router, the only difference is that the problematic server is in the same building and the connection loops back via the same router but through an external IP address.


When you say "external address," I assume you mean that your office 
network is being NATed.  In that case, when you are connecting to 
systems outside your network, the router is performing SNAT for your 
connections.  When you connect to the system in your building, using an 
"external" address, your router is probably performing both SNAT and 
DNAT for that connection. Your router may have different timeouts on its 
SNAT and DNAT tables.  More than likely, the timeout for DNAT is lower 
than the TCP keepalive time, and you're seeing idle connections closed 
by the router.  You might be able to prevent that by setting a 
ServerAliveInterval value in ~/.ssh/config.  It is disabled by default, 
but should keep connections alive in your case, if it is set lower than 
the timeout on the router.