How to open a port in macOS Sierra 10.12.4
The linked How-to is wrong!
You simply can't open a port in a firewall. You can block a port or not. By default pf is disabled and doesn't block anything. If you enable stealth mode in the Application Firewall, pf will be enabled via the com.apple/250.ApplicationFirewall anchor with a very limited set of rules:
scrub in all fragment reassemble
block drop in inet proto icmp all icmp-type echoreq
block drop in inet proto icmp all icmp-type echoreq
block drop in inet6 proto ipv6-icmp all icmp6-type echoreq
Except incoming IPv4/6 ICMP echo request, pf won't block anything. The default pf.conf doesn't contain any block all ...
or allow all ...
rules.
To open a port on your host, you have to launch an app which opens a listening port. Example nc:
nc -l 12345
After entering the command you will be asked to accept incoming network connections for nc by the Application Firewall.
To connect to nc listening at port 12345 from remote simply enter nc hostname 12345
on a second host (replace hostname with the host name of the Mac running nc).
You can check open ports from remote by entering nmap hostname -Pn
(if stealth mode is enabled).