{"id":1610,"date":"2012-01-08T10:45:52","date_gmt":"2012-01-08T02:45:52","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1610"},"modified":"2023-09-18T16:28:56","modified_gmt":"2023-09-18T16:28:56","slug":"how-to-install-nslookup-on-centos","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-nslookup-on-centos\/","title":{"rendered":"How to Install nslookup on CentOS"},"content":{"rendered":"<p>The nslookup command-line tool is an essential utility for web administrators and IT professionals. It allows you to query the Domain Name System (DNS), which is the system that translates human-friendly domain names like &#8220;example.com&#8221; into IP addresses that computers use to communicate. This can be particularly useful when you&#8217;re trying to diagnose network issues or troubleshoot DNS-related problems.<\/p>\n<p>For instance, if a website isn&#8217;t loading, you can use nslookup to check if the DNS for that domain is functioning correctly. If nslookup returns the correct IP address, but you still can&#8217;t reach the website, the problem might be with your network or the website&#8217;s server.<\/p>\n<p>On <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-centos-beginners-guide-centos-linux-distro\/\">CentOS<\/a>, a popular Linux distribution often used for servers, nslookup isn&#8217;t included by default. Instead, it&#8217;s part of the bind-utils package, which contains a collection of utilities for working with DNS.<\/p>\n<p>This guide provides step-by-step instructions on how to install nslookup on CentOS. It will walk you through the process of installing the bind-utils package on CentOS, equipping your system with nslookup and a suite of other DNS tools. This setup will enhance your ability to manage and troubleshoot your server&#8217;s DNS.<\/p>\n<h2>Step 1: Update Your System<\/h2>\n<p>Before installing new software, it\u2019s a good practice to update your CentOS system to ensure you have the latest packages and security updates. Use the following command:<\/p>\n<pre>\r\nsudo yum update -y\r\n<\/pre>\n<h2>Step 2: Install the bind-utils Package<\/h2>\n<pre>\r\nnslookup\r\n-bash: nslookup: command not found\r\n<\/pre>\n<p>To install nslookup on CentOS, you\u2019ll need to install the bind-utils package using the following command:<\/p>\n<pre>\r\nsudo yum install -y bind-utils\r\n<\/pre>\n<p>This command installs nslookup along with other utilities, such as dig and host, which can also be useful for DNS-related tasks.<\/p>\n<pre>\r\nyum install bind-utils\r\n\r\nLoaded plugins: fastestmirror\r\nDetermining fastest mirrors\r\nCentOS6.2-Repository                                                  | 1.3 kB     00:00 ...\r\nCentOS6.2-Repository\/primary                                          | 1.2 MB     00:00 ...\r\nCentOS6.2-Repository                                                               3042\/3042\r\nSetting up Install Process\r\nResolving Dependencies\r\n--> Running transaction check\r\n---> Package bind-utils.i686 32:9.7.3-8.P3.el6 will be installed\r\n--> Processing Dependency: bind-libs = 32:9.7.3-8.P3.el6 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: liblwres.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisccfg.so.62 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisccc.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisc.so.62 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libdns.so.69 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libbind9.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Running transaction check\r\n---> Package bind-libs.i686 32:9.7.3-8.P3.el6 will be installed\r\n--> Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n=============================================================================================\r\n Package           Arch        Version                     Repository                   Size\r\n=============================================================================================\r\nInstalling:\r\n bind-utils        i686        32:9.7.3-8.P3.el6           CentOS6.2-Repository        177 k\r\nInstalling for dependencies:\r\n bind-libs         i686        32:9.7.3-8.P3.el6           CentOS6.2-Repository        849 k\r\n\r\nTransaction Summary\r\n=============================================================================================\r\nInstall       2 Package(s)\r\n\r\nTotal download size: 1.0 M\r\nInstalled size: 2.6 M\r\nIs this ok [y\/N]: n\r\nExiting on user Command\r\n[root@centos6 ~]# nslookup\r\n-bash: nslookup: command not found\r\n[root@centos6 ~]# yum install bind-utils\r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\nSetting up Install Process\r\nResolving Dependencies\r\n--> Running transaction check\r\n---> Package bind-utils.i686 32:9.7.3-8.P3.el6 will be installed\r\n--> Processing Dependency: bind-libs = 32:9.7.3-8.P3.el6 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: liblwres.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisccfg.so.62 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisccc.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libisc.so.62 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libdns.so.69 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Processing Dependency: libbind9.so.60 for package: 32:bind-utils-9.7.3-8.P3.el6.i686\r\n--> Running transaction check\r\n---> Package bind-libs.i686 32:9.7.3-8.P3.el6 will be installed\r\n--> Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n=============================================================================================\r\n Package           Arch        Version                     Repository                   Size\r\n=============================================================================================\r\nInstalling:\r\n bind-utils        i686        32:9.7.3-8.P3.el6           CentOS6.2-Repository        177 k\r\nInstalling for dependencies:\r\n bind-libs         i686        32:9.7.3-8.P3.el6           CentOS6.2-Repository        849 k\r\n\r\nTransaction Summary\r\n=============================================================================================\r\nInstall       2 Package(s)\r\n\r\nTotal download size: 1.0 M\r\nInstalled size: 2.6 M\r\nIs this ok [y\/N]: y\r\nDownloading Packages:\r\n---------------------------------------------------------------------------------------------\r\nTotal                                                        6.1 MB\/s | 1.0 MB     00:00\r\nRunning rpm_check_debug\r\nRunning Transaction Test\r\nTransaction Test Succeeded\r\nRunning Transaction\r\n  Installing : 32:bind-libs-9.7.3-8.P3.el6.i686                                          1\/2\r\n  Installing : 32:bind-utils-9.7.3-8.P3.el6.i686                                         2\/2\r\n\r\nInstalled:\r\n  bind-utils.i686 32:9.7.3-8.P3.el6\r\n\r\nDependency Installed:\r\n  bind-libs.i686 32:9.7.3-8.P3.el6\r\n\r\nComplete!\r\n<\/pre>\n<h2>Step 3: Verify the Installation<\/h2>\n<p>After the installation is complete, you can verify that nslookup is installed and functioning correctly by running a simple query:<\/p>\n<pre>nslookup example.com<\/pre>\n<p>Replace example.com with the domain name you want to query. The output should display the DNS information for the specified domain.<\/p>\n<p>For example, google.com:<\/p>\n<pre>\r\nnslookup www.google.com\r\n\r\nServer:         198.18.18.18\r\nAddress:        198.18.18.18#53\r\n\r\nNon-authoritative answer:\r\nName:   www.google.com\r\nAddress: 64.233.164.105\r\nName:   www.google.com\r\nAddress: 64.233.164.99\r\nName:   www.google.com\r\nAddress: 64.233.164.104\r\nName:   www.google.com\r\nAddress: 64.233.164.147\r\nName:   www.google.com\r\nAddress: 64.233.164.106\r\nName:   www.google.com\r\nAddress: 64.233.164.103\r\nName:   www.google.com\r\nAddress: 2a00:1450:4010:c07::67\r\nName:   www.google.com\r\nAddress: 2a00:1450:4010:c07::69\r\nName:   www.google.com\r\nAddress: 2a00:1450:4010:c07::6a\r\nName:   www.google.com\r\nAddress: 2a00:1450:4010:c07::93\r\n<\/pre>\n<p>The nslookup utility is a versatile tool employed for a range of tasks associated with DNS. It can be used to verify the mapping of domain names to IP addresses, diagnose website loading issues, and ensure DNS changes have been propagated correctly. This makes nslookup an must-have tool for server administrators for DNS querying and troubleshooting.<\/p>\n<h2>Alternative Installations<\/h2>\n<p>There are alternative ways to install nslookup on CentOS, although the most common method is through the bind-utils package as previously described. Here are a couple of alternatives:<\/p>\n<h3>1. Using the dnf Package Manager<\/h3>\n<p>If you&#8217;re using CentOS 8 or later, you might be using the dnf package manager instead of yum. The command to install bind-utils with dnf is very similar to the yum command:<\/p>\n<pre>\r\nsudo dnf install -y bind-utils\r\n<\/pre>\n<h3>2. Compiling from Source<\/h3>\n<p>If for some reason the bind-utils package isn&#8217;t available or doesn&#8217;t work for you, you could compile the BIND software (which includes nslookup) from source. This is a more complex process and generally not recommended unless you have specific needs that aren&#8217;t met by the package manager. Here are the steps:<\/p>\n<p>First, you&#8217;ll need to install the necessary development tools and libraries. On CentOS, you can do this with the following command:<\/p>\n<pre>\r\nsudo yum groupinstall 'Development Tools'\r\n<\/pre>\n<p>Next, download the latest version of BIND from the ISC website. As of my knowledge cutoff in September 2021, you would do this with the following commands, but you should check the ISC website for the latest version:<\/p>\n<pre>\r\nwget https:\/\/downloads.isc.org\/isc\/bind9\/9.16.15\/bind-9.16.15.tar.gz\r\n<\/pre>\n<pre>tar -xzvf bind-9.16.15.tar.gz\r\n<\/pre>\n<p>Navigate to the extracted directory:<\/p>\n<pre>\r\ncd bind-9.16.15\r\n<\/pre>\n<p>Configure the source code for your system:<\/p>\n<pre>\r\n.\/configure\r\n<\/pre>\n<p>Compile the source code:<\/p>\n<pre>\r\nmake\r\n<\/pre>\n<p>Install the compiled software:<\/p>\n<pre>\r\nsudo make install\r\n<\/pre>\n<p>This will install BIND, including nslookup, to your system. Remember, compiling from source bypasses the package manager, so you&#8217;ll need to manually update the software in the future.<\/p>\n<p>Regardless of how you install nslookup, it&#8217;s important to keep your system and software updated to ensure you have the latest security patches and bug fixes. Regularly run &#8220;sudo yum update -y&#8221; or &#8220;sudo dnf update -y&#8221; to keep your system up to date.<\/p>\n<h2>Advanced Usage of nslookup<\/h2>\n<p>Beyond the basic DNS lookup, nslookup offers a range of advanced options that can be useful in more complex scenarios. Here are some examples:<\/p>\n<h3>1. Checking Specific DNS Record Types<\/h3>\n<p>nslookup allows you to query specific types of DNS records. For example, to check the TXT records of a domain, which often include SPF and DKIM records used for email authentication, you can use the command:<\/p>\n<pre>\r\nnslookup -query=txt example.com\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nnslookup -query=txt bing.com\r\n\r\nServer:         198.18.18.18\r\nAddress:        198.18.18.18#53\r\n\r\nNon-authoritative answer:\r\nbing.com        text = \"facebook-domain-verification=09yg8uzcfnqnlqekzsbwjxyy8rdck7\"\r\nbing.com        text = \"google-site-verification=OkRY8R261shK5B8uEwvsFZp9nQ2gRoHavGlruok1azc\"\r\nbing.com        text = \"v=msv1 t=6097A7EA-53F7-4028-BA76-6869CB284C54\"\r\nbing.com        text = \"v=spf1 include:spf.protection.outlook.com -all\"\r\n<\/pre>\n<h3>2. Using Different DNS Servers<\/h3>\n<p>By default, nslookup uses the DNS servers that are configured for your system. However, you can specify a different DNS server by adding it to the end of your command. For example, to use Google&#8217;s DNS server to lookup a domain, you would use:<\/p>\n<pre>\r\nnslookup example.com 8.8.8.8\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nnslookup centos.org 8.8.8.8\r\n\r\nServer:         8.8.8.8\r\nAddress:        8.8.8.8#53\r\n\r\nNon-authoritative answer:\r\nName:   centos.org\r\nAddress: 52.56.83.118\r\nName:   centos.org\r\nAddress: 81.171.33.202\r\nName:   centos.org\r\nAddress: 81.171.33.201\r\nName:   centos.org\r\nAddress: 2001:4de0:aaae::201\r\nName:   centos.org\r\nAddress: 2001:4de0:aaae::202\r\nName:   centos.org\r\nAddress: 2a05:d01c:c6a:cc02:225e:ab54:d58c:8b14\r\n<\/pre>\n<h3>3. Checking SOA Records<\/h3>\n<p>The Start of Authority (SOA) record is a type of DNS record that stores important information about a domain, such as the primary name server, the email of the domain administrator, the domain serial number, and several timers related to refreshing the data. To check the SOA record of a domain, you can use:<\/p>\n<pre>\r\nnslookup -type=soa example.com\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nnslookup -type=soa ezoic.com\r\n\r\nServer:         198.18.18.18\r\nAddress:        198.18.18.18#53\r\n\r\nNon-authoritative answer:\r\nezoic.com\r\n        origin = ns-148.awsdns-18.com\r\n        mail addr = awsdns-hostmaster.amazon.com\r\n        serial = 1\r\n        refresh = 7200\r\n        retry = 900\r\n        expire = 1209600\r\n        minimum = 86400\r\n\r\nAuthoritative answers can be found from:\r\nezoic.com       nameserver = ns-148.awsdns-18.com.\r\nezoic.com       nameserver = ns-1523.awsdns-62.org.\r\nezoic.com       nameserver = ns-1549.awsdns-01.co.uk.\r\nezoic.com       nameserver = ns-822.awsdns-38.net.\r\n<\/pre>\n<h3>4. Interactive Mode<\/h3>\n<p>If you have several queries, you can use nslookup in interactive mode, which allows you to perform multiple operations without having to exit and re-enter the tool. You can enter interactive mode by simply typing &#8220;nslookup&#8221; at the command prompt.<\/p>\n<pre>\r\nnslookup\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo yum update -y<\/span> \u2013 Updates all packages on the CentOS system<\/li>\n<li><span class=\"fw-bold\">sudo yum install -y bind-utils<\/span> \u2013 Installs the bind-utils package, which includes nslookup and other DNS-related utilities<\/li>\n<li><span class=\"fw-bold\">nslookup<\/span> \u2013 A command-line tool for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information<\/li>\n<li><span class=\"fw-bold\">sudo dnf install -y bind-utils<\/span> \u2013 Installs the bind-utils package using the dnf package manager (CentOS 8 or later)<\/li>\n<li><span class=\"fw-bold\">sudo yum groupinstall &#8216;Development Tools&#8217;<\/span> \u2013 Installs necessary development tools and libraries for compiling from source<\/li>\n<li><span class=\"fw-bold\">wget https:\/\/downloads.isc.org\/isc\/bind9\/9.16.15\/bind-9.16.15.tar.gz<\/span> \u2013 Downloads the BIND source code<\/li>\n<li><span class=\"fw-bold\">tar -xzvf bind-9.16.15.tar.gz<\/span> \u2013 Extracts the downloaded BIND source code<\/li>\n<li><span class=\"fw-bold\">cd bind-9.16.15<\/span> \u2013 Navigates to the extracted BIND source code directory<\/li>\n<li><span class=\"fw-bold\">.\/configure<\/span> \u2013 Configures the BIND source code for your system<\/li>\n<li><span class=\"fw-bold\">make<\/span> \u2013 Compiles the BIND source code<\/li>\n<li><span class=\"fw-bold\">sudo make install<\/span> \u2013 Installs the compiled BIND software, including nslookup<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this tutorial, we&#8217;ve explored the process of installing the nslookup command-line tool on CentOS, a critical utility for querying the DNS. This tool is a must-use for server administrators and IT professionals who need to diagnose and troubleshoot DNS-related issues. We&#8217;ve also discussed the bind-utils package, which houses nslookup and other DNS-related utilities, and provided alternative installation methods for different CentOS versions.<\/p>\n<p>Moreover, we&#8217;ve discussed some of the basic uses of nslookup, from domain name and IP address mapping to advanced tasks like checking specific DNS record types, using different DNS servers, and performing reverse DNS lookups.<\/p>\n<p>Whether you&#8217;re managing a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud<\/a> hosting account, understanding and utilizing tools like nslookup is crucial for effective server management and troubleshooting.<\/p>\n<p>I hope this guide has been informative and helpful, equipping you with the knowledge to install and use nslookup on CentOS.<\/p>\n<p>As always, if you have any questions or suggestions, feel free to leave a comment below.<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is nslookup and why is it useful?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">nslookup is a command-line tool used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information. It&#8217;s particularly useful for diagnosing and troubleshooting DNS-related issues.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I install nslookup on CentOS?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">On CentOS, the nslookup command is part of the bind-utils package. You can install it using the command: sudo yum install -y bind-utils. If you&#8217;re using CentOS 8 or later, you might use the dnf package manager instead: sudo dnf install -y bind-utils.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Can I compile BIND from source to install nslookup?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Yes, you can compile BIND from source to install nslookup, although this is a more complex process and generally not recommended unless you have specific needs that aren&#8217;t met by the package manager. This involves downloading the BIND source code, configuring it for your system, compiling it, and then installing the compiled software.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What are some advanced uses of nslookup?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Beyond basic DNS lookups, nslookup can be used to check specific types of DNS records, use different DNS servers, perform reverse DNS lookups, and more. For example, you can check the MX records of a domain with nslookup -query=mx example.com, or use a different DNS server with nslookup example.com 8.8.8.8.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What other utilities are included in the bind-utils package?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The bind-utils package includes several utilities for working with DNS, not just nslookup. These include dig, a flexible tool for interrogating DNS name servers, and host, a simple utility for performing DNS lookups.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>The nslookup command-line tool is an essential utility for web administrators and IT professionals. It allows you to query the Domain Name System (DNS), which is the system that translates&#8230;<\/p>\n","protected":false},"author":6,"featured_media":349,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,1138],"tags":[1228,1244,1536,1607],"class_list":["post-1610","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-dns","tag-bind","tag-centos","tag-linux","tag-nslookup"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1610"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1610\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/349"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}