Wildcard CNAME record for wildcard domain - dns

Suppose I own a wildcard domain like *.example.com that points at 192.0.2.34
All requests to https://bob.example.com will point at the server 192.0.2.34.
Is there a way that I can also have a wildcard CNAME that points *.bob.stuff.com at the 192.0.2.34 server?
Basically I'd like a double wildcard domain so I can do apps.bob.example.com and blarg.bob.example.com and have all of those resolutions point at 192.0.2.34 over SSL.

You can not do a "double" wildcard, in the sense that *.*.example.com will not work as expected in the zone.
You can however put both *.example.com and *.bob.example.com in your zone, the later will override the former, and you can repeat that for any other string than bob.
See https://serverfault.com/questions/942124/can-i-use-nested-dns-wildcard-records for a similar example.

Related

What is the correct term for apex/naked/bare/root domain names?

When you search term Apex Domains on Google Search, the top page you get is https://help.github.com/en/articles/about-supported-custom-domains, which explains the concept as:
An apex domain is a root domain that does not contain a subdomain part. Apex domains are also known as base, bare, naked, root apex, or zone apex domains. In DNS provider settings apex domains are sometimes symbolized by an # symbol. For example:
example.com is an apex domain because it doesn't have any subdomain
parts.
Whereas www.example.com is not an apex domain because it contains the >
subdomain part www.
This description alone says this concept is also known as
base domains
bare domains
naked domains
root apex domains
zone apex domains
Is there really not a well-recognized and established name for this concept?
If you want to be 100% technically correct, this latest RFC from the IETF does give precise information on all DNS terminology.
https://www.rfc-editor.org/rfc/rfc7719 "DNS Terminology".
Note that this deals with technical terms, not marketing ones.
If you search for apex in it you get:
Apex: The point in the tree at an owner of an SOA and
corresponding
authoritative NS RRset. This is also called the "zone apex".
[RFC4033] defines it as "the name at the child's side of a zone
cut". The "apex" can usefully be thought of as a data-theoretic
description of a tree structure, and "origin" is the name of the
same concept when it is implemented in zone files. The
distinction is not always maintained in use, however, and one can
find uses that conflict subtly with this definition. [RFC1034]
uses the term "top node of the zone" as a synonym of "apex", but
that term is not widely used. These days, the first sense of
"origin" (above) and "apex" are often used interchangeably.
In light of this, github definition is slightly wrong.
example.com is the apex of the zone example.com (because it is delegated from .com, that we know for sure), that has www.example.com in it.
Speaking about domains and subdomains is something opening to many perils, as you can not judge, just by looking at the string, where the zone cuts are, hence where the "subdomain" starts. Examples to study: www.dk, www.minefi.gouv.fr to start with.
Just by looking at www.example.com (without doing any kind of DNS queries) you can not say if www is just a label inside the example.com zone, or if www.example.com is an apex because it has been delegated from example.com.
Of course, one might argue that www gives an hint, but then replace it with admin, and the mystery remains unsolved.

Setting up domain alias CNAME record

I have a website setup at bryantmakesprog.10b3.com. I also own the domain sneaky.fish. I want my domain to point to this website by pointing to to the url, NOT the ip address. The end result being that visiting sneaky.fish/sample-page renders bryantmakesprog.10b3.com/sample-page but the URL says sneaky.fish/sample-page.
What would be the best way to go about this? I've seen some people have CNAMEs setup, but I'm not having any luck. Here's what I've tried:
To clarify, the domain must point to the subdomain. It is not sufficient to point to 10b3.com.
So there were two parts to this issue.
The first, the CNAMEs worked, it was just a matter of waiting.
The second issue was with the subdomain. sneaky.fish redirected to 10b3.com, and only bryantmakesprog.sneaky.fish would redirect to bryantmakesprog.10b3.com.
The solution for this was to use PHP to determine if a CNAME record exists pointing to bryantmakesprog.10b3.com and to handle that accordingly.

Wildcard subdomain for some but not all values on DNSimple

I have an app that is roughly fractured between a server serving front end and one serving an API. We'd like to add a wildcard to catch usernames on the subdomain and direct those to the front end server. So my URLs map like so:
Server that serves front-end files is mapped by https://example.com and https://www.example.com
Server for the API is mapped by https://api.example.com
We also have a forum, demo, etc at domains like https://forum.example.com and https://demo.example.com
Right now this is all straightforward using ALIAS records in DNSimple.
What is the best way to capture https://username.example.com and map it to the front-end server? We will need it to be a wildcard e.g. *.example.com, but we don't want to direct api, forum, demo, etc to that server.
Is there a way to set hierarchies or priorities at the DNS level so that it checks for the named matches first and then moves on to wildcard if nothing is found?
The way to go is exactly the one you considered. You should add a wildcard DNS record
*.example.com
that points to the IP (A) or hostname (CNAME) you want. The rule is that if there is a specific record matching the query, our DNS server will server it. Otherwise, we will fallback to the wildcard.
In other words, if you have a wildcard in place and a client asks for api.example.com, we will serve the api DNS record and not the wildcard. Specific records have higher priorities over wildcards.

Dynamic subdomain redirection

How do I redirect a dynamic subdomain to the same subdomain on a different domain?
*.example.com to *.example2.com
Can this be handled with Zerigo?
Depending on your exact requirements, you could achieve that with a DNAME record:
For example, you could have the following in your example.com zone file:
example.com. IN DNAME example2.com.
and a pretty standard example2.com zone, you can mostly achieve the effect.
Querying dig www.example.com, you'd get:
example.com. IN DNAME exmaple2.com.
www.example.com. IN CNAME www.exmaple2.com.
However, if you had DNS records that you need directly under either zones, e.g. an A, MX or TXT record, they don't "alias" so you need to store them in both zones.
In any case, DNAME is not supported in most DNS providers (Zerigo included) that only gives you a web interface, so you'd need to run your own DNS server.
In DNS you can not redirect, that is an HTTP function. But what you can do is use CNAMEs. A CNAME take a dns name and under the covers resolves it to another name. For example:
www.example.com resolves to www.example2.com. In the web browser the user will see www.example.com though.
What you will want to do is look into "wilcard CNAME". There is a limitation though. A wildcard CNAME will only point to a single address. This means that:
*.example.com will only ever point to a single address at example.com2 (let's say you pick bang.example2.com)
foo.example.com -> bang.example2.com
bar.example.com -> bang.example2.com
baz.example.com -> bang.example2.com
cux.example.com -> bang.example2.com
It is also important to note that not every DNS provider allows for wildcard CNAMEs. Also, not every DNS server allows wildcard CNAMEs. If you really want to have a wildcard CNAME point to the corresponding entry in example2.com, then you may want to look into powerDNS. It allows for 3rd party plugins written in various languages like lua. It also can be backed by a mysql, postgress, ldap, or a sqlite backed. This means that you can add that functionality yourself if it does not already exist.
Good luck

Point a main domain using cname

I need to point a domain using a CNAME to another, but I need to point both as the main domain www.
I think that it is not possible with cname. I need to point a domain to other domain like a cname, but also main domain.
How i can do it?
To redirect an entire domain, you actually want to use DNAME instead of CNAME. You can do CNAME records too, but you'd need one CNAME for every equal record, whereas DNAME lets you do just one. DNAME records aren't quite as well supported, however.

Resources