Here is a terrible trouble happened on our new server: unstable SSH connection. Here I want to share how I find and "shoot" the trouble.
First of all, you should know where the problem comes from. It can be wrong firewall settings, broken cables, or any problem in a server. I did so many trials from replacing the internet cable to alternating another router end. I found it works when I changed the IP for the questionable server, and another machine taking this IP facing the SSH connection problem alternatively. Therefore, it is very possible that the IP is the "suspect" that makes the trouble.
Following I am going to check if IP conflict occurs. IP conflict means that two or more machines are unexpectedly using the same IP. This can lead to problems of any connection. Maybe only one of the machines or each of them cannot be connected with, or each of them can be connected alternately.
The problem is: if there any other machines that shares the same IP with my server. I believed that NMAP should be a good tool to solve the problem! If you think you are facing the same problem, here are four simple steps to help you:
- Temporarily shut down your machine that cannot connected with, or it can be a noise when you want to find out who is using the questionable IP
- You need to find another server for following steps. Let me call it server2. Server2 should use the same router as the questionable serve uses. If you do not know which machine you have can be used, check each available servers from system setting>internet>options>IPv4. Router is indicated by the numbers in the column GATEWAY.
- Make sure that you have nmap installed on Server2. You can type the command below to install it
sudo apt-get install nmap
- Use NMAP to find the machine that using the IP. Here two basic commands can help you on detection
- sudo nmap -sP 123.456.78.999 ---> here type the IP you want to check
if the it show the message
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
which means that here is actually no other machines, and I think you had better leave this blog to find other solutions.
Or, it should tell you some basic information, including MAC address, of the machine that shares the questionable IP. Print the screen and send the photo to the IP manager, and tell him/her you need a new IP due to IP conflict.
- sudo nmap -A 123.456.78.999 ---> here type the IP you want to check
this command help no more than the above one if there is no such a competitive machine, but it can support you full information about the machine that competes with you for the IP, so that you may know who may suffer the same problem.