How efficient is DNS second-level domain lookup? For example, in a url web.example.com, the top-level domain is .com, and the second level domain is .example. When we query for web.example.com, the root servers will provide the gTLD servers for .com. After a gTLD server is selected for .com, this server will return the nameservers for example.com. How can one gTLD know the nameservers for all each possible second-level domain (such as "example.com") since there could be so many possible second-level domains? Based on wikipedia (en.wikipedia.org/wiki/Domain_Name_System#Structure) each label is up to 63 characters, so if we limit to the english alphabet, this already gives us 26^63 possible second-level domains.
The reason is that very very few of the 26^63 domains are actually used.
Also, the DNS system is hierarchical, so once a DNS server at an ISP looked up for example cnn.com, it will cache the data and not ask the root server about it again for a set time even if other clients ask about it. After a while, many root domains are cached very near to the clients.
That is not to say that the root servers don't have their work cut out for them... :-)
Most likely (I haven't checked, but will ask when I see the main author of BIND next) they just use a standard binary tree.
A properly balanced binary tree would need to be about 27 levels deep to hold the ~100M .com domain names.
It's unlikely to use a hash table since DNS servers typically need to be able to produce a sorted zone file on demand, and hash table's aren't that amenable to producing a sorted list of the keys.
Related
I wonder how services performing reverse NS lookup work.
So basically let's say we have a server with an IP address.
That server has a ns record, to which some other domains point.
So for example here, https://viewdns.info/reversens/
When we specify ns1.example.com we see all domains pointing there.
How one would approach it programmatically?
How one would approach it programmatically?
You can't, because there is no way to do this.
What people do is the following more or less:
start with a list of domains (do searches, try dictionary words, use social media, download gTLD zone files, etc.)
resolve them, you get the nameservers
record in some database the domain <-> nameservers mapping
Now, with all the data you can trivially do reverse queries. This is how basically everyone does it (hence it is never real time, you first have to collect all information).
I have a random number of domains (sub.client1.example, sub.client2.example, etc.) that I ask my clients to delegate to my name servers through a NS record.
The configuration for every delegated domain should be exactly the same (a CNAME to a fixed domain that we own and a record for SSL validation).
How to configure my DNS servers to accept requests for any domain name and return the correct configuration for it? Is there a hosted service like Route53 or DynDNS that would provide vanity name servers with support for that use case?
You are not saying with which nameservers.
With most of them, like Bind, you can write your zonefile in such a way that the domain name itself does not appear in the labels.
Basically you write www CNAME www.whatever.example and the missing dot at the end of www forces the nameserver to automatically add the domain name.
So with a zonefile written like that, you can configure your nameserver for all domain names it should be authoritative on and use that same exact zonefile.
This is one among many other options.
To be a little more on-topic for this programming Q&A website you could also:
use a nameserver that allows to use as source, instead of a static text file, content of a database (that some program of yours could fill in) or even directly a program that will get called to reply to each DNS packet
use some templating mechanism and some program to build all zonefile text files from other sources (like a database) before starting the nameserver.
Note that the first case with a "generic" zonefile text file is by far the easiest so that should be your first try.
Of course various providers on line could give you the same features more or less, starting with your registrar that could give you DNS hosting also. But it is also achievable by yourself if you agree to install and maintain a nameserver.
Also, you do not need any vanity server to do all of that, and I recommend you to just not follow that leads as it will not give you any kind of benefit.
If I register same domain name:
www.mysite.com
www.mysite.io
www.mysite.nu
and point all to same DNS servers, is that possible to one response faster than other?
I'm asking because my NU domain seems to be slow and I'm using this tool to check speed: https://www.ultratools.com/tools/dnsHostingSpeedResult
Each top-level domain has their own set of nameservers and they can certainly vary in number, location and performance.
E.g. when resolving mysite.nu, the DNS resolver must first ask one of the well-known root nameservers for the authoritative nameservers for the .nu top-level domain (turns out there are only three), pick one at random (e.g. b.nic.nu) and ask that nameserver for the location of nameservers for mysite.nu.
The country code (two character) top-level domains tend to concentrate their nameservers in a particular geographical region, and might therefore work faster for clients in the same region.
I would like to create a subdomain off of my main domain for accessing my raspberry pi at home. My domain register company charges £10 for every subdomain so I thought there might be an easier (and cheaper) way of creating one. It would also help if I knew a little more about them and how they are created.
DNS is built off of a hierarchy for scale-ability and/or for granularity.
If we take the a domain like www.stackoverflow.com. and break it down, here is what we get.
www - This is the host portion of the domain. It is either an A record or a CNAME and eventually points to an ip address.
stackoverflow - This is one of the domain levels. It has it's own DNS servers and config managed by the stackoverflow team. This allows that team to manage the entries specific to their needs.
com - This is called a TLD (top level domain). All other domains that end in .com have an entry on the "com" dns servers.
. - This is called the ROOT. There are 20 somodd root DNS servers scattered around the world. These servers are used to identify where the .com, .org, .edu, .gov, etc dns servers are.
From a client perspective what happens when you query www.stackoverflow.com is:
You query the . name servers to ask where the com dns servers are.
You query the com dns servers to ask where the stackoverflow dns servers are.
you query the stackoverflow dns servers to ask where www is.
A subdomain simply means that you add an additional layer of DNS servers in the mix so that you can add more scale-ability and/or granularity to the mix.
For example, if our dns name is: www.foo.stackoverflow.com we would now have the foo dns server layer.
Having said that, I do not think that you need a subdomain. You probably just need an additional DNS A record or CNAME. For example:
raspberry.stackoverflow.com instead of raspberry.foo.stackoverflow.
They should not charge extra for additional host entries (A record or CNAME), only for subdomains.
I noticed the service http://jpg.to/ supports any word, e.g. http://car.jpg.to/. Curious if this kind of thing is a burden on the DNS system, due to all the names that must potentially be stored, and therefore considered poor practice. Not picking on jpg.to, but just curious because I haven't seen anyone mention the issue when it's been covered.
Is it acceptable for a service to establish many thousands of subdomains?
This is wildcards.
DNS servers for jpg.to contain only one record, like this:
*.jpg.to. A 107.20.205.231
When client asks for any domain which ends with jpg.to (for example car.jpg.to), DNS server on-the-fly "generates" an answer like this:
car.jpg.to. A 107.20.205.231
As you see, there is absolutelly no additional burden on the jpg.to DNS servers, on the contrary it have to store only one record.
Although, (for those not familiar with the topic), DNS system built in the way that there are intermediate, "caching" DNS servers. They will cache the actual answer like car.jpg.to, and not a wildcard. Thus once people query lost of different domains under jpg.to, caching server will store many records.
There is nothing wrong with using wildcard DNS. Wildcards defined in the internet standards (RFC 1034 section 4.3.3) and this little additional load is part of normal operation of DNS infrastructure.
Wildcard domains are exactly that – wildcards.
They don't use any more spaces that a normal DNS entry.