Apple Resources - Turn on Apple Firewall

Firewall security in macOS        

  macOS includes a built-in firewall to protect the Mac from
  network access and denial-of-service attacks. It can be
  configured in the Security & Privacy pane of System
  and supports the following configurations:
  o Lock all incoming connections, regardless of app.
  o Automatically allow built-in software to receive incoming 
  o Automatically allow downloaded and signed software to 
    receive incoming connections.
  o Add or deny access based on user-specified apps.
  o Prevent the Mac from responding to ICMP (Internet Control 
    Message Protocol) probing and portscan requests.

Turn On Firewall

Change Firewall settings on Mac   

Block connections to your Mac with a firewall   

Apple Platform Security