DNS in Linux for the Absolute Beginners!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we get introduced to dns in linux for the absolute beginners we will discuss the basic concepts and view some commands that will help us explore dns configuration on hosts specifically linuxos at the end of this section you will go through a practice test where you're given a set of challenges related to dns and are asked to solve them on a live practical hands-on lab environment right in your browser we have two computers a and b both part of the same network and they've been assigned with ip addresses 192.168.1. and 1.11 you're able to ping one computer from the other using the other computer's ip address you know that system b has database services on them so instead of having to remember the ip address of the system b you decide to give it a name db going forward you would like to ping system b using the name db instead of its ip address if you try to ping db now you would see that host a is unaware of a host named db so how do you fix that basically you want to tell system a that system b at ip address 192.168.1.11 has a name db you want to tell system a that when i say db i mean the ip 182 168 1.11 you can do that by adding an entry into the hc hosts file on system a mention the ip address and the name you want your host to see system b as we told system a that the ip at 192.168.1.11 is a host named db pings to db now get sent to the correct ip and are successful now there is an important point to note here we told system a that the ip at 192.168.1.11 is a host named db host a takes that for granted whatever we put in the etsy host file is the source of truth for host a but that need not be the truth host a does not check to make sure if system b's actual name is db for instance running a host name command on system b reveals that it is named host 2 but host a doesn't care it goes by what's in the hosts file you can even full system a to believing that system b is google just add an entry into the host file with an ip mapping to www.google.com then ping google and you will get a response from system b so we have two names pointing to the same system one as db and another as google and we can use either names to reach system b you can have as many names as you want for as many servers as you want in the etsy hosts file every time we reference another host by its name from host a through a pin command or ssh command or through any of the applications or tools within this system it looks into its etsy host file to find out the ip address of that host translating hostname to ip address this way is known as name resolution within a small network of few systems you can easily get away with the entries in the hc hosts file on each system i specify which are the other systems in the environment and that's how it was done in the past until the environment grew and these files got filled with too many entries and managing these became too hard if one of the servers ip changed you would need to modify the entries in all of these hosts and that's where we decided to move all these entries into a single server who will manage it centrally we call that our dns server and then we point all hosts to look up that server if they need to resolve the host name to an ip address instead of its own etsy host files so how do we do that how do we point our host to a dns server our dns server has the ip192 168 1.100 every host has a dns resolution configuration file at etsyresolv.conf you add an entry into it specifying the address of the dns server we say name server and point it to 182.168.1.100 and that should be it once this is configured on all of your host every time a host comes up across a hostname that it does not know about it looks lit up from the dns server if the ip of any of the host was to change simply update the dns server and all hosts should resolve the new ip address going forward you no longer need any entries in the hc hosts file in any of the hosts but that does not mean you can't have entries in hosts file you still can for example say you were to provision a test server for your own needs you don't think others would need to resolve the server by its name so it need not be added to the dns server in that case you can add an entry into your host's hc host file to resolve this server you can now resolve the server however no other system will be able to do that so a system is able to use host name to ip mapping from the etsy host file locally as well as from a remote dns server what if you have an entry in both places one in your etsy host file and another in dns i have an entry in my local file set to 192.168.1.115 and someone added an entry for the same host to 192.168.1.116 on the dns server in that case the host first looks in the local hc host file and then looks at the name server so if it finds the entry in the local etsy hosts file it uses that if not it looks for that host in the dns server but that order can be changed the order is defined by an entry in the file at c ns switch.conf the line with the host entry as you can see the order is first files and then followed by dns files refers to etsy host file and dns refers to the dns server so for every host name the host first looks into the etsy hosts file and if it cannot find it there it then looks at the dns server this order can be modified by editing this entry in the file as per this order our host would resolve the test server to 192.168.1.115 if you try to ping a server that is not in either list for example i try and ping www.facebook.com i don't have facebook.com in my etsy host file and i don't have it in my dns server either so in that case it will fail you can add another entry into your resolve.conf file to point to a name server that knows facebook for example 8.8.8.8 is a common well-known public name server available on the internet hosted by google that knows about all websites on the internet you can have multiple name servers like this configured on your host but then you will have to configure that on all your hosts in their network you already have a name server within your network configured on all the hosts so in that case you can configure the dns server itself to forward any unknown host names to the public name server on the internet you should now be able to ping external sites such as facebook.com until now we've been just trying to read systems with their names like web db nfs etc but we just tried to ping facebook at www.facebook.com what is this name with your www.and.com at the end it's called a domain name and it is how ips translate to names that we can remember on the public internet just like how we did for our hosts now the reason they are in this format separated by dots is to group like things together the last portion of the domain name the dot coms the dot nets dot edu dot org etc are the top level domains they represent the intent of the website dot com for commercial or general purpose dot net for network dot edu for educational organizations and dot org for non-profit organizations let's look at one in particular in google's case the dot is the root that's where everything starts dot com is a top level domain google is the domain name assigned to google and www is a sub-domain the sub-domains help in further grouping things together under google for example google's map service is available at maps.google.com so maps is a subdomain google's storage service is available at drive.google.com mobile apps are available at apps.google.com google's email service are available at mail.google.com you can further divide each of these into as many subdomains based on your needs so you begin to see a tree structure forming when you try to reach any of these domain names say apps.google.com from within your organization your request first hits your organization's internal dns server it doesn't know who apps or google is so it forwards your request to the internet on the internet the ip address of the server serving apps.google.com may be resolved with the help of multiple dns servers a root dns server looks at your request and points you to a dns serverserving.com a.com dns server looks at your request and forwards you to google and google's dns server provides you the ip of the server serving the app's applications in order to speed up all future results your organization's dns server may choose to cache this ip for a period of time typically few seconds up to few minutes that way it doesn't have to go through the whole process again each time so that was out in the public what about your organization your organization can have a similar structure too for example your organization could be called as mycompany.com and have multiple sub-domains for each purpose the www for external facing website mail.mycompany.com for accessing your organization's mail drive for accessing storage paid or company.com for accessing the payroll application hr for accessing hr application etc all of these are configured in your organization's internal dns server the reason we discussed all of these is to understand another entry in the etsy resolve.conf file remember this is the file where we configured the dns server to be used for our host with that we were able to resolve servers in your organization with just their names like web we have now introduced more standard domain names like web.mycompany.com or db.mycompany.com etc now when you ping web you can no longer get a response of course this is because we're trying to ping web but there is no record for by the name web on my dns server instead it is web.mycompany.com so you have to use web.mycompany.com now i can understand if someone outside our company wants to access our web server he would have to use web.mycompany.com but within our company your own company you want to simply address the web server by its first name web just like how you address other members in your family simply by their first names which is not the case when someone outside your family addresses them using their full names so what do you do to configure web to resolve my web.mycompany.com you want to say when i say web i mean web.mycompany.com for that you make an entry into your host's etsyresult.com file called search and specify the domain name you want to append next time you try to ping web you will see it actually tries web.mycompany.com now your host is intelligent enough to exclude the search domain if you specified a domain in your query like this you may also provide additional search domains like this so it would mean when i say web i mean web.mycompany.com or web.prod.mycompany.com so your host would try searching all of these domain names when you look for a hostname finally a word about record types so how are the records stored in the dns server we know that it stores ip to host names that's known as a records storing ipv6 to host names is known as quad era codes mapping one name to another name is called cname records for example you may have multiple aliases for the same application like a food delivery service may also be reached at eat or hungry that's where a cname record is used named to name mapping there are many more but that's all we're going to look at for now now ping may not always be the right tool to test dns resolution there are a few other tools as well such as ns lookup you can use ns lookup to query a hostname from a dns server but remember nslookup does not consider the entries in the local etsy hosts file so if you add an entry into the local sc host file for your web application and if you try to do an ns lookup for that web application it is not going to find it the entry for your web application has to be present in your dns server ns lookup only queries the dns server the same goes with dig dig is another useful tool to test dns name resolution it returns more details in a similar form as is stored on the server in the upcoming practice exercises section you will practice viewing configuring and troubleshooting dns in a lab environment on actual systems through some fun and challenging exercises well that's it for this lecture
Info
Channel: KodeKloud
Views: 32,691
Rating: 4.9490743 out of 5
Keywords: DevOps, DevOps for beginners, Linux, Linux for beginners, dns server, DNS Linux, dns server problem, devops course, devops online classes, kodekloud devops, dns configuration, dns configuration in linux, dns practicals
Id: 9nCIjLlLVzY
Channel Id: undefined
Length: 14min 25sec (865 seconds)
Published: Mon Aug 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.