Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify domain ownership

When setting up Google Adsense or Gmail as a site owner, you are required to modify a CNAME record for verification. Microsoft does the same thing.

I am building a website where I would like an owner of a group to verify ownership of a domain in the same way. How do I accomplish this?

like image 771
Matt Norris Avatar asked Oct 24 '09 23:10

Matt Norris


People also ask

Is DNS used to verify ownership of a domain?

Now you can also use DNS CNAME records to verify ownership of your domains. This is a new domain verification option for users that are not able to create DNS TXT records for their domains.

How long does it take to verify domain ownership?

Note: The process of adding a DNS record only takes 10 minutes, but verification can take up to 72 hours and is controlled by the domain host.


2 Answers

There's lots of ways to do this. Listed in order of preference:

  • microid
  • whois (check email address and/or name)
  • OpenID w/ delegation
  • DNS TXT (or CNAME if you must)
  • Insert HTML comment <!-- verify code --> into main page

I would recommend implementing some combination of these. The last one should be a measure of last resort for people who can't insert things into the <head> section of their sites. Done well, many users might be able to claim ownership of their domain without having to take any action at all, provided they've supplied you with an email address already.

For the specific issue of getting DNS information, try this:

$ dig TXT google.com

; <<>> DiG 9.4.3-P3 <<>> TXT google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4045
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN  TXT

;; ANSWER SECTION:
google.com.     3600    IN  TXT "v=spf1 include:_netblocks.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"

;; Query time: 131 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Sat Oct 24 16:50:56 2009
;; MSG SIZE  rcvd: 122

This particular query gives you the SPF entries for google.com. You could just as easily do:

dig TXT verify.example.com

Then check the confirmation code in the answer section.

like image 196
Bob Aman Avatar answered Oct 26 '22 02:10

Bob Aman


You need to query DNS server for the CNAME record of that domain. It can be as simple as using dig/nslookup/etc and scraping data from it or using name resolving capabilities of your platform/language.

like image 39
Zepplock Avatar answered Oct 26 '22 04:10

Zepplock