Does a Browser look up DNS on every refresh? - browser

Does a browser lookup DNS every time it makes a request?
Or perhaps it looks at the A-record TTL and follows that directive?
I am wondering if a browser will keep changing site IPS, if the underlying site has multiple IPS which are being served up round-robbin-style by DNS?
RESULTS In addition to the comments below, I've found that Nameservers are where caching strictly occurs, and may or may not occur in your browser/OS. HOWEVER, if you have a site that is infrequently accessed,then you can expect propagation of any changes to occur instantly, since many nameservers will not have queried for your records, and will query the instant they are asked. Basically, the more a site is accessed, the more exact your TTL will work.

A browser should follow the DNS TTL timeouts. (that's exactly the reason they exist)
That means that if you are using round robin DNS and the record that you are pointing to goes offline, then that client will be offline until the TTL expires. In these situations you should keep a short TTL, and be sure to use a DNS provider with good global coverage.
(However, I think I read somewhere that Chrome has its own DNS resolver, and breaks those rules in a few places - or I could have imagined that bit!)

Related

1&1 domain name redirects to heroku hosting

I deployed my node js app properly on heroku and it's working fine with the heroku provided domain name.
Now, I'm trying to link it with my personal domain name. On the heroku website, in the settings section of my app hosted by heroku, I have setup the domain name to be my-app.com and my heroku dns is set to my-app.com.herokudns.com
In 1&1, I have registered a domain name my-app.com that I redirect to www.my-app.com
Still in 1&1, I have then created a sub-domain called www.my-app.com, in which I have set the DNS CNAME to my-app.com.herokudns.com
I saved everything but when I go to www.my-app.com, the url shows www.my-app.com/defaultsite in which the content shows a heroku generic page telling me There's nothing here, yet. Build something amazing.
Could anyone has a clue on what may be missing to connect to my app ?
DNS changes take time to propagate through the network. Very often you'll have to wait before seeing them take effect.
This can be somewhat mitigated by setting your records' time to live (TTL). This value specifies an expiry time for your records after which cached values should be re-fetched from the authoritative server:
Shorter TTLs can cause heavier loads on an authoritative nameserver, but can be useful when changing the address of critical services like Web servers or MX records, and therefore are often lowered by the DNS administrator prior to a service being moved, in order to minimize disruptions.
Note that if you are planning to change a DNS record its TTL should be lowered far enough before the change is made that old values will already have expired. For example, if the record you plan to change has a TTL of 86400 seconds (24 hours) you should decrease it at least 24 hours before modifying its value.

Why does getaddrinfo sometimes behave differently with "example.com" and "www.example.com"?

This is a code example from MSDN: getaddrinfo.
You can use "baidu.com" and "www.baidu.com" to test.
Because baidu.com and www.baidu.com are different addresses!
www.example.com is registered in DNS with an A type record (or a CNAME, which points to an A record - this is slightly simplified) An A record is a name, in this case www that points to an IP Address 12.34.56.78. (as I'm sure you already know!)
example.com can also have an A record registered (though not a CNAME) this is called the Apex (or naked!) domain. example.com's A record could very well point to 123.45.67.89
A little history
Part of the reason that this came about, is that in the early days of the internet, a server would have a hostname of something like LOCUS.UC.EDU because it can be difficult to know what services LOCUS might provide. you could attach the CNAME FTP.UC.EDU to point to that machine. that way people knew what services it offered. at that point, www was just another service, it had no special place in the collective consciousness. (all of this was happening over the decade or two that the internet was developing!) but you could also quite probably want bob#UC.EDU to work. so UC.EDU needed to be a host name also
In actual fact it started with just the hostname (and host records that got telexed - I do love that fact) - but we'll ignore that for this case.
back to the facts
What usually - should - happen is that there is an A record registered at the Apex and a CNAME registered at www But there is certainly no requirement for this and you can have whatever records you wish at your domain.

Is DNS lookup time affected by the use of subdomains and CNAME?

Is DNS lookup time slowed down by the use of subdomains and CNAME? As I understand it, if a client wants to lookup for example rweb.stat.ucla.edu at least four steps are needed:
[registrar] NS ucla.edu ==> ns2.dns.ucla.edu
[ns2.dns.ucla.edu] NS stat.ucla.edu ==> dns.stat.ucla.edu
[dns.stat.ucla.edu] CNAME rweb.stat.ucla.edu ==> id-86-243.stat.ucla.edu
[dns.stat.ucla.edu] A id-86-243.stat.ucla.edu ==> 128.97.86.243
Does this mean the client has to connect to each of these servers when visiting the page? Or do the DNS servers connect to each other and directly resolve (and cache) rweb.stat.ucla.edu ==> 128.97.86.243? Also it is not clear to me how much work is involved in finding the initial record for the root domain?
First of all, the registrar is never involved in the actual DNS lookup. Registrars (and indeed, registries) are administrative entities outside the scope of the DNS protocol. The actual lookup process looks more like this:
Ask root servers for A of rweb.stat.ucla.edu..
They won't tell you, but they'll point you to servers for edu..
Ask the edu. servers for A of rweb.stat.ucla.edu..
They won't tell you, but they'll point you to servers for ucla.edu.
Ask the ucla.edu servers for A of rweb.stat.ucla.edu..
stat.ucla.edu could be a zone that is delegated to yet another set of nameservers, in which case you'll get a referral answer for the third time.
But let't say it's not.
You get an answer: rweb.stat.ucla.edu. has CNAME id-86-243.stat.ucla.edu.
Now you have to start all over again and look up id-86-243.stat.ucla.edu...
...except that because the target of the CNAME is inside the same zone as the original record (or, in general, inside any zone that happens to be served from the same nameserver), the nameserver will helpfully give you the A record for id-86-243.stat.ucla.edu in the additional section of the DNS response. The resolver will notice this and won't have to run after the A record itself.
Because resolvers cache answers, many queries can be answered from the cache and don't actually have to be asked every time. Especially the first few steps of the query are all likely to be already cached by the resolver, except immediately after it starts up with a cold cache. So the resolver can probably usually start at step 3 (because it remembers what the nameservers for ucla.edu. are from its cache) or at least at step 2 (because it remembers what the nameservers for edu. are) if it doesn't already know the final answer.
So the short answer to your question is yes, using CNAME makes more work for the resolver and makes the resolution process take longer. But in practice it doesn't matter very much because the resolver's cache is so helpful. And if the CNAME's target is in the same zone as the CNAME record itself, it matters even less because of the helpful additional record.

DNS servers pointing to site saying "owner knows site is down"?

When my site goes down, I want to change my registrar DNS settings to
point to (for example):
ns1.this_site_is_down.com
ns2.this_site_is_down.com
ns3.this_site_is_down.com
ns4.this_site_is_down.com
where these nameservers would return a fixed IP with a low TTL for all
queries (or even a CNAME), and a webpage on that IP address would read
something like:
The owner of this website knows it is down and is working to fix
it. Once the site is fixed, you will no longer see this message.
To use this service, set your DNS servers to ... [as above]
Does such a service exist?
I realize this system wouldn't be perfect, but it would be useful.
DNS and "site is offline" messages
discusses creating your own 2nd nameserver to do this, but I'm looking
to do this with an existing service/server.
It doesn't exist for A records or CNAME records (the closest you can get here is using a round robin, but that doesn't solve your issue).
Your looking for a priority tag, which exists in MX only records.
I'm afraid your best option is just on the servers send out a 503 error with a HTML page as the ErrorDocument.

Understanding dig output - will this redirect a browser?

I'm trying to setup a subdomain elstest1 on my example.com domain to redirect to a certain IP. Following some instructions on the web, I created an A DNS record.
Currently, if I do this:
dig elstest1.example.com
I get:
...
...
;; ANSWER SECTION:
elstest1.example.com. 14400 IN A 994.93.999.990
(IP address hidden)
Will going to http://elstest1.example.com take me to the IP address above?
Its not working presently, but that's to be expected because the web server isn't up + I just made the DNS changes, etc. But I want to make sure the above DNS settings are what they need to be.
Yes, your record is correct - that's exactly what an A record would do.
If this entry is brand new it should be visible very quickly across the rest of the internet. So called "negative answers" (i.e. "this domain does not exist") are usually only cached for 15 minutes or so, or at worst a few hours. See RFC 2308.
If the entry previously existed, but only just got this value it might take longer, depending on the (previous) value of the TTL. To be on the safe side it's normally suggested that it takes up to a day or two for all caches to flush the previous entry and then pick up the new one.
First, you've created an alias, not redirect. Alias points to IP, not redirects to it. Actually, all domains are aliases.
Second, changing DNS records takes some time. From 15 minutes to 1-2 days. It happens because there are lots of DNS servers in the world, and they all have to be updated.
Will going to http://elstest1.example.com take me to the IP address above?
Indeed, after your ISPs DNS will update.

Resources