Ping on centOS resolving instead of returning "unknown host"
Check your /etc/resolv.conf and see you have nameserver enrty to resolve the domain, if we have nameserver entry missing we will also get this error
Related videos on Youtube
nahanil
Updated on September 18, 2022Comments
-
nahanil over 1 year
On my local machine (Ubuntu) if I were to ping a hostname that is non-existent, the ping command returns
$ ping somefakedomain.com.au ping: unknown host somefakedomain.com.au
However the same command on either of my remote centOS servers returns totally different results
$ ping somefakedomain.com.au PING texh.net (103.4.16.120) 56(84) bytes of data. 64 bytes from toph.texh.net (103.4.16.120): icmp_seq=1 ttl=64 time=0.046 ms ...
This really has me stumped, I'd love if anyone has any ideas as to why this is. I've tried Googling for it, but all I seem to be able to find is the opposite problem where people are unable to ping valid hosts due to various networking issues.
What I plan to do with this is set up a cron job to ping several servers to check that they're still online, and to gauge network latency between the two, however it seems that if one of the servers pinged was down, then it would simply ping itself and return false positives.
-
nahanil almost 12 yearsThanks, I think you may be on to something. I had my suspicions that it could be something to do with /etc/resolv.conf not being completely correct. It's original contents were
nameserver 8.8.8.8 nameserver 8.8.4.4
I just prependedsearch toph.texh.net
(machines hostname) to the file, and it seems to work as I was expecting originally. Would this be the correct thing to place there, or am I way off? For now it seems to be working okay, just don't want it to come back and bite me in the butt later on.