Hack Like a Pro: Linux Basics for the Aspiring Hacker, Part 17 (Client DNS) « Null Byte :: WonderHowTo

Welcome back, my aspiring hackers!Domain Name System (DNS) is one of those things we seldom think about unless it doesn't work. Then, it can be very frustrating when we attempt to navigate to a website and we get that frustrating error message.DNS enables us to type in a domain name in our browser, such aswonderhowto.com, rather than a numerical IP address of the site we are trying to reach. In its simplest form, DNS simply translates domain names into IP addresses, making our lives much simpler. Can you imagine trying to remember all of the IP addresses of the hundreds of sites you visit daily?For most of us working inLinux, we have two DNS concerns. First, as a client we need to access DNS services to translate our domain names into IP addresses. Second, as a server we need to provide DNS services. Here, I will limit myself to managing DNS from aclientperspective and leave providing DNS services to another tutorial.It's important to remind you here that in Linux, nearly everything is a file, and configuration is usually through the editing of a simple text file. This rule certainly applies to DNS.Step 1: /Etc/HostsIn Linux, we have what is referred to as a "hosts" file. It's found where nearly all the configuration files are in the/etcdirectory, so/etc/hosts. This hosts file acts similarly to DNS, but it is static. This means that it's not updated like DNS is. The hosts file is the simplest and fastest method for mapping hostnames to IP addresses, but also the most time consuming.Let's look at the/etc/hostsfile in BackTrack. Type:bt > kwrite /etc/hostsThis will open the following file. Note that the default configuration in BackTrack has just the entries for localhost at 127.0.0.1 and then some notes on IPv6.We could add additional lines to this file to provide simple name resolution services. If we wanted to resolve the word "hacker" to a system on our internal network, we could simply add a line to our hosts file, such as:192.168.116.7 hackerWhen we save our/etc/hostsand type "hacker" into our browser, we will be directed to the IP 192.168.117.7.Step 2: /Etc/resolv.confThe primary file for pointing your system to a DNS server is the/etc/resolv.conf. Please note that the file name is similar to the English word resolve, but without the "e" at the end. It is here that we tell our system where to look for DNS services.Let's open it with kwrite.bt> kwrite /etc/resolv.confWhen we hit ENTER, kwrite opens the file as below.The format of this file is:nameserver IPaddressAs you can see, my/etc/resolv.confis pointing to a DNS server on my local network, 192.168.116.1. I can change this to point to any public DNS server by simply editing and deleting the internal IP address with that of a public DNS server, such as Comcast's at 75.75.75.75.If you have an internal DNS server, you would probably prefer to use it as it will give you faster responses, but people very often will put inbothan internal DNS server first and then a public DNS server, second. In this way, your system will check the internal DNS server first and if it doesn't find a listing on that DNS server, it will then progress to the public IP server and will hopefully find it there.I've edited my/etc/resolv.confto include the public DNS server for Comcast at 75.75.75.75. All I do now isSavethe/etc/resolv.conffile and my system will look to my internal DNS server first and then to the Comcast public DNS server, if it doesn't find the name in my private DNS server.Step 3: /Etc/nsswitch.confLastly, we have the/etc/nsswitch.conffile. Here is where we tell our system the order of where to look for name resolution. We have opened it with kwrite and have displayed it below.Note the line that begins with "hosts". This line line tells the system the order of which to search for name resolution. The system will try each in order until it finds the name it is looking for. Let's examine each separately.files- Refers to the/etc/hostsfile. Generally, we want the system to look here first as it is the fastest.mdns4_minimal- This is a legacy multi-cast DNS protocol.dns- This tells the system to go to the/etc/resolv.conffor find a DNS server.[NOTFOUND=return]- This indicates that if themdns_minimalsearch returns NOTFOUND, this should be treated as authoritative and the search ceases.mdns4- This is multicast DNS, a relatively rare DNS-like protocol for small networks without DNS servers.Stay tuned for moreLinux Basics for the Aspiring Hacker.Want to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseWwwimage via ShutterstockRelatedHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 6 (Networking Basics)News:How to Study for the White Hat Hacker Associate Certification (CWA)How To:The Essential Skills to Becoming a Master HackerHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 11 (Apache Web Servers)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 15 (Creating a Secure Tunnel to MySQL)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)Hack Like a Pro:Digital Forensics for the Aspiring Hacker, Part 2 (Network Forensics)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 22 (Samba)Hack Like a Pro:How to Spoof DNS on a LAN to Redirect Traffic to Your Fake WebsiteHow to Hack Like a Pro:Getting Started with MetasploitHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 12 (Loadable Kernel Modules)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 13 (Mounting Drives & Devices)How To:Linux Basics for the Aspiring Hacker: Configuring ApacheHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 2 (Creating Directories & Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 21 (GRUB Bootloader)Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 4 (Armitage)Hack Like a Pro:Abusing DNS for ReconnaissanceHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 9 (Managing Environmental Variables)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 5 (Installing New Software)Goodnight Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 1 - Legal Hacker TrainingHow To:Secure Your Computer with Norton DNSCommunity Byte:HackThisSite Walkthrough, Part 2 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 7 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingHack Like a Pro:Hacking Samba on Ubuntu and Installing the MeterpreterCommunity Byte:HackThisSite, Realistic 2 - Real Hacking SimulationsCommunity Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 5 - Legal Hacker TrainingCommunity Byte:HackThisSite, Realistic 3 - Real Hacking SimulationsNews:Quiksilver Pro El Salvador:Goodnight Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingThe Ultimate Guide:Diagnosing & Fixing Connection Issues, Part IIGoodnight Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 4 - Legal Hacker Training