简体   繁体   English

使用全局URL访问页面时,为什么用户的IP是本地IP?

[英]Why does the user's IP is a local one when accessing the page using the global URL?

I am logging every user's IP when they access the company's page. 我正在记录每个用户访问公司页面时的IP。

There are two ways to access the page from inside the local network: 有两种从本地网络访问页面的方法:

http://company/webpage

and

https://webpage.company.com

What bugs me is that even when the users use the https global IP, their accesses are still recorded on database with their IP as 10.50.1.12 or 10.50.1.100 . 让我感到烦恼的是,即使用户使用https全局IP,他们的访问仍会记录在IP为10.50.1.1210.50.1.100

Does that means that the browser or something else is redirecting the https://webpage.company.com to company/webpage ? 这是否意味着浏览器或其他工具正在将https://webpage.company.com重定向到company/webpage Or does that mean that I'm using a flawed method to log the users IP? 还是那意味着我正在使用一种有缺陷的方法来记录用户IP?

Another way to ask my question (just to make sure I'm being clear): if I'm accessing my Internet web page from inside the LAN network, am I effectively going outside my network and then back? 提出问题的另一种方式(只是为了确保我清楚):如果我是从LAN网络内部访问Internet网页,那么我是否有效地走出网络然后又返回? If not, where am I going wrong with my logging? 如果没有,我的日志记录哪里出问题了?

Code used to log user's IP: 用于记录用户IP的代码:

user.LastIP = HttpContext.Current.Request.UserHostAddress;

I'm curious about this because I want to make sure the users inside the company will access the page using exclusively the LAN Network . 我对此很好奇,因为我想确保公司内部的用户将仅使用LAN网络访问该页面。 The goal is to save bandwidth usage , which is scarce. 目的是节省带宽的使用 ,这是稀缺的。

Edit: 编辑:

Pinging the https://webpage.company.com from inside the LAN network will result in a reply from a global IP address like 194.xxx.xxx.xxx . 从LAN网络内部对https://webpage.company.com ping操作将导致来自诸如194.xxx.xxx.xxx类的全局IP地址的194.xxx.xxx.xxx So I'm clearly getting the user's IP wrongly. 因此,我显然是错误地获得了用户的IP。 What would be the ideal way of retrieving the IP from the page accessing entity? 从页面访问实体检索IP的理想方式是什么?

Access to http://company/webpage will result in a DNS lookup of the host name "company". 访问http:// company / webpage将导致对主机名“ company”的DNS查找。 To resolve this, DNS will need a fully qualified domain name (fqdn), so it will add a top level domain (according to the configured search list in the client). 要解决此问题,DNS将需要一个完全限定的域名(fqdn),因此它将添加一个顶级域(根据客户端中配置的搜索列表)。 In this example, it seems fair to assume that the fqdn will be "company.com". 在此示例中,假设fqdn将为“ company.com”似乎很公平。 This, in turn, may very well resolve to the same IP address as the "webpage.company.com". 反过来,这很可能会解析为与“ webpage.company.com”相同的IP地址。 You can check this by using dns lookup utilities like 'nslookup' and 'dig', or simply by using 'ping company' and 'ping webpage.company.com'. 您可以使用dns查找实用程序(如“ nslookup”和“ dig”)进行检查,也可以仅使用“ ping company”和“ ping webpage.company.com”进行检查。

The users IP addresses you mention, 10.50.1.12 and 10.50.1.100, seems to be the local IP addresses of the client hosts. 您提到的用户IP地址10.50.1.12和10.50.1.100似乎是客户端主机的本地IP地址。 I base this assumption on the fact that these IP addresses come from the RFC-1918 address range which is used for internal addresses. 我以这些IP地址来自用于内部地址的RFC-1918地址范围这一事实为基础。 My guess is that these are the correct IP addresses, and that your logging works fine. 我的猜测是这些是正确的IP地址,并且您的日志记录工作正常。

The users IP address you will log from accessing ' http://company/webpage ' and ' https://webpage.company.com ' should in most cases be the same. 在大多数情况下,您通过访问“ http:// company / webpage ”和“ https://webpage.company.com ”登录的用户IP地址应该相同。 You can see it this way: it doesn't matter what the target URL is, traffic is still coming from the same host, the same IP address. 您可以这样看:目标URL无关紧要,流量仍然来自同一主机,同一IP地址。

In any case, you most probably don't need to worry about any traffic leaving your local network. 无论如何,您很可能不必担心离开本地网络的任何流量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Global.asax文件重定向用户时发生错误::页面未正确重定向 - Error when Redirecting user using Global.asax file ::Page's not redirected properly 为什么一个URL的页面使用另一个URL的缓存页面? - Why is the page at one URL using the cached page from another URL? 为什么用户注销后页面上会启动authenticateRequest? - why does authenticateRequest fire on a page when user is logged out? 当用户在页面网址后输入“ //”时,为什么ASPX页面格式错误 - Why ASPX page gets malformed when user enter “//” after page url 为什么Keyoti的Conveyor有多个远程URL IP地址 - Why does Conveyor by Keyoti have multiple Remote URL IP Address 在 MVC6 中使用 ASP.NET Identity 时从控制器访问登录用户的字段 - Accessing the logged in User's fields from the controller when using ASP.NET Identity with MVC6 从托管网页访问用户控件的组成控件 - Accessing user controls’s constituent controls from a hosting web page c#为什么我的页面/用户控件仅支持一个事件处理程序 - c# Why does my page / user control only support one event handler 通过url路由访问页面时的jQuery对象预期错误 - JQuery object expected error when accessing page via url routing 用户输入错误的网址时,不显示自定义页面 - Custom page is not displayng when user mistyped url
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM