This is a script that performs DNS lookup using the host command.
The host command is a simple tool used to perform DNS lookups in Linux. It is usually used to resolve a hostname into an IP address or vice-versa.
If you want to use this script to perform DNS lookups than follow the below steps.
- Clone this repository to your machine, for that use this command in terminal.
git clone https://github.com/rahulMishra05/dns_lookup_host.git
- Now, when you have succesfully cloned this repository move to the project folder, like this
cd dns_lookup_host/ - Now to list all the files use
lscommand, and you will see these files in the directory.Among them README.md is the markdown file and script.sh is the main project file contaning the script.README.md script.sh
- Now its time that we can run this script, to do that execute the script.sh file in the terminal, like this
./script.sh
This is a shell script, which contains some command inside it, that give users the desired output.
Let's understand about this script in detail.
- When you execute the script it asks for the DNS name and store the input provided by the user into a variable
$dnsName. - Than first thing that is displayed are the details of the IP address, and the command that is used to do that is
host $dnsName - Second thing which is displayed on the terminal is SOA records for the zone name form all the listed authoritative name servers for that zone.
The list of name servers is defined by the NS records that are found for the zone.
Command used to do that is
host -C $dnsName - Third thing which is displayed is verbous/detaied output for the host command, by using this command
We can use
host -d $dnsName-dflag and-vflag to display verbous output. - Forth thing which is displayed tells us about the name servers explicitly, and for that we use this command
Here
host -t ns $dnsNamensflag is used to get the details of the name server, and-tflag is used to specify the type of query. - Fifth and last thing which will be displayed on the terminal is txt records, and for it we will use this script.
Here again
host -t txt $dnsName-tflag is used to specify the type of query andtxtflag is used to get text records.

