开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜