In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to find the IP address of the domain name in the Linux terminal, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
You can use the following five commands to do this.
Dig command: it is a flexible command-line tool for querying DNS name servers.
The host command: this is a simple program for executing DNS queries.
Nslookup command: it is used to query the Internet domain name server.
Fping command: it is used to send ICMP ECHO_REQUEST packets to network hosts.
Ping command: it is used to send ICMP ECHO_REQUEST packets to network hosts.
For testing, we created a file called domains-list.txt and added the following fields.
# vi / opt/scripts/domains-list.txt 2daygeek.commagesh.co.inlinuxtechnews.com method 1: how to use the dig command to find the IP address of a domain
The dig command stands for "domain name information grab Domain Information Groper", which is a powerful and flexible command-line tool for querying DNS name servers.
It executes the DNS query and displays the returned information from the name server of the query. Most DNS administrators use the dig command to solve DNS problems because of its flexibility, ease of use, and clear output.
It also has a batch mode, which can read search requests from files.
# dig 2daygeek.com | awk'{print $1 2daygeek.com 5}'. 104.27.157.1772daygeek.com. 104.27.156.177
Use the following bash script to find IP addresses for multiple domains.
# vi / opt/scripts/dig-command.sh #! / bin/bashfor server in `cat / opt/scripts/domains- list.txt`do echo $server "-" dig $server + shortdone | paste-d ""-
After adding the above to the script, set executable permissions to 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.177magesh.co.in-104.18.35.52 104.18.34.52linuxtechnews.com-104.27.144.3 104.27.145.3
If you want to run the above script on 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 done 2daygeek.com. 104.27.157.1772daygeek.com. 104.27.156.177magesh.co.in. 104.18.34.52magesh.co.in. 104.18.35.52linuxtechnews.com. 104.27.144.3linuxtechnews.com. 104.27.145.3 method 2: how to use the host command to find the IP address of a domain
The host command is a simple command-line program that executes DNS queries. It is typically used to convert names to IP addresses and vice versa. If no arguments or options are provided, 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.1772daygeek.com-104.27.156.177
Use the following bash script to find IP addresses for 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 to the script, set executable permissions to the host-command.sh file.
# 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.1772daygeek.com-104.27.157.177magesh.co.in-104.18.35.52magesh.co.in-104.18.34.52linuxtechnews.com-104.27.144.3linuxtechnews.com-104.27.145.3 method 3: how to use the nslookup command to find the IP address of a domain
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 users 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 only the name and requested information of the host or domain.
It is a network management tool that can help diagnose and resolve DNS-related problems.
# nslookup-QiteA 2daygeek.com | tail-nasty 4 | sed-e'/ ^ $/ d'-e's xargs add _ ressGUP _ GO _ g' | grep-v 'Name | answer' | xargs-N1 104.27.157.177104.27.156.177
Use the following bash script to find IP addresses for multiple domains.
# vi / opt/scripts/nslookup-command.sh #! / bin/bashfor server in `cat / opt/scripts/domains- list.txt`do echo $server "-" nslookup- quliA $server | tail-nag4 | sed-e'/ ^ $/ d'e-e-Name AddressG' | grep-v 'Name | answer' | xargs-N1 done | paste-d ""-
After adding the above to the script, set executable permissions to the nslookup-command.sh file.
# 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.177magesh.co.in-104.18.35.52 104.18.34.52linuxtechnews.com-104.27.144.3 104.27.145.3 method 4: how to use the fping command to find the IP address of a domain
The fping command is a program such as ping that uses Internet Control message Protocol (ICMP) echo requests to determine whether the target host responds.
Fping is different from ping in that it allows users to ping any number of hosts in parallel. In addition, it can enter the host from a text file.
Fping sends an ICMP echo request and moves to the next destination in a loop without waiting for the target host to respond.
If the target host replies, mark it as the active host and remove it from the list of targets to check, and if the target does not respond within a specific time limit and / or retry limit, designate it as inaccessible.
# fping-A-d 2daygeek.com magesh.co.in linuxtechnews.com 104.27.157.177 (104.27.157.177) is alive104.18.35.52 (104.18.35.52) is alive104.27.144.3 (104.27.144.3) is alive method 5: how to use the ping command to find the IP address of a domain
The ping command (packet Internet grab Packet Internet Groper) is a network program used to test the availability / connectivity of hosts on an Internet protocol (IP) network.
Verify the availability of the host by sending an Internet Control message Protocol (ICMP) Echo request packet to the target host and waiting for an ICMP Echo reply.
It summarizes statistical results based on packets sent, packets received, packets lost, and usually includes minimum / average / maximum time.
# 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 IP addresses for multiple domains.
# vi / opt/scripts/ping-command.sh #! / bin/bashfor 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 to the script, set executable permissions to the ping-command.sh file.
# 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.177magesh.co.in-104.18.35.52linuxtechnews.com-104.27.144.3 Thank you for reading this article carefully. I hope the article "how to find the IP address of the domain name in the Linux terminal" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.