Determine IP address of Network Load Balanced server at runtime

  • Thread starter Thread starter BA
  • Start date Start date
B

BA

Hi Everyone,

I have an application that sits behind a server farm, the application needs
to pass its NLB IP address in the message that it sends to another service.
From C# code, how can I determine the IP address of the network load
balanced machine that the message is generated from?

So, in essence, I have server1, server2 and server3 sitting behind the NLB
IP address 100.1.2.100, then I have server4 and server5 sitting behind NLB
IP 200.1.2.200 how can server1 figure our what IP address its sitting behind
so it can pass that info (100.1.2.100) into the message I want to send?

Thanks!
 
BA said:
Hi Everyone,

I have an application that sits behind a server farm, the application
needs to pass its NLB IP address in the message that it sends to another
service. From C# code, how can I determine the IP address of the network
load balanced machine that the message is generated from?
So, in essence, I have server1, server2 and server3 sitting behind the
NLB IP address 100.1.2.100, then I have server4 and server5 sitting
behind NLB IP 200.1.2.200 how can server1 figure our what IP address its
sitting behind so it can pass that info (100.1.2.100) into the message I
want to send?

Unless you are doing NLB without NAT/IP Masquerading, you probably can't.

As I understand it, your setup is:

A - { server1, server2, server3 }
B - { server4, server5 }

A has IP 100.1.2.100, B has IP 200.1.2.200.

Scenario:
- server1 sends a message to B, not a specific server behind it.
- server5 winds up servicing the request, but as far as it can tell, it's coming
from A**

When a request is served through A (NLB)it will look like it is coming from
100.1.2.100, and when the response is served back from B (NLB) it will look like
it's coming from 200.1.2.200.

You may want to provide additional details, as depending on the type of load
balancing, it may be possible. Frequently though, load balancing is done at the
network layer with the traffic itself being routed round-robin style.

With more details of your current setup and what you're looking to accomplish
I'm sure you will get a better answer.

Chris.
 
Hi Everyone,

I have an application that sits behind a server farm, the application needs
to pass its NLB IP address in the message that it sends to another service.
From C# code, how can I determine the IP address of the network load
balanced machine that the message is generated from?

So, in essence, I have server1, server2 and server3 sitting behind the NLB
IP address 100.1.2.100, then I have server4 and server5 sitting behind NLB
IP 200.1.2.200 how can server1 figure our what IP address its sitting behind
so it can pass that info (100.1.2.100) into the message I want to send?

Thanks!

I am not sure if that is possible. There could be some way of
querying the LB.. may be web scrap the LB admin site..

but what you can do is create a domain name that points to
100.1.2.100 and resolve it and pass to the other server..
 
Chris Shepherd said:
Unless you are doing NLB without NAT/IP Masquerading, you probably can't.

As I understand it, your setup is:

A - { server1, server2, server3 }
B - { server4, server5 }

A has IP 100.1.2.100, B has IP 200.1.2.200.

Scenario:
- server1 sends a message to B, not a specific server behind it.
- server5 winds up servicing the request, but as far as it can tell, it's
coming from A**

When a request is served through A (NLB)it will look like it is coming
from 100.1.2.100, and when the response is served back from B (NLB) it
will look like it's coming from 200.1.2.200.

You may want to provide additional details, as depending on the type of
load balancing, it may be possible. Frequently though, load balancing is
done at the network layer with the traffic itself being routed round-robin
style.

With more details of your current setup and what you're looking to
accomplish I'm sure you will get a better answer.

Chris.


Thanks Chris,

Let me try to clarify.

Lets aggregate the servers in the 2 NLB enviornments so we just look at the
2 different NLB farms 100.1.2.100 and 200.1.2.200. Messages are being sent
from these 2 distinct environments to an external trading partner, not to
eachother.

I just need to determine what the IP of the farm that the message is being
generated within and put it into the message that I need to send to the
trading partners. No other action is required, its just a part of the
requirements of the application that the trading partner know what NLB farm
this message was generated from.

We'll be using the standard windows NLB.

Does this clarify?

BA
 
BA wrote:
[...]
I just need to determine what the IP of the farm that the message is
being generated within and put it into the message that I need to send
to the trading partners. No other action is required, its just a part
of the requirements of the application that the trading partner know
what NLB farm this message was generated from.

We'll be using the standard windows NLB.

Does this clarify?

Yes it does. According to MSDN you can rig something up using WMI:
http://msdn.microsoft.com/en-us/library/cc296105(VS.85).aspx

Check the "enumerating nodes" section, as well as the Provider Reference. You'll
be looking for the MicrosoftNLB_Cluster class and its InterconnectAddress I believe.

Chris.
 
Peter said:
[...]
I just need to determine what the IP of the farm that the message is
being generated within and put it into the message that I need to send
to the trading partners. No other action is required, its just a part
of the requirements of the application that the trading partner know
what NLB farm this message was generated from.

Granted, I'm sure I know less about the actual load-balancing
architecture than the other respondents so far. But it sounds to me as
though that may actually be a moot point.

Most of the rest of your reply is correct in the general sense. In this
particular instance, it appears to be more of a case of a service identity issue
than anything else.

It strikes me that you could simply have a configuration directive for the
services themselves which dictate which cluster they appear to be responding
from, rather than using WMI to query the Windows NLB service.

Chris.
 
Back
Top