Monday 12 September 2016

Linux host that pings itself resoves to 127.0.0.1

I had a RedHat linux machine which, when pinging itself, would resolve to 127.0.0.1 in the terminal output of the ping command.

This was caused by a wrong configuration in the /etc/hosts file:

127.0.0.1  MachineDNSName localhost.localdomain localhost
::1            localhost6.localdomain6  localhost6

I removed the MachineDNSName entry leaving it to:

127.0.0.1     localhost.localdomain localhost
::1                localhost6.localdomain6  localhost6

Now the pinging the machine from itself started to return its real external IP instead of 127.0.0.1

My example does not show how a host file should be configured. This only shows that an additional entry was resulting with network issues in specific cases (not all the time).
So in case of issues with wrong resolving of machine DNS name, look at your host file for possible issues.

No comments:

Post a Comment