sudo nano /etc/pf.conf
Add lines like this to block ports,
as shown below.
block in quick inet proto { tcp, udp } from any to any port 20
This command tests the firewall configuration for errors:
sudo pfctl -vnf /etc/pf.conf
This command activates the firewall:
sudo pfctl -evf /etc/pf.conf
This command disables the firewall:
sudo pfctl -d