简体   繁体   English

将ASP.NET(MVC)中的DNS解析为主机名/代理

[英]Resolving DNS in ASP.NET (MVC) to Host Name/Proxy

Alright, this question sounds a bit stupid, I know. 好吧,我知道这个问题听起来有点愚蠢。 I've looked at some of the other questions about it and I'm getting inconsistent results, even though I am finding the right answers. 尽管我找到了正确的答案,但我已经查看了有关此问题的其他一些问题,但结果却不一致。 I'll try to lay it out as plainly as I can. 我会尽力将其布局。

I have a problem where a large number of visitors to my site are using a ...I use the term popular very loosely, internet service (AOL) to access it. 我有一个问题,我的网站的大量访问者正在使用...我使用非常宽松的术语,互联网服务(AOL)来访问它。 This is beyond my control. 这超出了我的控制范围。 It is a large part of the userbase and I cannot stop them from using its built in browser (which derives from IE). 它是用户群的很大一部分,我无法阻止它们使用其内置的浏览器(源自IE)。

Now, this isn't the inherit problem. 现在,这不是继承问题。 The problem is that any sites accessed through the browser go through one of their proxies. 问题在于,通过浏览器访问的任何网站都将通过其代理之一。 This does not cause any conflicts, but we need to know who is unique and who isn't for some specific reasons. 这不会引起任何冲突,但我们需要知道谁是独特的,谁不是出于某些特定原因。

I have an installation of a popular message board system called "Invision Power Board". 我安装了流行的留言板系统,称为“ Invision电源板”。 It tracks people's IP Address's and it has a feature to resolve an IP. 它跟踪人们的IP地址,并具有解析IP的功能。 So, I can click on an IP, and it will 'resolve' to a host like .. 所以,我可以点击一个IP,它将“解析”给像这样的主机。

IP XX.XXX.XX.XXX resolves to cache-dtc-ae16.proxy.aol.com . IP XX.XXX.XX.XXX解析为cache-dtc-ae16.proxy.aol.com

Now I understand kind of what is going on here. 现在我明白了这里发生了什么。 cache-dtc-ae16.proxy.aol.com is a proxy, so I can't do much about that. cache-dtc-ae16.proxy.aol.com是代理,所以我不能做太多事情。 I've come to terms with that. 我已经同意了。 The code that does this is in IPB, and I don't speak PHP, so I'm SOL in that department. 执行此操作的代码是在IPB中,我不会说PHP,所以我在那个部门是SOL。

I know how to get a User's IP Address. 我知道如何获取用户的IP地址。

HttpContext.Request.UserHostAddress

What I want to know is this ... from an IP, how can I 'resolve' to that proxy, in C#? 我想知道的是......来自IP,如何在C#中“解析”到该代理? I basically want to setup a specific part of code that denies anything from a proxy that has .aol. 我基本上想设置代码的特定部分,以拒绝来自具有.aol的代理的任何内容。 in it. 在里面。

Does what I am trying to make any sense, is it even feasible or possible? 我想要做的是什么,甚至是可行的还是可能的? I may be completely missing the terminology. 我可能完全错过了该术语。 I believe I understand this much. 相信我理解这么多。

UserHostAddress is the **client's** IP Address

Here is what I have tried, basically. 基本上,这是我尝试过的。

System.Net.Dns.GetHostEntry(System.Net.IPAddress.Parse(HttpContext.Request.UserHostAddress)).Aliases

are you trying to get the domain name from the ip? 你想从ip获取域名吗? it looks like your answer is in this question here 它看起来像你的回答是这个问题在这里

IPHostEntry IpToDomainName = Dns.GetHostEntry("209.85.129.103");
string HostName = IpToDomainName.HostName; //it returns "fk-in-f103.1e100.net"

This is a limitation of TCP protocol. 这是TCP协议的限制。 The address is part of the TCP packet and as far as I know, routers and switches and NATs and proxies change the address and put their own. 该地址是TCP数据包的一部分,据我所知,路由器和交换机以及NAT和代理会更改地址并自行设置。

As far as I know, there is no way around it. 据我所知,没有办法解决它。 Proxy's address is as good as you gonna get. 代理商的地址和你要的一样好。

I believe even TCP packet's MAC (physical) address is going to be proxy's but that is something to look at although not sure if you can get that in ASP.NET runtime since a request can come in multiple TCP packets. 我相信即使是TCP数据包的MAC(物理)地址也将是代理服务器,但是这是值得关注的,尽管不确定您是否可以在ASP.NET运行时获得该数据包,因为请求可以包含多个TCP数据包。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM