- How to Install and Use dig and nslookup Commands in Linux
- Installing dig & nslookup in CentOS/RHEL
- Installing dig & nslookup on Debian / Ubuntu
- Installing dig & nslookup on ArchLinux
- Using the dig command
- Using the nslookup Command
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to use Nslookup in Debian
- Nslookup Non-interactive mode
- How it works?
- Obtain IP address for a hostname
- Understanding the output
- Obtain hostname from IP address
- Obtain MX records
- Obtain NS records
- Obtain all DNS records
- Nslookup Interactive mode
- About the author
- Karim Buzdar
- SYNOPSIS¶
- DESCRIPTION¶
- ARGUMENTS¶
- INTERACTIVE COMMANDS¶
- RETURN VALUES¶
- IDN SUPPORT¶
- FILES¶
- SEE ALSO¶
- AUTHOR¶
- COPYRIGHT¶
- SYNOPSIS¶
- DESCRIPTION¶
- ARGUMENTS¶
- INTERACTIVE COMMANDS¶
- RETURN VALUES¶
- IDN SUPPORT¶
How to Install and Use dig and nslookup Commands in Linux
In this article, you will learn how to install the dig command and nslookup command on Linux. These commands are used for network troubleshooting and gathering information about domain names.
Dig, short for Domain Information Gopher, is a DNS lookup utility used for probing DNS servers and troubleshooting problems associated with DNS servers. Due to its ease of use, system administrators rely on the tool to troubleshoot DNS issues.
Nslookup is used for handling DNS lookups and displays crucial information such as MX records, and the IP address associated with a domain name.
Newer Linux system ship both dig and nslookup utilities by default. However, older Linux systems may not. The two come bundled inside the bind-utils package.
Let’s see how we can install DNS troubleshooting utilities in Linux.
On this page:
Installing dig & nslookup in CentOS/RHEL
On Red Hat Linux /CentOS, install dig and nslookup using the dnf command.
Install Bind-Utils in CentOS
Upon successful installation, verify the version using the command below.
Check Dig Command Version
Installing dig & nslookup on Debian / Ubuntu
On Debian and any of its derivatives including Debian, the installation is done using the apt command.
Install DNS Utils in Debian and Ubuntu
Again, to verify the installation, run the command.
Check dig Version in Debian and Ubuntu
Installing dig & nslookup on ArchLinux
For ArchLinux, the command for installing dig and nslookup will be.
Install dns-utils Arch Linux
To check the version of dig installed, run.
Check dig Version in Arch Linux
Using the dig command
dig command can be used to query a domain name and retrieve information as shown:
The command displays a host of information such as the version of the dig command utility, the DNS server, and its corresponding IP address.
Sample Output
To get more specific and display only the IP of the domain name append the +short argument as shown:
To check the MX record of the domain name run.
Using the nslookup Command
To retrieve information about a domain name using the nslookup utility, use the following command.
Sample Output
Conclusion
In this article, you learned how to install dig and nslookup command utilities in different Linux distributions and also the basic usage of the commands. We do hope that you can now comfortably install the utilities when confronted with a system without them.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to use Nslookup in Debian
In this article, we will explain how to use Nslookup to query different types of DNS records. We have run the commands and procedure mentioned in this article on a Debian 10 OS. However, the same procedure can be followed in other distributions and versions of Linux as well.
There are two modes in which Nslookup works: Interactive mode and Non-interactive mode. We have explained the procedure in not-interactive mode. However, at the end will also learn how to use the interactive mode.
Nslookup Non-interactive mode
In non-interactive mode, the entire command is issued at the Terminal. Use this mode when you require a single piece of information from a particular server.
For using non-interactive mode, the general syntax is:
How it works?
Open the Terminal in your Debian OS. In the top left corner of your desktop, you will see the Activities tab. By clicking this tab, a search bar will appear. From there, you can search for Terminal application.
Obtain IP address for a hostname
In order to find the IP address for a hostname, the syntax is:
This method is also known as forward DNS lookup.
For instance, to find the IP address of redhat.com, enter the following command in Terminal:
The above command implies that the Nslookup has requests the DNS server to find the IP address of redhat.com. The DNS server then requests to other servers, get a response and then sending it back to the Nslookup.
In the Terminal, you will receive the following info:
Understanding the output
The above output has provided us with some findings. Let’s understand them:
# It is the IP address of the DNS server to which Nslookup requested to.
# It is the IP address of the DNS server along with the port number 53 Nslookup talked to.
# Non-authoritative answer indicates we have got the cached reply from the DNS server.
Obtain hostname from IP address
We can also perform reverse Nslookup to resolve hostname against an IP address. It is known as reverse DNS lookup.
The syntax of the command is:
In the following example, we are finding the hostname against the IP 209.132.183.105 as follows:
From the following output, you can see that Nslookup has returned the hostname against the specified IP address.
Obtain MX records
MX ( Mail Exchange ) records determine the mail server settings configured for a specific domain. It contains the mapping of a domain name to a list of email servers. MX records tells which mail server will handle the mails sent to a specific domain. MX records are configured in such a way that when an email is sent to @example.com, it is routed to the mail servers for the domain example.com.
To find the MX records for a specific domain, the syntax is:
In the following example, we are finding the MX records for the domain debian.org:
The following output shows the MX records for the domain debian.org.
Obtain NS records
In the domain name system, NS records are used to identify which name servers are responsible and authoritative for a domain.
To find the NS records for a specific domain, the syntax is:
In the following example, we are finding the NS records for the domain debian.org:
The following output shows the NS records for the domain debian.org.
Obtain all DNS records
Nslookup can also be used to retrieve all the records simultaneously including A, NS, MX, TXT, SPF, etc. for the hostname you specify.
To find all the DNS records, use the following syntax:
For instance, to find all DNS records of a domain debian.org, the command would be:
Nslookup Interactive mode
In interactive mode, you first enter in a separate prompt, and then add subsequent parameters to inquire further information. Use this mode when you require a lot of information from a server.
In order to use interactive mode, simply type nslookup in Terminal and press Enter.
You will see the prompt like >. Here you can query for information.
In the following example, after entering in the Nslookup prompt, we have entered the following commands:
# To obtain IP address information for the domain redhat.com
# To obtain MX records for the domain redhat.com
As we have seen, Nslookup provides a lot of information regarding DNS such as forward and reverse lookup information, NS records, MX records, etc. However, it is not limited to just this information rather it provides a lot more than this. But for now, we hope it would be enough for you to have a basic understanding of Nslookup works.
About the author
Karim Buzdar
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.
Источник
SYNOPSIS¶
nslookup [-option] [name | -] [server]
DESCRIPTION¶
Nslookup is a program to query Internet domain name servers. Nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.
ARGUMENTS¶
Interactive mode is entered in the following cases:
Non-interactive mode is used when the name or Internet address of the host to be looked up is given as the first argument. The optional second argument specifies the host name or address of a name server.
Options can also be specified on the command line if they precede the arguments and are prefixed with a hyphen. For example, to change the default query type to host information, and the initial timeout to 10 seconds, type:
The -version option causes nslookup to print the version number and immediately exits.
INTERACTIVE COMMANDS¶
To look up a host not in the current domain, append a period to the name.
The class specifies the protocol group of the information.
(Default = IN; abbreviation = cl)
(Default = nodebug; abbreviation = [no]deb)
(Default = 53; abbreviation = po)
(Default = A; abbreviations = q, ty)
(Default = recurse; abbreviation = [no]rec)
RETURN VALUES¶
nslookup returns with an exit status of 1 if any query failed, and 0 otherwise.
IDN SUPPORT¶
If nslookup has been built with IDN (internationalized domain name) support, it can accept and display non-ASCII domain names. nslookup appropriately converts character encoding of domain name before sending a request to DNS server or displaying a reply from the server. If you’d like to turn off the IDN support for some reason, define the IDN_DISABLE environment variable. The IDN support is disabled if the variable is set when nslookup runs or when the standard output is not a tty.
FILES¶
SEE ALSO¶
AUTHOR¶
Internet Systems Consortium, Inc.
COPYRIGHT¶
Copyright © 2004-2007, 2010, 2013-2019 Internet Systems Consortium, Inc. («ISC»)
Источник
SYNOPSIS¶
nslookup [-option] [name | -] [server]
DESCRIPTION¶
nslookup is a program to query Internet domain name servers. nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode prints just the name and requested information for a host or domain.
ARGUMENTS¶
Interactive mode is entered in the following cases:
Non-interactive mode is used when the name or Internet address of the host to be looked up is given as the first argument. The optional second argument specifies the host name or address of a name server.
Options can also be specified on the command line if they precede the arguments and are prefixed with a hyphen. For example, to change the default query type to host information, with an initial timeout of 10 seconds, type:
The -version option causes nslookup to print the version number and immediately exit.
INTERACTIVE COMMANDS¶
To look up a host not in the current domain, append a period to the name.
server domain | lserver domain These commands change the default server to domain; lserver uses the initial server to look up information about domain, while server uses the current default server. If an authoritative answer cannot be found, the names of servers that might have the answer are returned. root This command is not implemented. finger This command is not implemented. ls This command is not implemented. view This command is not implemented. help This command is not implemented. ? This command is not implemented. exit This command exits the program. set keyword[=value] This command is used to change state information that affects the lookups. Valid keywords are:
The class specifies the protocol group of the information. The default is IN; the abbreviation for this keyword is cl.
nodebug This keyword turns on or off the display of the full response packet, and any intermediate response packets, when searching. The default for this keyword is nodebug; the abbreviation for this keyword is [no]deb. nod2 This keyword turns debugging mode on or off. This displays more about what nslookup is doing. The default is nod2. domain=name This keyword sets the search list to name. nosearch If the lookup request contains at least one period, but does not end with a trailing period, this keyword appends the domain names in the domain search list to the request until an answer is received. The default is search. port=value This keyword changes the default TCP/UDP name server port to value from its default, port 53. The abbreviation for this keyword is po. querytype=value | type=value This keyword changes the type of the information query to value. The defaults are A and then AAAA; the abbreviations for these keywords are q and ty.
Please note that it is only possible to specify one query type. Only the default behavior looks up both when an alternative is not specified.
norecurse This keyword tells the name server to query other servers if it does not have the information. The default is recurse; the abbreviation for this keyword is [no]rec. ndots=number This keyword sets the number of dots (label separators) in a domain that disables searching. Absolute names always stop searching. retry=number This keyword sets the number of retries to number. timeout=number This keyword changes the initial timeout interval to wait for a reply to number, in seconds. novc This keyword indicates that a virtual circuit should always be used when sending requests to the server. novc is the default. nofail This keyword tries the next nameserver if a nameserver responds with SERVFAIL or a referral (nofail), or terminates the query (fail) on such a response. The default is nofail.
RETURN VALUES¶
nslookup returns with an exit status of 1 if any query failed, and 0 otherwise.
IDN SUPPORT¶
If nslookup has been built with IDN (internationalized domain name) support, it can accept and display non-ASCII domain names. nslookup appropriately converts character encoding of a domain name before sending a request to a DNS server or displaying a reply from the server. To turn off IDN support, define the IDN_DISABLE environment variable. IDN support is disabled if the variable is set when nslookup runs, or when the standard output is not a tty.
Источник