Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between nslookup, host and resolveip?

Tags:

unix

dns

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?

like image 361
Kevin Burke Avatar asked Dec 15 '22 22:12

Kevin Burke


1 Answers

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.

like image 119
Celada Avatar answered Dec 27 '22 04:12

Celada