Security and certificates

Turn on the firewall

Switch on the built-in firewall so your computer turns away connections it didn't ask for.

  1. Turn the firewall onNeeds sudo
    Terminal
    sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

Check it worked

  1. Check it's on
    Terminal
    /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

    It should say the firewall is enabled.

Undo it
  1. Turn it offNeeds sudo
    Terminal
    sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
  1. Keep remote access workingNeeds sudo
    Terminal · Ubuntu / Debian
    sudo ufw allow OpenSSH

    Only needed if you connect to this machine over SSH. Do it first, so you don't lock yourself out.

  2. Turn the firewall onNeeds sudo
    Terminal · Ubuntu / Debian
    sudo ufw enable

Check it worked

  1. Check it's on
    Terminal · Ubuntu / Debian
    sudo ufw status

    It should say Status: active.

Undo it
  1. Turn it offNeeds sudo
    Terminal · Ubuntu / Debian
    sudo ufw disable
  1. Turn the firewall on for every networkRun as administrator
    PowerShell
    Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

Check it worked

  1. Check it's on
    PowerShell
    Get-NetFirewallProfile | Select-Object Name, Enabled

    Every row should say True.

Undo it
  1. Turn it offRun as administrator
    PowerShell
    Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

    Only do this briefly, for example while fixing a problem.

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