- Turn the firewall onNeeds sudo
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
Check it worked
- Check it's on
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstateIt should say the firewall is enabled.
Undo it
- Turn it offNeeds sudo
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
- Keep remote access workingNeeds sudo
sudo ufw allow OpenSSHOnly needed if you connect to this machine over SSH. Do it first, so you don't lock yourself out.
- Turn the firewall onNeeds sudo
sudo ufw enable
Check it worked
- Check it's on
sudo ufw statusIt should say Status: active.
Undo it
- Turn it offNeeds sudo
sudo ufw disable
- Turn the firewall on for every networkRun as administrator
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Check it worked
- Check it's on
Get-NetFirewallProfile | Select-Object Name, EnabledEvery row should say True.
Undo it
- Turn it offRun as administrator
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled FalseOnly do this briefly, for example while fixing a problem.

New to firewalls? I explain it in plain English on Layman Terms.