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开发者_JAVA百科 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.
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.
nslookup <hostname> <dns server>
For example:
nslookup www.example.com ns1.example.com
精彩评论