Http 请求 - 绕过 DNS [.Net] [英] Http Request - Bypass DNS [.Net]
问题描述
是否有可能(如果有,如何)在执行 HTTP 请求时绕过 DNS?
Is it possible (and if yes, how) to bypass DNS when doing a HTTP request ?
我想直接使用 HTTP 请求访问前端,而不通过 NLB 但使用正确的主机标头.因为我有我的服务器的 IP,所以我只需要绕过 DNS.
I want to hit directly a front-end with an HTTP request, without getting through NLB but with the correct host header. As I have the IP of my server, I just need to bypass the DNS.
我尝试使用 WebRequest,将 URL 替换为 IP 并设置 Host 标头,但此标头受到保护.
I tried to use WebRequest, replacing the URL with the IP and setting the Host header, but this header is protected.
我该怎么做?我需要自己创建 HTTP 请求吗?
How can I do that ? Do I need to create the HTTP request myself ?
注意:编辑主机文件不是一种选择
Note: editing host file is not an option
推荐答案
我设法做我需要的事情,将代理设置为远程服务器的 IP 地址:
I manage to do what I need setting the proxy to the IP address of the remote server :
request.Proxy = new WebProxy(ip.ToString());
它并不适用于所有情况,但在我的情况下确实适用.
It doesn't work in all scenarios, but it did in my case.
这篇关于Http 请求 - 绕过 DNS [.Net]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!