Unix 命令“host” - 是否有 Windows 等价物?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21520191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unix command "host" - is there Windows equivalent?
提问by Alexander Mills
I am on a Windows 7 machine and I was instructed to use the Unix command "host" as per this article:
我在一台 Windows 7 机器上,我被指示按照这篇文章使用 Unix 命令“host”:
https://devcenter.heroku.com/articles/custom-domains
https://devcenter.heroku.com/articles/custom-domains
however, host
is not a valid command with Windows and even with bash on Windows I could find host
installed.
但是,host
对于 Windows 和什至在 Windows 上使用 bash 都不是有效命令,我可以找到host
安装。
Is there a Windows equivalent to "host"?
是否有相当于“主机”的 Windows?
回答by Jim Stewart
This question is more suited to Super User, but the command you're looking for is nslookup
. Both are (at their most basic) used to look up IP addresses for hostnames. You can run cmd
and do nslookup hostname
the same way you'd do host hostname
. If you need something other than the IP address, the command-line arguments will differ. Run nslookup
with no arguments and type help
at the prompt for details.
这个问题更适合Super User,但您要查找的命令是nslookup
. 两者(最基本的)都用于查找主机名的 IP 地址。你可以像你一样跑步cmd
和nslookup hostname
做host hostname
。如果您需要 IP 地址以外的其他内容,则命令行参数会有所不同。nslookup
不带参数运行并help
在提示符下键入以获取详细信息。
回答by pinball13
Although you will be able to find the DNS resolution using nslooukup
, there is no direct equivalent to the host
command in Windows. There is a similar question on Super User.
虽然您可以使用 找到 DNS 解析nslooukup
,但host
在 Windows 中没有直接等效的命令。Super User上有一个类似的问题。
回答by Shane Baker
Old thread, but I hit it doing Google searches. There is no built in but if you add this to your profile.ps1 it'll do what you want.
旧线程,但我在谷歌搜索中找到了它。没有内置,但如果你将它添加到你的 profile.ps1 中,它会做你想做的。
function host {
param ($ip)
$ErrorActionPreference='stop'
$answer=Resolve-DnsName $ip
if ($answer[0].IPAddress -eq $null)
{
echo "$($answer.Name[0]) has address $($answer.namehost[0])"
}
else
{
echo "$($answer.Name[0]) has address $($answer.Ipaddress[0])"
}
}
回答by Falcon362xxXxx5692
Use the command "Nslookup" followed by your business domain to look up its server's IP address. If the server has multiple IP addresses associated with the name, the command will list all of them. As an example, you might enter "nslookup google.com" to find a list of Google's IP addresses.
使用命令“Nslookup”后跟您的业务域来查找其服务器的 IP 地址。如果服务器有多个与该名称关联的 IP 地址,该命令将列出所有这些地址。例如,您可以输入“nslookup google.com”来查找 Google 的 IP 地址列表。