Skip to main content

Inside the Domain Name System

introduce you to the domain name system so imagine this you're on your laptop in your web browser trying to reach example dotnet both your computer and the web server for example net are connected to the Internet now usually your browser will automatically contact the web server for you and request the home page although you know the domain name you have to remember that the internet runs on IP addresses so you cannot just ask hey can you contact example net for me because the internet can't it only knows IP addresses this is where DNS comes in think of it as a gigantic address book that tells you at which IP address any domain name can be contacted to look up an address you ask a special DNS server something like Whois example dotnet and it'll tell you the answer problem solved right not so fast remember that you're not the only one on the Internet there are billions of Internet connected devices that are also trying to look up IP addresses while you're doing the same thing if we had just one measly DNS server to handle all of that traffic it would be overwhelmed with requests immediately even if you added more servers do we really want one organization to manage the entire DNS system that's a lot of power and responsibility I mean if you sabotage this one organization it's bye-bye domain names it also makes the internet more susceptible to government interference which traditionally tends to be a bit of a controversial topic in reality DNS is more of a distributed group effort there's still a hierarchy to it but responsibilities are divided let's start at the top with the root servers there are over 380 root servers worldwide and they're divided into 13 groups root serve no other DNS servers that can help you with specific top-level domain names if you ask who is example dotnet it won't know the answer however it will know which servers are responsible for all the dotnet domains we now have the IP address of a top-level domain name server for dotnet so we can move on to step two we've arrived at the top-level domain layer of the hierarchy now the way this works is that a bunch of servers are responsible for dot-com domains then there's a bunch of servers for org domains there's a bunch for dossier domains and so on and so forth we're going to ask a TLD server for dotnet about example dotnet once again we won't be getting a straight answer from the server yet what it will give us however is a list of IP addresses of servers that are responsible for queries regarding example net and its subdomains we've arrived at the domain name layer now and rest assured this is in fact the final step for the third time already here's that million dollar question again who is example net and yes this server will give us the right IP address the web browser can now try to contact example dot Nats web server using this IP address let's recap what just happened a root server told us which DNS servers are responsible for dotnet domains a top-level domain server told us which DNS servers are responsible for example net and finally one of example Nets DNS servers told us which IP address is associated with example net after people make their way through this maze of DNS servers these are the servers that have the IP address we're looking for they're set to be authoritative servers for example dotnet we've covered the basic idea of DNS but we kind of glanced over the details time now to take a closer look somewhere on this planet a users trying to go to example dotnet in their browser before the browser can contact the web server for example net it needs to find its IP address and to do this it'll perform you guessed it a DNS lookup instead of doing the heavy lifting itself your computer will hand off the request to your local DNS server this server will play the DNS client on your behalf and send you the answer when it's ready the first thing the DNS client will do is contact a root server the client comes pre equipped with a list of root servers as well as their IP addresses if the client didn't have this list of root servers it simply wouldn't know where to start looking the client picks a root server at random and starts looking for the domain name its query will look a little something like this the first field of the query is the domain since we're looking for the IP address of example net that's what we put in our query although the root server won't know the answer it will be able to use this information to refer us to an appropriate top-level domain server the second field is the DNS class this field can have a bunch of values but it is almost always I n which stands for Internet the third field tells the root server which type of result we're looking for we ask for type a because we're looking for the address of a top-level domain server the root server will then prepare a response here's what it's sent to us as we expect it the root server refers us to the top level domain servers for dotnet the first section contains general information about these servers this is the time to live which indicates how long the information remains valid the value is specified in seconds so this information is good for two more days field number three is the DNS class which once again is I an for Internet field number force the record type the NS stands for names erver this indicates that this record points to a DNS server that is authoritative about hosts in the.net domain this is the root servers way of saying I don't know anything about dotnet domains but go ask that guy the last field contains the domain name for each of these name servers now with the domain name alone we can't reach these DNS servers because we need IP addresses this is where the additional section comes in also called glue records these tell us where to find the domain names that were previously mentioned they're not always present but sometimes they're necessary like if we didn't have this information we'd have to look up mg TLD servers NAT first but since we don't have the IP address of any TLD server Fernet we can look up dotnet domains so we're stuck in a loop this is why the glue records are absolutely necessary here using the IP address we just obtained we can contact a TLD server for dotnet domains now although our query remains the same the response will be different servers at the TLD layer have more specific information about our target so they'll bring us closer to the answer the server crunches some numbers and sends back the following list the authority section reports to name servers for example dotnet a IANA server's net and B dot I Anna - servers dotnet we'll just go with the first name server and retrieve its IP address from its glue record note that there are actually two glue records for this name server the second one is a quadruple a record from this record we can obtain its IP version 6 address we'll just stick to IP version 4 for now on to the next DNS server we will reuse the same query but the response will look a little different this time let's see what we have here for the first time there will be an answer section from there we learned that example is at 93.1 84.2 16.1 19 the authority section tells us which name servers are authoritative for this domain but that information is no longer relevant to us the local DNS server can now send back the information to the computer that requested it that information goes to the operating system which now knows where to find example dotnet then the browser can contact the IP address request the web page and we're done a couple more facts about DNS servers one IP address can house multiple physical servers for example Facebook's name servers only have two IP addresses but that doesn't mean that they only have two physical name servers to serve everyone worldwide by spreading incoming requests across multiple servers they prevent them from getting overloaded this is true for servers in general by the way whether you're talking about web servers or mail servers or DNS servers one name server can be authoritative for multiple domains for example the organization behind Wikipedia uses the same name servers for multiple domains including wikipedia.org wikimedia org and wikibooks org another example of this is when you register a domain name in most cases your domain name will use the name server of the company that hosts your website for you before I wrap this up I want to share some more useful DNS features with you the first one is caching remember when we got that answer back from the authoritative nameserver well as you may recall the second field in the record indicates how long the information remains valid the server specified a time to live of little more than 86,000 seconds or as normal people would probably say 24 hours instead of looking up the answer every time we need it we can save this piece of information until the next day this eases the load the nameservers but it also saves us precious waiting time DNS has support for both iterative and recursive queries iterative queries look like this you consult a root server that will refer you to a TLD server the TLD server will refer you to an authoritative name server that third server should be able to give you the answer iterative queries are all about actively seeking out all the information yourself now recursive queries on the other hand are structured a little differently first you ask a server a question if they don't have an immediate answer for you they'll go ask someone else in your name that server in its turn may ask another server and finally the answer comes all the way back to you in a recursive query servers will try to gather information from other servers if they don't have the answer themselves whereas in an iterative query the client has to piece together all the information on its own in real life a mix of iterative and recursive queries is used the most common scenario is that your computer will send a recursive query to your local DNS server this local DNS server will then handle the query iteratively piecing together information it gathers from root servers TLD servers and authoritative name servers once the local DNS server knows the IP address it can respond to the computer's recursive query our introduction to DNS ends here but there's lots more to learn DNS has some security flaws so hackers can abuse it to redirect people from their bank's website to a malicious site and you won't be able to tell by looking at your browser's address bar if you want to learn more about this and get a little too paranoid look up DNS spoofing DNS also plays a role in the routing of emails if you want to find out how that works look up MX records the MX stands for mail exchange and with that we wrap up another episode of Peter explains tack thanks for watching see you next time

Comments

Popular posts from this blog

Port Forwarding Explained

what is port forwarding now maybe you've heard about it but you weren't exactly sure what it was or how it works so basically port forwarding allows computers over the Internet to connect to a specific computer or service within a private network it's basically making your computer accessible over the Internet even though you're behind a router so for example let's say a friend of yours at their home wants to remotely control your computer at your home using a service such as remote desktop connection now remote desktop connection is a service built into Microsoft Windows that enables you to connect to another computer running Microsoft Windows and then once you're connected to the remote computer you can use that computers programs and files just as if you were sitting in front of it so now your friend is ready to connect to your computer so we starts up the remote desktop connection and sends the request to your public IP address with a specific port number no

32 bit vs 64 bit

computer hardware and software can come in 32 or 64-bit versions the difference between a 32-bit and a 64-bit is the way that it handles memory the bit size refers to the memory that it can address a 32-bit system can reference 2 to the 32nd power bytes of memory which equals to about 4 gigabytes however a 64-bit system can reference 2 to the 64th power bytes of memory which equals to about 16 exabytes which is 4 billion times more memory than a 32-bit now that number is so huge that it's virtually unlimited because we will never need to use that amount of memory so in a computer in order for data or a program to run it needs to be loaded into Ram first so the data is stored on the slower hard drive and from the hard drive it's loaded into the faster Ram and once it's loaded into Ram the CPU can now access the data or run the program now in a 32-bit system since the maximum amount of memory that it can support is 4 gigabytes it may not be enough to hold all the data that th

NAT Explained - Network Address Translation

nat stands for network address translation and this is a service that is used in routers and its purpose is to translate a set of IP addresses to another set of IP addresses and the reason for having the nat service is to help preserve the limited amount of IP version for public IP addresses that we have available around the world when the IP version 4 address was created engineers didn't realize how big the internet will become because even though there were over 4 billion IP version 4 addresses available the engineers thought that that would be enough but obviously they were wrong so in order to prevent a shortage of public IP version 4 addresses engineers developed private IP addresses and network address translation now there are two different types of IP version 4 addresses there's public and there is private public IP addresses are publicly registered on the Internet you have to have a public IP address if you want to go on the internet and there are approximately 4 billi