开发者

Can I specify an IP when connecting to a URL?

I have a load balancer sitting on www.someurl.com, resolving to 100.100.100.100. There are two servers being balanced: 100.100.100.101 and 100.100.100.102. This is in order to create a health check which will make sure that the balanced sites are both alive.

Is there any way I can connect to the host www.someurl.com but specify which IP I want to actually connect to? I am implementing 开发者_开发技巧this solution in C# and have looked into using HttpWebRequest and also Sockets.


I have used two methods to accomplish this. First, you can use your hosts file to map the domain name to .101 or .102. Or, you can create new dns entires (www1.someurl.com and www2.someurl.com) that map to each server.

Let me know if you need more detail on either of these methods.


Is there any way I can connect to the host www.someurl.com but specify which IP I want to actually connect to?

If those IP addresses are publicly accessible from the client, then yes, you can directly specify the IP (var request = WebRequest.Create("http://100.100.100.101");). But I suspect that this is not your case. The IP addresses are not directly visible from where you are sending the request, only the load balancer is. In this case you can only send a request to this load balancer of course.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜