Change Firewall preferences on Mac
Use the Firewall pane of Security & Privacy preferences to turn on the firewall in macOS to prevent unwanted connections from the internet or other networks.
To open this pane on your Mac, choose Apple menu > System Preferences, click Security & Privacy, then click Firewall.
Turn On Firewall
If the firewall is turned off, click Turn On Firewall to turn on firewall protection.
Click the Firewall Options button to change firewall settings.
Block all incoming connections
In Firewall Options, select to prevent incoming connections to nonessential services and apps.
Basic internet services are a set of apps that allow your Mac to find services provided by other computers on the network. This setting prevents connections to all other sharing services.
In Firewall Options, to add an app or service, click the Add button , select the item in the list, then use the Up Arrow and Down Arrow keys to set the limits for the app.
In Firewall Options, to remove an app, select it in the list, then click the Remove button .
Automatically allow built-in software to receive incoming connections
Automatically allow downloaded signed software to receive incoming connections
In Firewall Options, select to allow downloaded apps and services that are signed by a valid certificate authority to be automatically added to the list of allowed apps, without your authorization.
Enable stealth mode
In Firewall Options, select to prevent your Mac from responding to probing requests that can be used to reveal its existence. The Mac still answers requests from authorized apps, but unauthorized requests such as ICMP (ping) get no response.
Locks or unlocks Security & Privacy preferences. Click the lock icon to unlock it, then enter an administrator name and password.
Click to increase the security on your Mac by adjusting specific settings in the Change Advanced preferences.
Certain shared services can connect through the firewall when they are turned on in Sharing preferences. For additional security, you can prevent connections to these incoming services by turning off the service in Sharing preferences. See Share your Mac screen, files, and services with other users on your network.