Mike
Mike

Reputation: 24964

How can I get the IP of a hostname using a fixed DNS server?

Is there an easy way, on *nix platforms(Linux specifically) to get the IP address of a hostname, while supplying a custom DNS server to use in place of the system's configured one? I want to access this information from a C program.

Upvotes: 0

Views: 269

Answers (2)

Emil Sit
Emil Sit

Reputation: 23542

You will need to use your own resolver, directly sending DNS packets, instead of relying on the system's resolver and gethostbyname. You would probably want to use a library, such as adns.

Upvotes: 3

Jeremy Vanderburg
Jeremy Vanderburg

Reputation: 842

nslookup <hostname> <dns server>

For example:

nslookup www.example.com ns1.example.com

Upvotes: 2

Related Questions