From 4038c036caa423404dee1f852859d26423ffbb68 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 2 Dec 2019 08:43:41 +0800 Subject: [PATCH] translated --- ...dress of a Domain in the Linux Terminal.md | 275 ------------------ ...dress of a Domain in the Linux Terminal.md | 275 ++++++++++++++++++ 2 files changed, 275 insertions(+), 275 deletions(-) delete mode 100644 sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md create mode 100644 translated/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md diff --git a/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md deleted file mode 100644 index 866d5df482..0000000000 --- a/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md +++ /dev/null @@ -1,275 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal) -[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) - -5 Commands to Find the IP Address of a Domain in the Linux Terminal -====== - -This tutorial shows you how to verify a domain name’s or computer name IP address from a 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 use these commands effectively to identify multiple domain IP address information from the Linux terminal. - -This can be done using the following 5 commands. - - * **dig Command:** dig is a flexible cli tool for interrogating DNS name servers. - * **host Command:** host is a simple utility for performing DNS lookups. - * **nslookup Command:** Nslookup command is used to query Internet domain name servers. - * **fping Command:** fping command is used to send ICMP ECHO_REQUEST packets to network hosts. - * **ping Command:** ping command is used to send ICMP ECHO_REQUEST packets to network hosts. - - - -To test this, we created a file called “domains-list.txt” and added the below domains. - -``` -# vi /opt/scripts/domains-list.txt - -2daygeek.com -magesh.co.in -linuxtechnews.com -``` - -### Method-1: How to Find a IP Address of the Domain Using the dig Command - -**[dig command][1]** stands for “domain information groper”‘ is a powerful and flexible command-line tool for querying DNS name servers. - -It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. - -Most DNS administrators use dig command to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. - -It also has a batch mode functionality to 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 multiple domain’s IP address. - -``` -# 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 " " - - - -``` - -Once the above script is added to a file. Set the executable permission 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 the 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 address of the multiple domain. - -``` -# 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 a Domain’s IP Address Using the host Command - -**[Host Command][2]** is a simple CLI application to perform **[DNS lookup][3]**. - -It is commonly used to convert names to IP addresses and vice versa. - -When no arguments or options are given, host prints a short summary of its command line arguments and options. - -You can view all types of records in the domain by adding a specific option or type of record in the host command. - -``` -# 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 multiple domain’s IP address. - -``` -# 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 -``` - -Once the above script is added to a file. Set the executable permission for 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.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 - -**[nslookup command][4]** is a program for querying Internet **[domain name servers (DNS)][5]**. - -nslookup has two modes, which are interactive and 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. - -It is a network administration 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 multiple domain’s IP address. - -``` -# 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 " " - - - -``` - -Once the above script is added to a file. Set the executable permission for 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.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 a Domain’s IP Address Using the fping Command - -**[fping command][6]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding. - -fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file. - -fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds. - -If a target host replies, it is noted as active and removed from the list of targets to check; if a 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 the Domain Using the ping Command - -**[ping command][6]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network. - -It’s verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply. - -It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the 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 multiple domain’s IP address. - -``` -# 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 " " - - -``` - -Once the above script is added to a file. Set the executable permission for the “dig-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.177 -magesh.co.in - 104.18.35.52 -linuxtechnews.com - 104.27.144.3 -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/ - -作者:[Magesh Maruthamuthu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/ -[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/ -[3]: https://www.2daygeek.com/category/dns-lookup/ -[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/ -[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/ -[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/ diff --git a/translated/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/translated/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md new file mode 100644 index 0000000000..344d781010 --- /dev/null +++ b/translated/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md @@ -0,0 +1,275 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal) +[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 个用于在 Linux 终端中查找域 IP 地址的命令 +====== + +本教程介绍了如何在 Linux 终端验证域名或计算机名的 IP 地址。 + +本教程将允许你一次检查多个域。 + +你可能已经使用过这些命令来验证信息。 + +但是,我们将教你如何有效使用这些命令在 Linux 终端中识别多个域的 IP 地址信息。 + +可以使用以下5个命令来完成此操作。 + + * **dig 命令:** dig 是用于查询 DNS名称服务器的灵活命令行工具。 +  * **host 命令:** host 是用于执行 DNS 查询的简单程序。 +  * **nslookup 命令:** nslookup 命令用于查询互联网域名服务器。 +  * **fping 命令:** fping 命令用于将 ICMP ECHO_REQUEST 数据包发送到网络主机。 +  * **ping 命令:** ping 命令用于向网络主机发送 ICMP ECHO_REQUEST 数据包。 + + + +为了测试,我们创建了一个名为 “domains-list.txt” 的文件,并添加了以下域。 + +``` +# vi /opt/scripts/domains-list.txt + +2daygeek.com +magesh.co.in +linuxtechnews.com +``` + +### 方法 1:如何使用 dig 命令查找域的 IP 地址 + +**[dig 命令][1]**代表 “domain information groper”,它是一个功能强大且灵活的命令行工具,用于查询 DNS 名称服务器。 + +它执行 DNS 查询,并显示来自查询的名称服务器的返回信息。 + +大多数 DNS 管理员使用 dig 命令来解决 DNS 问题,因为它灵活、易用且输出清晰。 + +它还有批处理模式,可以从文件读取搜索请求。 + +``` +# dig 2daygeek.com | awk '{print $1,$5}' + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# 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 " " - - - +``` + +添加以上脚本后,给 “dig-command.sh” 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/dig-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# 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 +``` + +如果要在一行中运行上面的脚本,请使用以下脚本。 + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - - +``` + +或者,你可以使用以下 Shell 脚本查找多个域的 IP 地址。 + +``` +# 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 +``` + +### 方法 2:如何使用 host 命令查找域的 IP 地址 + +**[host 命令][2]**是一个简单的命令行程序,用于执行 **[DNS 查询][3]**。 + +它通常用于将名称转换为 IP 地址,反之亦然。 + +如果未提供任何参数或选项,host 将打印它的命令行参数和选项摘要。 + +你可以在 host 命令中添加特定选项或记录类型来查看域中的所有记录类型。 + +``` +# host 2daygeek.com | grep "has address" | sed 's/has address/-/g' + +2daygeek.com - 104.27.157.177 +2daygeek.com - 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# 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 +``` + +添加以上脚本后,给 “host-command.sh” 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/host-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# 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 +``` + +### 方法 3:如何使用 nslookup 命令查找域的 IP 地址 + +**[nslookup 命令][4]**是用于查询互联网**[域名服务器(DNS)] [5]**的程序。 + +nslookup 有两种模式,分别是交互式和非交互式。 + +交互模式允许用户查询名称服务器以获取有关各种主机和域的信息,或打印域中的主机列表。 + +非交互模式用于仅打印主机或域的名称和请求的信息。 + +它是一个网络管理工具,可以帮助诊断和解决 DNS 相关问题。 + +``` +# 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 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# 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 " " - - - +``` + +添加以上脚本后,给 “nslookup-command.sh” 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/nslookup-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# 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 +``` + +### 方法 4:如何使用 fping 命令查找域的 IP 地址 + +**[fping 命令][6]**是类似 ping 之类的程序,它使用互联网控制消息协议(ICMP)echo 请求来确定目标主机是否响应。 + +fping 与 ping 不同,因为它允许用户并行 ping 任意数量的主机。另外,它可以从文本文件输入主机。 + +fping 发送 ICMP echo 请求,并以循环方式移到下一个目标,并且不等到目标主机做出响应。 + +如果目标主机答复,那么将其标记为活动主机并从要检查的目标列表中删除;如果目标在特定时间限制和/或重试限制内未响应,那么将其指定为不可访问。 + +``` +# 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 +``` + +### 方法 5:如何使用 ping 命令查找域的 IP 地址 + +**[ping(Packet Internet Groper)命令][6]**是一个网络程序,用于测试 Internet 协议(IP)网络上主机的可用性/连接性。 + +通过向目标主机发送互联网控制消息协议(ICMP)Echo 请求数据包并等待 ICMP Echo 应答来验证主机的可用性。 + +它基于发送的数据包、接收的数据包、丢失的数据包,通常包含最小/平均/最大时间来汇总统计结果。 + +``` +# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' + +104.27.157.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# 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 " " - - +``` + +添加以上脚本后,给 “ping-command.sh” 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/ping-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# 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 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/ +[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/ +[3]: https://www.2daygeek.com/category/dns-lookup/ +[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/ +[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/ +[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/