How does Google know the domain is really mine?
DNS | Verifying ownership with a TXT record
- 14 min read
- 18 terms from the glossary
I searched Google for the address of my site, the one you are reading right now. The answer was that no active site was found at that address, and that perhaps I had meant the site of someone else with a similar name.
The site was live, and opened in my browser without any problem. But it still did not appear in Google's search results.

The way to fix this goes through Google Search Console, the tool where you ask Google to crawl a site. But before Google is willing to listen to me about the domain, it wants to know that it is really mine.
And then a good question came up: how is it supposed to know? Anyone can type a site's address and claim to be the owner. Google does not know me, has no access to my hosting account, and does not ask for it either. And yet, a few minutes later it was convinced.
The way it was convinced is a small, elegant mechanism, which turns out to hide behind many other things on the internet. In this post I take it apart.
What I actually did
The first step was, in fact, not in cPanel. Google's dialog asked me to go to my "domain name provider", and then I realized I was not sure who that actually was.
First of all: where is my DNS even managed?
For anyone who needs a reminder: DNS is the system that translates site names into IP addresses, but you can also publish other information in it, such as mail settings and verification strings. A TXT record is simply a record that holds free text.
I bought the domain from a domain registrar, and the hosting from another company. The DNS can be managed by either of the two, or by a third provider altogether, and the record has to go in the right place. A record added in the wrong interface simply does not exist as far as the world is concerned.
The deciding factor is the domain's name servers (NS), and you can simply ask about them too:
nslookup -type=NS example.comIn my case the answer pointed to the hosting company's name servers, not the registrar's. In other words, the domain is registered in one place, and its DNS is managed in another: in the hosting's cPanel. That is where the record is added, and nothing is touched at the registrar. Certainly not the addresses of the name servers, because changing them could take down the site and the email.
Notice that I found this out, too, with a single public query. We will come back to that.
The four steps
-
In Search Console I chose between two property types. "Domain" covers all subdomains, over http and https together, and requires DNS verification. "URL prefix" covers only the addresses that start with the defined prefix, including the protocol, and also allows other verification methods. I chose Domain. Google opened a dialog called "Verify domain ownership via DNS record", with a string that starts with google-site-verification= and a copy button.

-
I logged in to cPanel, opened Domains, from there Zone Editor, and clicked Manage next to the domain.
-
I chose Add Record of type TXT and filled in three fields:
- Name: the fully qualified domain name, with a dot at the end (example.com.)
- TTL: the default, 14400 in my case
- Record: the full string from Google, including the prefix
-
I saved, went back to Google's dialog and clicked "Verify".
The dot at the end of the domain name is not a typo. It marks a complete name, and without it some interfaces add the domain name a second time.
And what is TTL? It stands for Time To Live: how long other DNS servers may keep the record in their cache before they ask again. 14400 seconds are four hours. This does not mean a new record will appear only after four hours, but that a server that kept the previous answer may go on returning it for up to that period.



In my case verification went through within seconds. That is not always so: a change in DNS needs time to propagate, and according to Google's documentation it can take anywhere from a few minutes to a few days.
Even after verification goes through, there is no point looking for data right away. Search Console showed me empty reports, with a message that the system was processing data and that it was worth coming back in about a day.

Notice what did not happen here. Google did not ask for the cPanel password, did not ask for access to the server, and did not ask me to change a single line of the site's code. It only asked me to write something in a specific place.
Why it works
The first thing that surprised me: the string is not secret at all. In the screenshots above I still hid it. Only later did I understand there was no need. DNS records are public information, and anyone in the world can ask what is written in my domain's TXT records and get an answer.
So if everyone can read it, what does it prove?
It proves that someone managed to write it there. Anyone can read DNS, but only whoever holds a domain's management rights can write to its zone. Google generated a unique string tied to my Google account, and then checked whether it appears in the domain's DNS. If it is there, the conclusion is that whoever is signed in to that account managed to get the record published, on their own or through whoever manages the domain's DNS.
It is a bit like asking someone to hang a specific note in the window to prove that they live in the apartment. Everyone walking down the street sees the note, but only someone with a key can hang it.
From this also follow two things worth stating precisely:
- This is proof of control, not proof of ownership. Google does not check in whose name the domain is registered. It checks who is able to actually manage it.
- Copying the string does not help anyone. Someone who sees my string cannot use it, because for it to verify anything they would need to publish a string of their own in my DNS, and that is exactly what they do not have.
Seeing it with your own eyes
You do not have to take my word for it. Open a terminal and run:
nslookup -type=TXT example.comOn Mac and Linux you can also use:
dig +short TXT example.comReplace example.com with your own domain. This is the real output from the domain of this site:
"v=spf1 ip4:82.166.38.22 +a +mx ~all"
"google-site-verification=1nddY9qgeZpp8p21z2S5YF2Z5uusnTgwsF9TsEIJNkk"Every line here tells you something:
- The line that starts with v=spf1 is an SPF record. It sets which servers may send email on behalf of the domain, and along the way reveals the IP address of the server that is authorized to send it.
- google-site-verification is the string from our story. Someone verified the domain with a Google service.
Two lines, without a password and without permissions, and you already know quite a lot about the domain.
It is worth knowing that the query returns only the TXT records of the name you asked about, not those of its subdomains.
And if you want to know where the domain's incoming mail goes, you ask about its MX records:
nslookup -type=MX example.comThe same principle, other places
Once you recognize the pattern, you see it everywhere. It is always the same: a service gives you a value, you publish it in DNS, and the service checks that it is there.
Let's Encrypt and TLS certificates. When you request a certificate, Let's Encrypt has to make sure the domain is under your control before it signs for it. One of the ways is called the DNS-01 challenge: it gives you a value, you publish it in a TXT record under _acme-challenge in the domain, and it checks. This is also the only way to get a wildcard certificate from it, one that covers all subdomains at one level at once, for example *.example.com.
Microsoft 365. When you connect a domain to an organization, Microsoft asks for a TXT record that starts with MS=. Exactly the same idea.
SPF and DKIM. These are no longer ownership verification mechanisms, but they too rely on what the domain's administrator publishes in DNS. With SPF you publish which servers may send email on behalf of the domain. With DKIM you publish a public key, and a server that receives a message uses it to check the message's digital signature.
In all these cases DNS serves as the domain's official notice board. Whatever is written in it counts as the owner's word.
The other side of the coin
If control of DNS is the proof that the domain is yours, then whoever gains control of your DNS can prove that they are you. Two conclusions follow.
The DNS account is a master key. Whoever gets into it can verify the domain with outside services, issue valid TLS certificates for it and redirect its email elsewhere, all without touching the server itself. Even so, this is often exactly the account that is neglected: an old password, no two-step verification, and sometimes access held by a supplier who stopped working with you long ago. It is worth checking three things on your side: that two-step verification is on at the domain registrar and in the hosting account, that the password is unique, and that you know who else holds access. And if the provider offers alerts about changes to records, it is worth turning them on, so that you discover an unexpected change even if someone has already got in.
TXT records tell stories about you. We saw above that two lines are enough to know who is allowed to send email on behalf of the domain and which services it uses, or used in the past. Someone planning an attack often starts exactly here, at the information-gathering stage, because this way you can learn about an organization's infrastructure without touching its servers. You cannot hide the records, but you can make sure they hold no more than they need to.
Cleanup: what to do with old records
Verification records tend to pile up. Every service you ever connected left one behind, and nobody goes back to delete them.
Before deleting, you need to know that verification is not a one-time thing. Google comes back and checks the record from time to time, and if it disappears, the verification may be revoked. So a record of an active service stays where it is.
On the other hand, an old record is not always harmless. Suppose a marketing agency once verified your domain with its own Google account, and you have stopped working together. Even if you remove it from the list of owners in Search Console, its verification string stays in DNS, and as long as it is there, the agency can verify itself again.
Google knows about the problem, and has a dedicated screen for it: in Search Console, under Settings and then Users and permissions, there is a list called Unused ownership tokens, with the strings of owners who were removed and not yet deleted. When you remove someone, you also need to remove their string, after making sure that no other active service relies on it.
So for every TXT record it is worth asking three questions:
- Who added it?
- Which service does it belong to?
- Is that service still in use?
A record that answers all three stays, and it is better to document it. A record that nobody can explain is a candidate for deletion, after checking that nothing relies on it.
And then I went back and asked Google
Right after verification I searched for the site's address again. The answer had hardly changed: no visible information was found about the domain.

That was a little disappointing, but it made sense. Verification answered one question only: who controls the domain. It did not put the site into the search results. For that, Google's crawler has to reach the site, read the pages and add them to the index, and for a new site that no other site links to yet, that can take anywhere from a few days to a few weeks.
What verification did give me is the ability to ask Google to crawl the site and to follow the process. A promise that it will happen quickly, or at all, Google does not give. Three things you can do from within Search Console:
- Submit a sitemap (Sitemap), so that Google knows which pages exist.
- Request manual indexing of the home page, through the URL Inspection tool.
- Make sure the site is not itself blocking crawling or indexing, for example in the robots.txt file or with a noindex rule left over from the build period.
I submitted a sitemap and requested indexing of the home page. Along the way I discovered that Google had actually known the site all along, just under a different address. That is a story for the next post.
As of writing these lines, I am still waiting for the crawl.
The bottom line
I started with a five-minute action in cPanel, and came away with three things I had not thought about before:
- You can prove control without revealing any secret. It is enough to show that you are able to write in the right place.
- DNS is the domain's root of trust, and the protection of the account that manages it should match.
- Whatever is written in DNS is visible to everyone, including what you forgot you wrote there.
If you ran the command on your own domain and found something surprising there, I would be glad to hear about it.
Glossary
| Term | Short explanation | Why remember it |
|---|---|---|
| DNS | The system that translates site names into IP addresses | You can also publish other information in it, such as mail settings and verification strings |
| TXT Record | A record that holds free text | The verification string is published in it, and so is the SPF record |
| NS | The domain's name servers: the servers that answer DNS questions on its behalf | They decide where the DNS is managed, and that is where the record has to be added |
| Domain Registrar | The company where you buy and register the domain | The DNS does not have to be managed there |
| cPanel | A control panel for managing a hosting account | Through it you manage the DNS when the hosting company runs it |
| Zone Editor | The cPanel interface for creating, editing and deleting a domain's DNS records | This is where the TXT record was added |
| FQDN | A fully qualified domain name, which ends with a dot | Without the dot some interfaces add the domain name a second time |
| TTL | How long other DNS servers may keep the record in their cache before they ask again | This is the time by which a change to an existing record may be delayed |
| Google Search Console | The tool where you ask Google to crawl a site | Before that, it asks for proof that the domain is under your control |
| Verification Token | A unique string tied to one account, published in DNS | The string is not secret; the proof is the ability to publish it |
| SPF | A TXT record that sets which servers may send email on behalf of the domain | It is visible to everyone, like any DNS record |
| DKIM | A digital signature on email messages, whose public key is published in DNS | A server that receives a message checks the signature with it |
| MX | The record that says where the domain's incoming mail goes | It too can be asked about with a single public query |
| TLS Certificate | A certificate confirming that a site holds its domain name, which allows an encrypted connection | Whoever gains control of the DNS can issue a valid certificate for the domain |
| Wildcard Certificate | A certificate that covers all subdomains at one level at once | Let's Encrypt issues it only through the DNS-01 challenge |
| DNS-01 | A Let's Encrypt challenge: you publish a value in a TXT record under _acme-challenge in the domain | The same principle as verifying the domain with Google |
| Two-Step Verification | A sign-in that requires, besides the password, also a code or an approval from another device | The DNS account is a master key, and it is worth protecting it this way |
| Sitemap | A file that tells Google which pages exist on the site | It can be submitted in Search Console after verification |
Further reading
An email for every new post
A short message with a link whenever a new post is published. Signing up needs a confirmation through a link sent to the address.