I am trying to follow up on this thread and to update it for macOS Sierra (and probably all versions since Yosemite).
In that thread, a way to open a single port in the OS's firewall was suggested:
sudo ipfw add 40000 allow tcp from any to any dst-port portnum
However, since Yosemite, ipfw was replaced with pf and, unless I am mistaken, pfctl should therefore be used.
What would the above command translate to?