According to Apple's API documentation, the function DNSServiceNATPortMappingCreate "Requests a port mapping in the NAT gateway, which maps a port on the local machine to an external port on the NAT." This function has been available to developers for more than five years, and it continues to work fine on macOS 11.6.1 Big Sur. It's not marked as deprecated in the documentation or in the framework header files from the macOS 12 SDK. However, the function simply doesn't work on macOS 12 Monterey and never has. I filed a bug in Apple's Feedback Assistant on June 8, the day after we got the first developer preview of Monterey at this year's Worldwide Developers Conference. I know of several other developers who also filed the same bug. Yet almost 5 months later, with Monterey having been released already to the general public, DNSServiceNATPortMappingCreate still doesn't work. I've heard that the bug hasn't been fixed in the macOS 12.1 beta either. Any software that relies on DNSServiceNATPortMappingCreate is out of luck on Monterey.
Here's the sample Xcode project that I submitted to Apple demonstrating the bug. There's actually no error code in the DNSServiceNATPortMappingReply callback, it just returns 0 for the external port every time.
It's inaccurate to say that DNSServiceNATPortMappingCreate is now "deprecated". Deprecated API are officially announced by Apple as deprecated, and deprecated API continues to work for a period of time after deprecation is announced, sometimes indefinitely. In this case, on the other hand, DNSServiceNATPortMappingCreate isn't deprecated, it's simply dead. It abruptly died, with no announcement at all by Apple, and no deprecation period. Apple engineering has refused to comment on the issue or offer any kind of guidance to developers who rely on the API. This is the most irresponsible behavior possible from a platform vendor. It's truly shameful. Apple tells developers to file bugs as soon as possible during WWDC, and we did, for all the good it did us! But the worst part isn't the lack of a fix, it's the total lack of communication from Apple.