Note that there are some explanatory texts on larger screens.

plurals
  1. POKnowing the internal IP of an http request coming through NAT on a machine with multiple NICs?
    text
    copied!<p>Imagine a Windows box, which:</p> <ul> <li>hosts a WCF service</li> <li>has multiple NICs</li> <li>sits behind NAT</li> </ul> <p>When a user issues a request to the service (on top of the WCF infrastructure), he uses the external address assigned to the target machine by the NAT. </p> <p>I have to write some piece of code inside the WCF service, which must know which of the several NICs that the machine has was used to actually handle the network traffic. How does this code identify the NIC is less important - it could be its MAC address (the best) or it could be the (internal) IP address of the NIC.</p> <p>How can I do it?</p> <p><strong>EDIT1</strong></p> <p>I will try to supply the question context. There are two agents. Both expose the same WCF service. In addition, one of the agents can be instructed to start probing the network towards the second agent in the following fashion:</p> <ol> <li>Agent A is asked to probe the network to agent B</li> <li>Agent A negotiates with agent B the UDP port to utilize for the sake of probing using the WCF service exposed by the agent B.</li> <li>Once negotiation is over, the agent A starts some custom protocol over UDP, where the agent B acts as the server - i.e. it binds to the UDP port negotiated in the previous item.</li> </ol> <p>Binding to a UDP port requires two pieces - the IP address and UDP port, where the IP address can either be a specific IP address or * (to bind to all the IP addresses associated with the machine). The latter option is not good for us - I will omit the reasons. This leaves us the former option - binding to the specific IP address. However, when the agent B is behind NAT, the IP address used to talk to the WCF service is the external IP address assigned to the agent by the NAT. Binding, on the other hand, requires the respective internal IP address - how to get it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload