2

Im sorry if this been asked before, but couldnt find anything about this particular matter.

I try to find out with which of my own ip's my computer use to connect to a remote ip. I use some kind of socket setup both ways etc, and im sending my ip (and other stuff with xml) to another server so it knows how to contact me. But how do i figure out which ip i should send to it? I have the servers ip or host name, but trying with

Dns.GetHostEntry("host").AddressList

But that only gives me the ip of the remote host and not how my computer reach it.

Is my question solveable at all or is this just wishful thinking?

7
  • See: alperguc.blogspot.com/2008/11/… maybe? Commented Jan 11, 2012 at 3:19
  • 2
    Sending your local IP would be useless if you're behind a NAT gateway (e.g most home routers, cellular connection, etc...). It'd be (say) 10.x.x.x and be unreachable from the outside. Commented Jan 11, 2012 at 3:20
  • Minitech: Was thinking about that as well, but if the user have several lans, for example VM's its hard to know which one is related to the server in connecting to. Commented Jan 11, 2012 at 3:24
  • Marc B: That is a calculated risk in this content :) Most user of this will know that they need a public ip to connect over the internet. But this will mainly go in internal networks. Commented Jan 11, 2012 at 3:25
  • Is this even necessary? If you connect to the server first, it knows what IP you connected from and thus can use that to "call you back", assuming NAT is not involved. All you need to tell the server is the port number you're listening on. Commented Jan 11, 2012 at 3:37

3 Answers 3

0

Can you have the remote host capture that data? That end would surely have it.

Sign up to request clarification or add additional context in comments.

1 Comment

That is a option i have considered, but that part is not built inhouse. But raising the issue cant hurt, it cant be hard for them to fix it i guess.
0

If you're using UDP then this is exactly what the STUN protocol was designed for. STUN is used in VOIP applications (among other P2P systems) to be able to tell what a specific connection looks like on the internet.

One very reliable .NET implementation that implements STUN is included in the Lumisoft.NET library (source code available here). I've used it myself for to satisfy this specific task for applications ranging from VOIP to P2P VPN alternatives. It is very easy to use and is standards compliant.

NOTE: I am NOT in any way affiliated with Lumisoft, I've merely used their library in several different applications

1 Comment

On second thought this only applies in limited circumstances and your question is unspecific. It'll work if your application is UDP, you want your application to work on the greater internet, and you're behind a router that supports STUN as a traversal mechanism.
0

Ok, quick update that wont help anyone except myself.

But.

Found out that i can send hostname instead of actual ip, will work for now and most cases, and let the DNS do what its suppose to do :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.