I'm on my company VPN and noticed that both nslookup and host returned the public IP address of our server, while resolveip and curl (as well as my browser) returned the correct internal address. Why would different Unix programs resolve the same hostname differently?
nslookup
, dig
, and host
are clients that query DNS directly. The getent
utility, curl
, and most applications (probably including this resolveip
you're talking about, though I'm not familiar with it) are clients of the C library's address resolving service. The C library's address resolving service is configured using /etc/nsswitch.conf
and by default consults /etc/hosts
and then consults DNS if it can't find an answer in /etc/hosts
. It could also be configured to not consult DNS at all (or some other service instead).
In your case, you probably have the correct internal address in /etc/hosts
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With