Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been reading the NAT traversal requiring the use of an external STUN server. There are few public STUN servers but I do not know how to use them to find out my public IP that can be used by the other client to initiate the connection. Being a noob in this, I am not able to find out the correct documents for this using the BSD sockets. If someone can explain how can i find my public IP taking BSD sockets as base would be good. Also if you can provide good links for this, it wpuld also be appreciated.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It's in the STUN bind response. RFC 5389, the STUN specification, explains how on page 7:

The STUN server copies that source transport address into an XOR-MAPPED- ADDRESS attribute in the STUN Binding response and sends the Binding response back to the STUN client. As this packet passes back through a NAT, the NAT will modify the destination transport address in the IP header, but the transport address in the XOR-MAPPED-ADDRESS attribute within the body of the STUN response will remain untouched. In this way, the client can learn its reflexive transport address allocated by the outermost NAT with respect to the STUN server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.