DNSServiceNATPortMappingCreate always returning error code -65540 <p>I'm doing an ios application, it starts a server and listen for incoming connections, the device running the application may be behind a router so I need to make a port forward. I'm trying to make a port forward using DNSServiceNATPortMappingCreate but its always returning error code -65540</p> <pre><code>DNSServiceRef *sdRef = NULL ; void ( *DNSServiceNATPortMappingReply) (DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, uint32_t externalAddress, DNSServiceProtocol protocol, uint16_t internalPort, uint16_t externalPort, uint32_t ttl, void *context ); DNSServiceNATPortMappingReply = &amp;DNSServiceNATPortMappingCreate_callback ; DNSServiceErrorType error = DNSServiceNATPortMappingCreate(sdRef, 0, 0, kDNSServiceProtocol_TCP, htons(2000), htons(5000), 0, DNSServiceNATPortMappingReply, NULL ) ; </code></pre> <p>and this is the callback</p> <pre><code>void DNSServiceNATPortMappingCreate_callback( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, uint32_t externalAddress, DNSServiceProtocol protocol, uint16_t internalPort, uint16_t externalPort, uint32_t ttl, void *context ) { printf("in callback\n") ; } </code></pre>