This tutorial explains how to verify the IP address of a domain name or computer name in the Linux terminal. This tutorial will allow you to check multiple domains at once. You may have already used these commands to verify information. However, we will teach you how to effectively use these commands to identify IP address information of multiple domains in Linux terminal. This can be done using the following 5 commands.
For testing, we created a file called # vi /opt/scripts/domains-list.txt 2daygeek.com magesh.co.in linuxtechnews.com Method 1: How to find the IP address of a domain using dig command The dig command stands for "Domain Information Groper" and is a powerful and flexible command-line tool for querying DNS name servers. It performs a DNS query and displays the return information from the queried name servers. Most DNS administrators use the dig command to troubleshoot DNS problems because of its flexibility, ease of use, and clear output. It also has a batch mode and can read search requests from a file. # dig 2daygeek.com | awk '{print $1,$5}' 2daygeek.com. 104.27.157.177 2daygeek.com. 104.27.156.177 Use the following bash script to find the IP addresses of multiple domains. # vi /opt/scripts/dig-command.sh #!/bin/bash for server in `cat /opt/scripts/domains-list.txt` do echo $server "-" dig $server +short done | paste -d " " - - - After adding the above content to the script, set executable permissions for the dig-command.sh file. # chmod +x /opt/scripts/dig-command.sh Finally run the bash script to get the output. # sh /opt/scripts/dig-command.sh 2daygeek.com - 104.27.156.177 104.27.157.177 magesh.co.in - 104.18.35.52 104.18.34.52 linuxtechnews.com - 104.27.144.3 104.27.145.3 If you want to run above script in one line, use the following script. # for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - - Alternatively, you can use the following shell script to find the IP addresses of multiple domains. # for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done 2daygeek.com. 104.27.157.177 2daygeek.com. 104.27.156.177 magesh.co.in. 104.18.34.52 magesh.co.in. 104.18.35.52 linuxtechnews.com. 104.27.144.3 linuxtechnews.com. 104.27.145.3 Method 2: How to find the IP address of a domain using host command The host command is a simple command-line program for performing DNS queries. It is commonly used to convert names to IP addresses and vice versa. If no arguments or options are given, host prints a summary of its command line arguments and options. You can add specific options or record types to the host command to view all record types in the domain. # host 2daygeek.com | grep "has address" | sed 's/has address/-/g' 2daygeek.com - 104.27.157.177 2daygeek.com - 104.27.156.177 Use the following bash script to find the IP addresses of multiple domains. # vi /opt/scripts/host-command.sh for server in `cat /opt/scripts/domains-list.txt` do host $server | grep "has address" | sed 's/has address/-/g' done After adding the above content to the script, set executable permissions for the # chmod +x /opt/scripts/host-command.sh Finally run the bash script to get the output. # sh /opt/scripts/host-command.sh 2daygeek.com - 104.27.156.177 2daygeek.com - 104.27.157.177 magesh.co.in - 104.18.35.52 magesh.co.in - 104.18.34.52 linuxtechnews.com - 104.27.144.3 linuxtechnews.com - 104.27.145.3 Method 3: How to find the IP address of a domain using the nslookup command The nslookup command is a program used to query the Internet Domain Name Server (DNS). nslookup has two modes, interactive and non-interactive. Interactive mode allows the user to query the name server for information about various hosts and domains, or to print a list of hosts in a domain. Non-interactive mode is used to print only the name of the host or domain and the requested information. It is a network management tool that helps diagnose and resolve DNS-related issues. # nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 104.27.157.177 104.27.156.177 Use the following bash script to find the IP addresses of multiple domains. # vi /opt/scripts/nslookup-command.sh #!/bin/bash for server in `cat /opt/scripts/domains-list.txt` do echo $server "-" nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - - After adding the above content to the script, set executable permissions for the # chmod +x /opt/scripts/nslookup-command.sh Finally run the bash script to get the output. # sh /opt/scripts/nslookup-command.sh 2daygeek.com - 104.27.156.177 104.27.157.177 magesh.co.in - 104.18.35.52 104.18.34.52 linuxtechnews.com - 104.27.144.3 104.27.145.3 Method 4: How to find the IP address of a domain using fping command The fping command is a ping-like program that uses Internet Control Message Protocol (ICMP) echo requests to determine if the target host is responding. fping differs from ping in that it allows the user to ping any number of hosts in parallel. Alternatively, it can import hosts from a text file. fping sends ICMP echo requests and moves to the next target in a round-robin fashion without waiting for the target host to respond. If the target host replies, it is marked as active and removed from the list of targets to be checked; if the target does not respond within a certain time limit and/or retry limit, it is designated as unreachable. # fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com 104.27.157.177 (104.27.157.177) is alive 104.18.35.52 (104.18.35.52) is alive 104.27.144.3 (104.27.144.3) is alive Method 5: How to find the IP address of a domain using the ping command The ping command (Packet Internet Groper) is a network program used to test the availability/connectivity of hosts on an Internet Protocol (IP) network. Verifies the availability of a host by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for the ICMP Echo Reply. It summarizes statistics based on packets sent, packets received, packets lost, and usually includes min/avg/max times. # ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' 104.27.157.177 Use the following bash script to find the IP addresses of multiple domains. # vi /opt/scripts/ping-command.sh #!/bin/bash for server in `cat /opt/scripts/domains-list.txt` do echo $server "-" ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' done | paste -d " " - - After adding the above content to the script, set executable permissions for the # chmod +x /opt/scripts/ping-command.sh Finally run the bash script to get the output. # sh /opt/scripts/ping-command.sh 2daygeek.com - 104.27.156.177 magesh.co.in - 104.18.35.52 linuxtechnews.com - 104.27.144.3 Summarize The above are the 5 commands I introduced to you for finding the domain name IP address in the Linux terminal. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: JS operation object array to achieve add, delete, modify and query example code
>>: mysql installer community 8.0.16.0 installation and configuration graphic tutorial
Benefits of using xshell to connect to Linux We c...
After reading some articles, I finally figured ou...
Table of contents 1. Introduction 2. es5 method 3...
We often encounter this situation when doing devel...
Preface Today, I was reviewing the creational pat...
Page Description: Main page: name —> shisheng...
The property of centering text in CSS is very simp...
XHTML defines three document type declarations. T...
This article will introduce how to save IP addres...
1. Virtual Machine Preparation 1. Create a new vi...
Effect picture: The implementation code is as fol...
@Font-face basic introduction: @font-face is a CSS...
When we make a form, we often set a submit button ...
Table of contents Methods of String Object Method...
What is Nginx access restriction configuration Ng...