471,338 Members | 1,084 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Determine IP address of Network Load Balanced server at runtime

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!


Jun 27 '08 #1
6 3241
On Apr 30, 1:40 pm, "BA" <biztalk.archit...@gmail.comwrote:
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..
Jun 27 '08 #2
BA wrote:
>
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.
Jun 27 '08 #3
BA

"Chris Shepherd" <ch**@nospam.chsh.cawrote in message
news:Ox**************@TK2MSFTNGP05.phx.gbl...
BA wrote:
>>
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.

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


Jun 27 '08 #4
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/libr...05(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.

Jun 27 '08 #5
On Wed, 30 Apr 2008 11:14:27 -0700, BA <bi***************@gmail.comwrote:
[...]
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.

In general network applications, the usual answer to a question like this
is that the remote end (i.e. your "trading partner") already knows the IP
address. You should have some way of resolving your connection to some
lower-level network object that already has the IP address. For example,
a connected Socket can return the endpoint addresses (for the trading
partner end, your server farm will be the remote address). Or if this is
over UDP, then the receiving method will be able to return the IP address
for a given datagram received.

Since I'm unfamiliar with the specifics with respect to the NLB
architecture, I don't know whether that affects how you're making the
network connection or what sort of objects are involved. But surely there
is some way to resolve these objects to a lower-level object, assuming
you're not already dealing with such.

There is practically never a need for one end of a network communication
transaction to have to communicate its own address to the other end. If
it can communicate anything to the other end, then the other end already
has at least as good information about the first end's address than the
first end could come up with.

Pete
Jun 27 '08 #6
Peter Duniho wrote:
On Wed, 30 Apr 2008 11:14:27 -0700, BA <bi***************@gmail.comwrote:
>[...]
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.
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by ferpino | last post: by
1 post views Thread by msuk | last post: by
8 posts views Thread by Steven Van Dyke | last post: by
4 posts views Thread by Selden McCabe | last post: by
8 posts views Thread by MrNobody | last post: by
25 posts views Thread by _DD | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.