如何获取不响应 Ping 的网站 IP?

发布于 2024-10-09 11:13:48 字数 157 浏览 0 评论 0原文

我试图获取一个不响应 ping 的网站的 IP 地址——它们超时了。

我尝试从 C# 应用程序而不是 Windows 中的命令输入屏幕执行此操作。我一直在使用 ping 命令,该命令在某些站点上超时,因此它在那里没有用。

是否有其他方法可以获取此信息而不需要网站响应?

I'm trying to get the IP address of a website that does not respond to pings -- they time out.

I'm trying to do this from a C# application rather than the command entry screen in windows. I've been using the ping command which has times out on some sites so it is not useful there.

Is there another way to get this information that does not require the site to respond?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

离去的眼神 2024-10-16 11:13:48

即使站点不响应 PING(服务器上未启用 ICMP 或被防火墙过滤),PING 命令仍应将站点名称解析为 IP 地址并向您显示该 IP 地址。

检查 Windows 上 ping 命令的输出(IP 地址以粗体显示):

ping wikipedia.org

Pinging wikipedia.org [208.80.152.2] with 32 bytes o
208.80.152.2 回复:字节=32 时间=245ms TTL=50
来自 208.80.152.2 的回复: bytes=32 time=235ms TTL=50

更新(由于更新的问题)

如果您尝试从 C# 应用程序获取 DNS 名称的 IP 地址,您应该使用Dns 类中的 GetHostEntry 方法: http://msdn.microsoft.com/en -us/library/ms143998.aspx

Even if the site does not respond to PINGs (ICMP not enabled on the server or filtered by firewall), the PING command should still resolve the site name into an IP address and display that IP address to you.

Check the output of a ping command on Windows (the ip address in bold):

ping wikipedia.org

Pinging wikipedia.org [208.80.152.2] with 32 bytes o
Reply from 208.80.152.2: bytes=32 time=245ms TTL=50
Reply from 208.80.152.2: bytes=32 time=235ms TTL=50

Update (due to to updated question)

If you are trying to get the IP address for DNS name from a C# application, you should use the GetHostEntry method from the Dns class: http://msdn.microsoft.com/en-us/library/ms143998.aspx .

眼波传意 2024-10-16 11:13:48

您从 DNS 获取 IP,并需要它来执行 ping,因此您已经拥有它。

$ ping google.com
PING google.com (74.125.227.51) 56(84) bytes of data.
64 bytes from 74.125.227.51: icmp_seq=0 ttl=56 time=5.80 ms
64 bytes from 74.125.227.51: icmp_seq=1 ttl=56 time=6.23 ms

显示 IP。如果您没有获得 IP,则您的 DNS 可能已关闭。

您还可以尝试 nslookup google.com

You get IP from DNS, and need it to perform a ping, so you have it already.

$ ping google.com
PING google.com (74.125.227.51) 56(84) bytes of data.
64 bytes from 74.125.227.51: icmp_seq=0 ttl=56 time=5.80 ms
64 bytes from 74.125.227.51: icmp_seq=1 ttl=56 time=6.23 ms

The IP is shown. If you aren't getting an IP, your DNS might be down.

You can also try nslookup google.com

羁〃客ぐ 2024-10-16 11:13:48

Dns.GetHostEntry 中的主机名获取 IP 地址()。输入主机名,它会返回 IP 地址。

您没有理由需要 ping(无论如何联系)某个站点来获取其 IP 地址。 DNS 查找将为您提供所需的信息。

To get an IP address from a host name in Dns.GetHostEntry(). Pass in the host name and it will return you the IP address.

There is no reason you need to ping (on anyway contact) a site to get it's IP address. A DNS lookup will give you what you need.

冰雪梦之恋 2024-10-16 11:13:48

您可以使用 nslookup 来解析域名。

nslookup google.com

You can use nslookup to resolve domain names.

nslookup google.com

_畞蕅 2024-10-16 11:13:48

以下代码可用于对提供的主机名执行 DNS 查找。

使用 DNS 将绕过访问目标服务器。它是一个独立的分布式目录服务,维护主机名到 IP 地址的查找。

如果可以解析提供的主机名的 DNS 条目,以下代码将给出主机的第一个返回的 IP 地址。

    public void test()
    {
        string hostname = "google.com";
        IPAddress ipAdress;

        if (TryGetIpAddress(hostname, out ipAdress))
        {
            Console.WriteLine("Host:'{0}', IP:{1}.", hostname, ipAdress);
        }
        else
        {
            Console.WriteLine("Host '{0}' not found.", hostname);
        }
    }

    public bool TryGetIpAddress(string hostname, out IPAddress ipAddress)
    {
        const int HostNotFound = 11001;
        ipAddress = null;

        try
        {
            IPHostEntry hostEntry = Dns.GetHostEntry(hostname);

            ipAddress = hostEntry.AddressList[0];
        }
        catch (SocketException ex)
        {
            if (ex.ErrorCode != HostNotFound) throw;
        }

        return (ipAddress != null);
    } 

The following code can be used to execute a DNS lookup for the supplied host name.

Using DNS will bypass accessing the target server. It is an independant distributed directory service that maintains hostname to IP address lookups.

The following code will give the first returned IP address for a host if a DNS entry can be resolved for the supplied host name.

    public void test()
    {
        string hostname = "google.com";
        IPAddress ipAdress;

        if (TryGetIpAddress(hostname, out ipAdress))
        {
            Console.WriteLine("Host:'{0}', IP:{1}.", hostname, ipAdress);
        }
        else
        {
            Console.WriteLine("Host '{0}' not found.", hostname);
        }
    }

    public bool TryGetIpAddress(string hostname, out IPAddress ipAddress)
    {
        const int HostNotFound = 11001;
        ipAddress = null;

        try
        {
            IPHostEntry hostEntry = Dns.GetHostEntry(hostname);

            ipAddress = hostEntry.AddressList[0];
        }
        catch (SocketException ex)
        {
            if (ex.ErrorCode != HostNotFound) throw;
        }

        return (ipAddress != null);
    } 
江南月 2024-10-16 11:13:48

您可以使用tracert,它会解析IP地址并告诉您是否可以到达或停止在哪里。

You can use tracert and it will resolve the IP address and tell you if it can be reached or where it stops.

你爱我像她 2024-10-16 11:13:48

如果站点 (http) 已启动并正在运行,那么很明显系统/网络管理员禁用了 ping,并且很可能也禁用了跟踪路由实用程序。现在这种情况已经很常见了。请参阅此处。您的替代方法是使用此处所述的 ns 查找或 WHOIS 服务

If site (http) is up and running then it is very well clear that the sys/network admin disabled ping and most probably trace route utility too. It is getting very common now. See here. Your alternative is to use ns lookup or WHOIS service as described here

¢好甜 2024-10-16 11:13:48

在代码中执行此操作,您应该具有像 gethostbyname() 这样的函数。

这应该在 stackoverflow.com 上

Doing this in code you should have some function like gethostbyname().

This should be on stackoverflow.com

乖不如嘢 2024-10-16 11:13:48

未经测试

托管此网站

您可以http://centralops.net/co/DomainDossier.aspx

您 可以使用 import.io 来实现该网站的功能。

https://www.import.io/

此链接可以为您提供见解

untested

You could host this website

http://centralops.net/co/DomainDossier.aspx

you could use import.io to make functinality with the site.

https://www.import.io/

this links could give you an insight

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文