How can I block Nmap scanning on macOS?

The nmap tool is tricky and designed to evade firewalls, so you might need a hardware firewall or assistance from a network administrator based on how skilled the operator of nmap is.

You can’t be on a network and remain totally invisible.

That being said, enabling the firewall and configuring it to drop incoming connections is usually good enough.

  • https://support.apple.com/en-us/HT201642

Be sure to go into advanced and choose Block all incoming connections

This breaks many functions for sharing out, which is precisely what nmap detects.