在每次点击的基础上伪造 DNS 解析

发布于 2024-09-26 02:08:11 字数 674 浏览 1 评论 0原文

我正在编写一个应用程序,其唯一目的是确定我们的核心应用程序之一是否已在生产中启动并运行。该应用程序是一个WCF应用程序。该应用程序在负载均衡器后面的两个不同的盒子上启动并运行。每个框中的站点配置为侦听以下 DNS 名称的流量:app.company.com。 DNS 将 app.company.com 解析为我们的负载均衡器,然后负载均衡器以循环方式将请求传递给两个盒子之一。在确定我们的核心应用程序是否已启动方面,仅向负载均衡器发送请求是不可接受的,因为负载均衡器可能会将我们循环到活动服务器,即使其中一台服务器已关闭并且我们的应用程序需要能够以确定其中一个盒子是否已关闭。是的,负载均衡器已经在有限的范围内检查服务器是否已启动,但它并没有涵盖所有场景。

我遇到的问题是我无法将流量直接发送到每个盒子(通过 IP 或主机名),因为主机标头 (app.company.com) 必须位于请求中,否则目标服务器或 WCF 将拒绝它。如果我使用 app.company.com 而不是主机名或 IP 地址,我将使用负载均衡器,如果我修改计算机上的主机文件,它将仅适用于一台机器。

有没有办法强制 .Net 或 Windows 中的 DNS 解析将 app.company.com 解析为我选择的 IP 地址,并且可以针对每个请求进行微调,而不影响整个系统的 DNS?否则,我可能会考虑手工制作一个请求,以便我可以在请求中嵌入正确的主机标头,而实际上不会到达相同 DNS 名称的目标。

谢谢

I'm writing an app that's sole purpose is to determine if one of our core applications is up and running in production. This application is a WCF application. The app is up and running on two different boxes behind a load balancer. The site on each box is configured to listen to traffic for the following DNS name: app.company.com. DNS resolves app.company.com to our load balancer which then hands the request off to one of the two boxes in a round robin fashion. In terms of determining if our core application is up it is not acceptable to just hit the load balancer with a request as the load balancer might round robin us to an active server even if one of the servers is down and our app needs to be able to determine if one of the boxes is down. Yes the load balancer already checks to a limited extent that the server is up but it doesn't cover all scenarios.

The problem I'm having is I cannot send traffic directly to each box (by IP or host name) as the host header (app.company.com) has to be in the request or either the destination server or WCF will reject it. If I use app.company.com instead of the host name or IP address I'll hit the load balancer, if I modify the hosts file on the machine it will only work for one box.

Is there a way to force DNS resolution within .Net or Windows to resolve app.company.com to an IP address of my choosing in a way that can be fine tuned for each request and not affect DNS for the entire system? Elsewise I will probably be looking at hand crafting a request so that I can embedd the correct host header in a request not actually going to the target of the same DNS name.

Thanks

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

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

发布评论

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

评论(2

无敌元气妹 2024-10-03 02:08:11

它的负载均衡器按每次点击分配 DNS(正如您所说,以循环方式),因此您无法从客户端超载。您也许可以配置负载平衡器,以便来自特定 IP 的请求不会获得负载平衡,但如果您需要通过 DNS 检查两个负载平衡应用程序,这并没有多大帮助。

因此,您需要重新考虑如何解决这个问题。

一种策略是让负载平衡应用程序报告它们正在运行,而不是单独的应用程序检查。

或者让每个应用程序定期将带时间戳的文件更新到服务器上,以便您的应用程序可以通过 IP 地址分别到达这些盒子并检查是否存在带时间戳的文件。

Its the load balancer that is assigning DNS on a per-hit basis (as you said, in round robin fashion), so you cant overload that from the client side. You may be able to configure your load balancer so that requests from a specific IP don't get load balanced, but that doesn't much help if you need to check both load balanced apps via DNS..

Therefore you need to rethink how to tackle this.

One strategy is to have the load balanced apps report out that they are operational, rather than a separate app checking in.

Alternatively have each app periodically update a timestamped file onto the server so that your app can reach the boxes separately by IP address and check for the presence of the timestamped file.

来日方长 2024-10-03 02:08:11

我找到了解决这个问题的好办法。我最终做的是在同一个 Web 应用程序中创建第二个服务,然后我更改了每台计算机上的主机文件以包含将 localhost 指向 app.company.com 的行。

127.0.0.1     app.company.com

然后我将这个新服务配置为指向“app.company.com”。

这允许我通过第二个服务直接通过主机名或 IP 地址访问服务器,并且第二个服务通过主机名与测试中的服务进行通信。

这非常适合我们想要的。

I found a good solution to this problem. What I ended up doing is creating a second service in the same web application, then I changed the hosts file on each of the machines to contain a line pointing the localhost to app.company.com.

127.0.0.1     app.company.com

I then configured this new service to point to "app.company.com".

This allowed me to hit the server directly by host name or IP address via the second service and the second service communicated to the service under test by host name.

This works perfectly for what we were wanting.

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