title: NAT translation not working from inside the network (hairpin condition)
body: <p>I'm writing a P2P application. Peers regularly ping a main server to update their current IP/port, so when a peer wants to reach another one it can ask the server for that information. For now peers use UPnP to configure the NAT (for classic home setups) to be accessible from outside. </p>
  
  <p>So everything works, except when a peer's client tries to reach another (or the same) peer's server and both are behind the same NAT. <strong>Since in that case the client is trying to reach its own "external" (public) IP address from behind the NAT, the NAT doesn't do the port forwarding and is unable to route the IP packet.</strong></p>
  
  <p>For now I'm thinking of two solutions:</p>
  
  <ul>
  <li>query the NAT with UPnP to see to which local IP the port is forwarded</li>
  <li>store on the main server the internal IPs of the peers</li>
  </ul>
  
  <p>Can you think of other solutions? What strategies do mainstream P2P applications implement to solve this problem?</p>