How are nameserver addresses resolved? - ip

So if I try to navigate to google.com and I don't have the ip address cached, my browser will attempt to contact google's nameservers. If the nameserver is ns1.google.com, how exactly is the nameserver's ip address resolved?

Your browser doesn't contact Google's nameservers directly (unless you work there), instead it attempts to contact your organization's DNS servers (as defined by your ISP or network admins) to resolve google.com, and those DNS servers work from there, working their way up the DNS hierarchy to the DNS root servers if necessary.
How do the DNS root servers know the IP addresses for Google's servers? They don't. They look at the ".com" in the domain name, and forward the request to the ".com" TLD servers, currently managed by Verisign. Verisign notes the ".google" part of the domain name, and forwards the request to Google's DNS servers.
How does Verisign know the IP address of Google's DNS servers? Google tells them by registering resource DNS records with them when the IP address changes.
Of course, caching is used up and down all levels of this tree.
See http://www.howstuffworks.com/dns.htm for more info.

Related

Google router IP vs Google public IP

I am trying to get the big picture although my primary domain is not networking.
Some question's narrowed down for which I'm not getting enough/proper answers online
Is the IP that is resolved by the DNS server when I hit www.google.com is same as any of the Google router's Gateway IP?
Do bigger companies like Amazon do port forwarding?
If point 2 is true, I suppose they must be port forwarding with only 443 (https) port which means, to use multiple static IP across different data centers, they need to have that many routers. So, if they have N static IP address which resolves to a website, then they must be having N routers right? Is this a fair assumption?
A gateway IP refers to a device on a network which sends local
network traffic to other networks. it sits between you and internet,or other network . its like a watchman.
Question 1 : google.com has multiple ip addresses lets say then , Yes, that is possible, and will need to be two A records. This is called Round-Robin DNS. Clients will semi-randomly use one of the two addresses.
question2: yes port forwarding happens more often than we think. ALL VPC's (virtual private clouds like AWS , GCP , Azure etc) use this as they dont want to expose servers/internal resources to the internet.
depending on the port number , particular service is exposed to requesting client. lets say we want to make a website public , then we explicitly expose port 80(http) 443(https) so that web crawlers and users can see them.
Port forwarding, sometimes called port mapping, allows computers or
services in private networks to connect over the internet with other
public or private computers or services.
google https://www.google.com:444/ wont work because they did not expose port 444 on their cloud router
but https://www.google.com:443/ will work because the server corresponding to google.com has explicitly left it open.
How IP is resolved:
Step 1 - Send a Request to Resolve a Domain Name
When you type www.google.com into a browser, in order to load the webpage, your computer asks for the IP address. Computers do not know in advance where they can find the necessary information, so they try searching through the DNS cache and for available external source. proceed from lower level caches to root/main servers.
Step 2+3 - Try to resolve an IP Locally
Before going externally, your computer loads the local DNS cache database to see if you already requested the IP for that domain name. Every computer has a temporary cache with the most recent DNS requests and attempts to connect to online sources. if required record is present locally its called "CACHE HIT" and query stops.
However A computer’s local DNS cache database does not always contain the necessary data to resolve a domain name this is called a "CACHE MISS" . In that case, the request goes further to your Internet Service Provider (ISP) and its DNS server.
Step 4 - ISPs Ask Outside DNS Servers to Provide an IP Address iff Cache miss
ISP DNS resolvers are configured to ask other DNS servers for correct IP address mapping until they can provide data back to the requester. These are iterative DNS queries.
When a DNS client sends such a request, the first responding server does not provide the needed IP address. Instead, it directs the request to another server that is lower in the DNS hierarchy, and that one to another until the IP address is fully resolved. There are a few stops in this process.
hierarchy looks like this (just for reference):
Root domain nameservers. Root servers themselves do not map IP addresses to domain names. Instead, they hold the information about all top-level domain (TLD) nameservers and point to their location. TLD is the rightmost section of a domain name... Root servers are critical since they are the first stop for all DNS lookup requests.
TLD nameservers. These servers contain the data for second-level domains, such as ‘phoenixnap’ in phoenixnap.com. Previously, the root server pointed to the location of the TLD server. Then, the TLD server needs to direct the request toward the server that contains the necessary data for the website we are trying to reach.
Authoritative nameserver. Authoritative servers are the final destination for DNS lookup requests. They provide the website’s IP address back to the recursive DNS servers. If the site has subdomains, the local DNS server will keep sending requests to the authoritative server until it finally resolves the IP address.
Step 5 - Receive the IP Address
Once the ISP’s recursive DNS server obtains the IP address by sending multiple iterative DNS queries, it finally returns it to your computer. The record for this request now stays cached on the hard drive. The browser can then fetch this IP from the cache and connect it to the website’s server.
ALL this happens in less than 1 second, most of the times. if you just registered a new domain it might take few hours to propagate this DNS cache globally hence newly registered websites do not show up sometimes.
About companies owning multiple IPs
Big companies have pool of IPs reserved for example 123.234.xxx.xxx which means a company has reserved 255*255 ips. they are mapped on a VPC(virtual private cloud)
and accessible vis a subnet masking and CIDR feature, like your EC2 instances on AWS
Is the IP that is resolved by the DNS server when I hit www.google.com is same as any of the Google router's Gateway IP?
For sure it should, but it is mostly a Google management question that only they will be able to answer right. The thing is that we must understand how DNS query's work for this.
Let's take a look of it:
Device A requests the IP address through a DNS query of the device B.
To do this, it uses the network port 53 (Domain) on which it will ask, depending on which DNS server is being used at the time, which is usually the home router. Then the router will ask the ISP's DNS server, which will respond with a cached response, or the query with another server on top of it if it does not have one; All this process is followed until a reliable cache response is reached or until the authoritative response server is reached, that is, the name server that manages the domain in question.
Only the authoritative response server contains the reliable information of which IP of the domain which is going to be reached.
I suppose that within Google's servers and its network they use Google's own DNS servers, which are 8.8.8.8 and 8.8.4.4 where the DNS records are obtained and consulted by caching from many sites.
In general terms Google's IP will change depending on where you are, I made a DIG query to Google's authoritative servers, however, I received a result based on location to improve the route and loading time of the site which was 142.250.73.238.
Do bigger companies like Amazon do port forwarding?
Yes, they do. To handle queries with load balancers or similar and even for caching dns requests.
If point 2 is true, I suppose they must be port forwarding with only 443 (https) port which means, to use multiple static IP across different data centers, they need to have that many routers. So, if they have N static IP address which resolves to a website, then they must be having N routers right? Is this a fair assumption?
This has multiple answers. By the way, they actually can do a secure DNS query.
if they have N static IP address which resolves to a website, then they must be having N routers right?
They don't have to, but if they want to they can.
"Is this a fair assumption?"
No, the IP's doesn't depend on a router, the router only routes to a computer/server which can have multiple IP's. By the other hand, each thing (computer, server, etc... must have an IP which can be also a WAN IP).

How to determine the IP of the server to which a client is connecting to? Is it possible?

I am now just starting to understand Httpcontexts and server side logic. Total beginner.
I have understood how to read the http requests from a client and get the remote IP etc.
I came across the hostname property.
I believe hostname and domain are completely different.
My undersanding is that stackoverflow is the domain name.
Given its widespread reach, stackoverflow can have multiple servers and hence multiple ip addresses.
So is there a way to determine to which server a client is requesting to in asp.net core 2.0?
You are correct that stackoverflow.com is a domain name. A domain name points to an IP address. That's called DNS. stackoverflow.com points to one single IP address not multiple. There's probably a load balancer at that IP address which then points you to an available server, which is internal you can't see that, but that's another story.
If you ping stackoverflow.com you get:
The whole point of DNS is to not use IP address but a domain name.
I'm not sure why you would want to see the IP. Maybe this stackoverflow question can help: Resolve HostName to IP

Why is a DNS server needed when setting up a static ip

So I am setting up my at home server, and I am setting up my static ip address. I noticed that I need to input my ISP's DNS servers. Why? It does not seem to list a DNS server for DHCP. If I truly have a static ip address (which RCN, my ISP, claims that I have), then why do I need a DNS? What is being resolved at the DNS? Thank you in advance.
As you said you need DNS server/s to resolve hostnames to IP addresses. If you do not use a DNS server your PC/router wouldn't know what's the IP of the sites you want to visit (unless you hardcode all the addresses, of course). This are resolving/recursive DNS servers, not authoritative DNS servers.
When you do not use DHCP these servers are not automatically obtained, that is why you need to manually put them.

Ip address DNS and Domains

I'm a little confused about IP addresses.
I know that every web domain has an ip address.
Does the IP address represent the physical machine / host the website files are stored on?
Therefore when DNS lookup is performed, the domain's IP address is returned to the client. The client then uses this ip to contact the server that the web files reside on.
Is my understanding correct?
Many thanks
You are correct.
It is kind of like how some companies may say Dial PIZZAHUT instead of saying, Dial 74992488. PIZZAHUT is easier to remember, but you actually are dialling the number.
You're talking about HTTP protocol. Yes, FQDN (web domain) is resolved to IP address by DNS server. Client will connect to server IP address. Since you're probably using HTTP 1.1, HTTP request will contain also FQDN. This information is used by web server to perform several checks, like SSL certificate validation or Virtualhost management (several domains on a single IP address).

IP Addresses for Domains and their Subdomains the same?

I would like to know. When a domain example.com has an IP address: 41.72.111.222, would any of its subdomains (sub.example.com, mail.example.com etc) have the same IP address listed in the DNS records? Or does it work like this: A request is sent from the browser to the DNS server for sub.example.com. The DNS server returns the IP address for example.com, and the split/differentiation is made when the request for sub.example.com hits the example.com host server? So the host server basically know what to do with sub.example.com and not the DNS server?
It can kind of be a combination of both. Ultimately, though, the decisions are made based on what you set your DNS settings to be. Your host (or hosts) will then get whatever traffic you determined they should get in your DNS settings.
So for example...
You can set your DNS settings to take [anything].example.com and always direct that to your server. You would do this by adding a wildcard entry to your DNS subdomains. Wildcard entries use a * symbol to mean "anything". You would then need to configure your server to know what to do with all these different potential subdomains it could be receiving.
At the same time, you can set specific subdomains to go to other hosts. For example, if you wanted mail.example.com to go to some other webmail host, you would set up in your DNS the subdomain "mail" and have that traffic redirected to wherever you were hosting your webmail.

Resources