开发者

How to get host entries of a domain

We want to get host entries of a domain.

Given a domain name (let us say: google.com) I need to get the host records (ex: CNAME, TXT etc..records). Is it possible to get them even when we do not have the 开发者_JAVA百科control on the domain (i.e domain not purchased by us?

Actually, my requirement is that when users enter domain name in my application (which is in development), I want to check if the domain belongs to them or not (I will be asking them to add some random string as TXT record) and then will read the TXT record of that domain in the backend and verify the domain. I think google does this (when we setup google apps account). Any pointers in this will help a lot. Thank you in advance.


you can only get records from a particular name (hostname or domain name)

To get a txt entry from a particular name run:

dig TXT [name]

more information about dig: http://en.wikipedia.org/wiki/Domain_Information_Groper

If you have the control of the dns server of the domain you can allow dns zone transfer which enables you to get full configuration of a domain. But, most of the time, this is forbidden.

In this case you will run dig AXFR [domainname]


You can use 'dig' for this from the command line to see what output you are to get for a given domain, then, in php you can use dns_get_record to get the same information.

http://php.net/manual/en/function.dns-get-record.php


The dig command in LInux, can do that.

For example:

dig stackoverflow.com TXT
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜