Get IPv4 and IPv6 with one command

女生的网名这么多〃 提交于 2019-12-20 08:59:13

问题


I would like to know if is possible to get IPv4 and IPv6 address with just one command dig, and how?

For example: dig hostname A - the command above will give the IPv4

dig hostname AAAA - and this command will give me the IPv6 address

How can i get both addres, Ipv4 and IPv6, with just one command?

I got stuck in this problem, how can i get IPv4 and IPv6 with a authoritarian query, but with just one command?

Anyone can help me???


回答1:


If you're querying an authoritative server for the domain, you can get all the records for a name with an ANY query:

dig hostname ANY @servername

However, this won't work reliably if you're querying a caching server. When a caching server responds to an ANY query, it returns whatever records happen to be in cache at the time. If the name has both A and AAAA records, but the server has only looked up the A records recently, the AAAA records won't be in the cache, so it won't return them.

Furthermore, there is a proposal to allow DNS servers to refuse to answer ANY queries: Providing Minimal-Sized Responses to DNS Queries that have QTYPE=ANY. If you query a server that implements this, you may not be able to get both responses with a single query (although one of the suggestions in that draft is that an ANY query might just return all MX, A, and AAAA, since this is often what clients want). So for best reliability, you should just make two queries.




回答2:


It may be that this has been added to dig since the question was asked, but for completeness this can be accomplished through the following query:

dig hostname A hostname AAAA +short

Source: http://linux.die.net/man/1/dig -- under the 'Multiple Queries' section



来源:https://stackoverflow.com/questions/23699306/get-ipv4-and-ipv6-with-one-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!