SSH Latency Issues in CentOS 7 Linodes within the Same VPC
I've been facing network latency and connectivity problems while trying to establish SSH connections between certain Linodes within the same VPC. Occasionally, it's taking as long as 60 seconds, and at other times, the connection simply hangs and eventually times out. This problem appears to be isolated to Linodes operating on CentOS 7. What steps can I take to resolve this issue?
The culprit Linodes’ configuration: eth0 - VPC | eth1 - None | eth2 - None; We do not assign a public IPv4 address for this Linode. OS: CentOS 7.
1 Reply
Based on the configurations you provided, we replicated your setup and experienced the same behavior when attempting SSH connections between Linodes within the same VPC. Further testing revealed that this behavior is specifically present in distributions where the UseDNS directive is set to 'yes' by default, including CentOS 7. Given that you've opted not to assign a public IPv4 address to your Linode for full isolation within the VPC, the reverse DNS lookup times out, resulting in significant latency during SSH connection attempts.
To address this issue, you have two options. One approach is to assign a public IPv4 address to your Linode, although this may not align with your use case. Alternatively, you can disable DNS resolution by setting the UseDNS directive to 'no' in the sshd_config
file. Here are the steps to do so:
- Open the SSH server configuration file
sshd_config
using your preferred text editor:
sudo vi /etc/ssh/sshd_config
- Find the line containing UseDNS and change it to:
UseDNS no
- Save the changes, exit the text editor, and restart the SSH service:
sudo systemctl restart sshd
Upon implementing these changes, the SSH server will cease performing DNS resolution on connecting clients' IP addresses, mitigating the latency issue.