Create a catch-all zone in an authoritative DNS server - dns

I would like to have a DNS server which returns # CNAME example.com. for all requests unless otherwise specified. This will be used as the authoritative server for clients who don't customize their DNS.
Is it possible to configure BIND to have one catch-all zone file for any requests which don't have their own zone file?

You should be able to add a wildcard CNAME record.
*.example.com. IN CNAME example.com.

Related

DNS a vs cname records

Let's say my domain is xyz.com
If
- I had an A record pointing to an IP address, say 193.10.23.1
- then I had a CNAME www points to blah.cloudfront.net
But of course blah.cloudfront.net is not pointing to 193.10.23.1, will dns look up return the A record or the CNAME record? Is there an order of precedence or whether CNAMES overrides the A record?
Thanks
DNS standards does not allow having both CNAME and A record:
https://www.rfc-editor.org/rfc/rfc1034#section-3.6.2
If a CNAME RR is present at a node, no other data should be present;
this ensures that the data for a canonical name and its aliases cannot
be different.
DNS provider will usually will usually prevent you from adding conflicting records:
Cloudflare:
AWS Route53:

Setting NS for Subdomain to Another Hosted Zone with Same Apex Domain

Suppose I own example.com.
I delegate the subdomain www.example.com to a particular set of NS that is say a Route53 Hosted Zone. The rest of the example.com zone is not on R53 and contains important information for other subdomain/records. You can consider this Zone 1, and you can consider the new R53 Hosted Zone as Zone 2.
I want to have www.example.com CNAMEd to a particular endpoint, say a cloudfront distribution.
Since I can't CNAME the apex domain, instead hosted zone 2 is created in R53 with the original apex domain: example.com.
Then, inside that hosted zone, there is a record for the subdomain www.example.com with the CNAME to xxx.cloudfront.net.
I can't directly configure www.example.com with the CNAME in hosted zone 1 for various reasons, including that the CNAME is always changing and the person controlling the CNAME only has control over zone 2.
So the full chain looks like this:
User types in www.example.com, they get NS hosted 1 records. In that zone, the record for www.example.com points to Hosted zone 2 records. In this zone (which was created with apex example.com) the record for www.example.com is a CNAME to the proper endpoint.
My question: will any DNS resolvers mistakenly cache the NS from the second zone as apex domain records? Obviously, I want those NS accessed only for the www.example.com records. If example.com NS are mistakenly thought of as in hosted zone 2, there can be a lot of issues.
If this is the case, is there any way to make sure to dns resolvers that the apex domain nameservers are zone 1, and zone 2 records are ONLY for www.example.com, even though they were created with the example.com apex domain?
I understand that there are other ways to do this (CNAME to sep domain, etc) but for logistical purposes (for now) I am only interested in setting the NS directly for the www subdomain.
Thanks in advance.

DNS query through nameservers

If I host my website on Digitalocean and purchase my domain from namecheap.com, I have to edit the Nameservers linked to my domain (www.example.com) in my namecheap.com profile with ns1.digitalocean.com, ns2.digialocean.com, ns3.digitalocean.com.
Does that mean when the Recursive DNS server queries for the IP address from the Authoritative nameserver (namecheap.com servers), the namecheap.com servers will act as a recursive DNS server and redirect the query towards Digitalocean?
namecheap.com is a Domain Name registrant. It provides default name server for the domains bought from namecheap.com.
If you change the nameservers on domain name registrant, the DNS query from recursive nameserver will directly query the nameservers on digital oceans. There is no namecheap.com to digitalocean.com DNS query.

how to connect cloudflare root domain to AWS Elastic Beanstalk

I wish to setup Cloudflare so that both mydomain.com and www.mydomain.com will reach the same Elastic Beanstalk host.
I've created a CNAME for the "www" subdomain, it works great.
But how do I handle the mydomain.com DNS root entry? It's currently an A record, pointing to some IP, but in order to point to EB, I need to have a CNAME like "www", correct? If so, is it safe to somehow replace the A record with a CNAME despite the fact this is a root DNS entry rather than some subdomain..
thanks.
All you need to do is add a Page Rule
Match: mydomain.com/* and Redirect (301) to https://www.mydomain.com/$1
Or http if you’re not using SSL. The $1 means to copy the path from the original request.
Delete the A record from Cloudflare DNS Panel
Add a record with type CNAME and value as yourdomainname.com
This doesn't work on most DNS providers. However, Cloudflare has a feature called "CNAME flattening" that allows a CNAME Record to co-exist with other records at a domain's root. In practice, it doesn't act like a CNAME because when someone looks it up, Cloudflare resolves it internally, finds an A Record and returns the value. (This is how Alias A Records work on AWS Route 53, for example.)

Making nameserver for put domain on server ip

I have a domain and i want to set it to my server(centos 7).
I made a dns server by bind on my server and made 2 nameserver (ns1.myDomain.ir and ns1.myDomain.ir) and set it in my domain configuration, But i cant ping to my domain.
What is the problem?
At the domain registrar, you need to specify the authorised DNS server for your domain. My suggestion is to use the domain registrar's DNS server for resolution and create a zone file there for your domain and enter the A records and other records for your use case.
To have a domain working you don't need to setup your on DNS (bind) server.

Resources