E
E
elfix2016-01-28 20:50:45
linux
elfix, 2016-01-28 20:50:45

What does gethostbyname resolve bypassing resolv.conf?

Gethostbyname and nslookup return different values. Nslookup is correct, gethostbyname is left (from the cache?) - I set both my 127.0.0.1 and Google's 8.8.8.8 in resolv.conf.
Where does gethostbyname get its value from?
Since you need to take A through php, I would like to figure it out.
If you call nslookup through PHP, the value is correct, but it is slower and more crooked than native PHP.
Through PHP dns_get_record is also left.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Chudnovsky, 2016-02-04
@Frankenstine

nslookup makes a request directly to the DNS server, and gethostbyname first breaks through /etc/hosts, according to the setting in /etc/nsswitch.conf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question