IP地址返回问题 [英] IP Address Returning Question

查看:74
本文介绍了IP地址返回问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ping成员从2台不同的计算机ping网站。第一台计算机是网站服务器,其中存储了网站的所有文件等。运行测试的第二台计算机是不托管这些文件的计算机,因此任何计算机都不是服务器。


这是我的代码:

I am using a Ping member to ping a website from 2 different computers. The first computer is the websites server where all the files etc for the website are stored. The second computer running the test is a computer not hosting those files, so any computer not the server.

Here is my code:

展开 | 选择 | Wrap | 行号

推荐答案

这实际上是一个网络类型问题。服务器不知道它自己的外部IP地址。那是路由器处理的东西。 URL的DNS解析是本地的,因此它ping本地地址。


您需要找出此Web服务器的外部地址,并ping该IP而不是URL本身。


如果您希望以编程方式获取计算机的IP地址,则可以使用 WhatIsMyIp.com的自动化页面。详细了解此处
This is really a network type question. The server doesn''t know it''s own external IP address. That''s something a router handles. The DNS resolution to the URL is local, so it pings the local address.

You''d need to find out the external address of this web server, and ping that IP rather than the URL itself.

If you were looking to programatically obtain a machine''s IP address, you could use WhatIsMyIp.com''s Automation page. Read more about that here.


因此,当我从非服务器计算机ping该站点时,它从该服务器路由器返回一个IP地址,但是当服务器本身尝试ping该站点时,它收集其本地IP而不是通过路由器返回的内容。所以为了从服务器获得相同的返回IP地址,我需要像WhatIsMyIp.com这样的东西在我的服务器上发回请求,这样它就可以告诉我从路由器返回的IP地址是什么,对吗?


当我使用Ping成员时,它会在一个非常干净的可用变量中返回Address。当我使用whatsmyip.com/automation时,我假设我必须做一些格式化来清理任何类型的返回数据,所以我只返回了所需的IP地址?
So when I ping the site from the non sever computer it returns an IP address from that servers router, but when the server itself tries to ping the site it gathers its local IP not what is returned via the router. So in order to get the same returned IP address from the server I need to have something like WhatIsMyIp.com to send the request back at my server so it can tell me what it gets returned from the router as the IP address, correct?

When I use the Ping member it returns the Address in a very clean use-able variable. When I use the whatsmyip.com/automation I assume I will have to do some formatting to clean up any kind of returned data so I have just the needed IP address returned?


那个页面应该只需用字符串回复。没有HTML,除了IP地址的字符外什么也没有。您可以将它们拆分为''。''并从中创建一个IP。
That page should just respond with a string. No HTML, nothing except for the characters of your IP address. You could split them around ''.'' and make an IP out of it.


这篇关于IP地址返回问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆