Sub topic 7
Stealth mode, blocking all incoming connections, and app rules
This chapter assumes you have already turned on the macOS application firewall and understand that a firewall filters incoming connections. You need administrator access and basic Terminal use. Once the firewall is on, three options control how strict it is: stealth mode, block all incoming connections, and per-app rules.
The three options at a glance
All three live in System Settings under Network, then Firewall, then Options. They are separate settings and you can combine them.
| Option | What it does | Typical use |
|---|---|---|
| Per-app rules | Allows or blocks incoming connections for each listed app | Everyday use on a home or office network |
| Stealth mode | Makes the Mac ignore probe requests such as ping | Public Wi-Fi, to be harder to discover |
| Block all incoming connections | Refuses everything except a few essential system services | Untrusted networks, where you share nothing |
Per-app rules
The application firewall works per application, not per port. When an app that is not yet in the list tries to accept an incoming connection, macOS may ask you to allow or deny it. Your answer is saved as a rule.
To manage rules:
- Open System Settings, then Network, then Firewall, then Options.
- Review the list of apps. Each has either "Allow incoming connections" or "Block incoming connections".
- Click the plus (+) button to add an app, or select an app and click the minus (−) button to remove its rule.
- Click OK.
Two related settings appear in the same pane. "Automatically allow built-in software to receive incoming connections" lets Apple-signed software through without a prompt. "Automatically allow downloaded signed software to receive incoming connections" does the same for apps signed by an identified developer. Turning the second one off means more prompts but tighter control.
Stealth mode
With stealth mode on, the Mac does not answer probe requests such as ICMP ping. It also does not respond to connection attempts on closed TCP and UDP ports. A scanner sweeping the network gets silence instead of an answer, so the Mac is harder to notice.
Stealth mode does not block connections to apps you have allowed. If you run a web server and allow it, other machines can still reach it when they know the address.
Block all incoming connections
This option blocks every incoming connection except those needed for basic Internet services. Those include DHCP, Bonjour and IPSec. Any app-specific "allow" rules are ignored while it is on.
Sharing features such as File Sharing, Screen Sharing and AirPlay receiver stop working for other devices. Turn it on when you are on a hotel or café network and do not need to share anything. Turn it off when you get home.
Checking and changing options from Terminal
The socketfilterfw tool reports each option. These commands only read the state.
/usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode
/usr/libexec/ApplicationFirewall/socketfilterfw --getblockallTo change a setting you need sudo. This turns stealth mode on:
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode onReplace on with off to reverse it. Run the read commands again afterward to confirm the change.
Common errors
- Sharing stops working. If File Sharing or Screen Sharing is unreachable from another device, check whether "Block all incoming connections" is on.
- An app keeps prompting. Unsigned or modified apps may ask again after each update because the system sees a changed app. Add an explicit rule for the app.
- Expecting outbound protection. The application firewall controls incoming connections only. It does not stop an app from connecting out.
- Assuming stealth hides everything. Stealth mode silences probes. It does not hide traffic your Mac sends, and allowed apps still respond.
Choosing settings
For most people on a trusted home network, leave the firewall on with built-in and signed software allowed. On public Wi-Fi, add stealth mode, or block all incoming connections if you share nothing. These options reduce exposure to the network. They do not protect a stolen Mac. FileVault and Find My cover that case.
Exercise
You are on café Wi-Fi and have File Sharing enabled for use at home. You turn on "Block all incoming connections" and a colleague at home can no longer reach your shared folder. Why, and what would you do when you return home?
Show answer
Block all incoming connections refuses everything except essential system services and ignores per-app allow rules, so File Sharing cannot accept connections. When you return to a trusted network, turn the option off in System Settings under Network, Firewall, Options. You can also run the sudo socketfilterfw command with the --setblockall off option.
Exercise
Which command shows whether stealth mode is currently enabled, and does it need sudo?
Show answer
Run /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode. Reading the state does not need sudo. Changing it with --setstealthmode does.