0

I have a few questions about how dns works.

Would I be able to connect an A record to literally any ip address I want e.g the ip of Google?

I actually didn't know this and am quite astonished by this. I only thought you could redirect to websites you owned or could only have your domain forward to the actual destination link. And if this is true, than this must be the same for CNAME records, right?

In other words I can have my own domain be clicked on and display the site of Google while not displaying the name of google's domain but my own domain?

Would I be able to connect multiple records to one domain e.g an A record, a txt record, or an AAAA record and a CNAME record?

How do txt records actually work, do you really just type in the url in the browser and text pops up on the screen, or do you have to make a special get request or something?

3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jun 21, 2022 at 8:17
  • If you own a domain, you can setup the records to point to any IP or IPv6 address you want. It just does mean that it will provide anything sensible. Commented Jun 21, 2022 at 8:20
  • Oh that's pretty cool! Do you also know if I can link multiple records to one domain? Commented Jun 21, 2022 at 8:26

1 Answer 1

1

Would I be able to connect an A record to literally any ip address I want e.g the ip of Google?

Yes. It's not really a matter of "ownership", it's a matter of agreement between the domain owner and the server operator.

It won't be useful to you, if you're pointing to a server that hasn't agreed to serve the domain you want – the DNS entry will work, but the web server will just reply with an error page. (This is important for web or email, where the server knows what domain is being requested – or anything TLS-based where the server must have the right certificate.)

But in general, that's how paid web hosting works, for example – usually you don't own the IP address, and with 'shared' plans you don't own anything about the server, but you still point A/AAAA records to it, because it's been configured to recognize the domain and do something useful for it.

I actually didn't know this and am quite astonished by this. I only thought you could redirect to websites you owned or could only have your domain forward to the actual destination link. And if this is true, than this must be the same for CNAME records, right?

Also yes. Same as above, ownership doesn't matter, the only thing that matters is whether the server is configured to do what you want (again, when the discussion is about websites specifically, the target server will know what domain it's being visited as – and it might just respond with "Nope, I'm not configured to serve that domain").

Generally DNS doesn't care about "websites" or "links" in the first place – it only cares about domain names and IP addresses. But even then, DNS records are unidirectional; you can point anything to anything.

In other words I can have my own domain be clicked on and display the site of Google while not displaying the name of google's domain but my own domain?

It would work with some webservers. With Google – probably not.

Again, as mentioned above: webservers know what domain they're being called as (it's included in every HTTP request). Larger webhosts rely on this, as they serve many websites for different domains at the same IP address.

So if you just create an A record for your own domain pointing to such a webserver, it won't find a matching "virtual host" config, and will usually serve a generic error page instead of the website you wanted. But for small webservers that only have one "default" vhost, it would indeed work.

It also won't work with HTTPS or anything else TLS-based. Even in the simplest case, the server has to offer a certificate valid for the domain that's being visited, otherwise the browser will show a "certificate mismatch" error page.

But with many other (non-web) services, though, it would work and the server wouldn't even notice. For example, SSH or FTP don't report the hostname at all.

Would I be able to connect multiple records to one domain e.g an A record, a txt record, or an AAAA record and a CNAME record?

Generally yes, each service will only look at the record types it wants and ignore the rest, so you can have any combination of record types (whether it makes sense or not) – with a few exceptions.

For example, A+AAAA is very normal – that's how you host dual-stack IPv4+IPv6 services, with the same server having both address types. At the domain root, you would typically have MX for mail right next to those A+AAAA records (as well as NS+SOA for internal DNS operations).

There are record types such as SSHFP that are meant to be used alongside address records, and many types that have "descriptive" uses and can just be placed wherever (TXT, HINFO, RP, LOC…).

(I think that's kind of the whole point of there being different record types in the first place.)

One big exception is CNAME, however, which is usually not allowed to be used together with other record types. Either a name is an alias or it is not, but not both at the same time. (That's why you usually cannot put CNAME at your domain root – because you already have SOA and NS there.)

How do txt records actually work, do you really just type in the url in the browser and text pops up on the screen, or do you have to make a special get request or something?

No, web browsers don't interact with TXT records at all. They're there for other purposes.

(DNS as a whole predates the web by several years, so a lot of it is for other purposes than HTTP. Web browsers just use the same general-purpose A/AAAA records that many other services had already been using.)

While there's no URL for TXT records, you can see the content of such records by making direct DNS requests, using tools such as 'dig', 'host', or 'nslookup'. For example, on Windows you can run nslookup -q=txt example.com or Resolve-DnsName -Type TXT example.com, while on Linux or macOS, host -t txt example.com or dig example.com txt are preferred.

(There are actually two TXT records at the literal example.com – the one that starts with "v=spf1" is for mail servers doing SPF checks, the other is perhaps for DigiCert's domain verification. Most TXT uses nowadays are for automated requests, though you can still sometimes find TXT records that are meant to be read by sysadmins.)

1
  • I'm really grateful for your answer, I really appreciate it! So it is possible if http etc. is used IF there is no vhost file that specifies the only allowed domains (the webserver compares the domain the get request with any of the vhost file right?)? If you have https active, you had to generate a certificate for every domain name in your cpanel (or only one certificates that has all the possible domains in it?) or otherwise the webserver won’t offer a valid certificate (not a matching one) with the domain name you used. Commented Jun 21, 2022 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .