How to install and configure Zeek IDS (formerly Bro) on macOS

An easy guide to installing, configuring, and running Zeek IDS automatically on your Mac

Roberto Meléndez
Mac O’Clock
5 min readMar 20, 2021

--

Vector by Vecteezy

Zeek (formerly Bro) is a powerful open-source framework for network traffic analysis and security monitoring. In this step-by-step guide, I’ll show you how to install, configure, and run Zeek automatically on your Mac.

Installing Zeek

Prerequisites

  • Xcode or the Command Line Tools. To check if either is installed run:

Note: If you get an error, install them with: xcode-select --install

Installation

To install Zeek via Homebrew simply run:

Note: If you are using MacPorts, then execute: sudo port install zeek

Validation

To validate if Zeek was installed successfully, you can print the version withzeek -v:

Configuration

Fixing permissions

The official Zeek: FAQs documentation shows that systems using BPF (Berkeley Packet Filter) (e.g. macOS and FreeBSD) can allow users with read access to BPF devices to capture packets from it using libpcap. Therefore, execute the following commands to manually change BPF device permissions to allow users in the admin group to capture packets:

Important: If you don’t fix those permissions and you run the deploy command later on step 4, you’ll get this ugly message: Error: zeek terminated immediately after starting; check output with "diag"

Basic Configuration

Now that we fixed the permissions, let’s make some basic changes to the default configuration to start using Zeek.

  1. Choose the right interface to monitor in /usr/local/etc/node.cfg:

Remove the default value eth0 and use en0 or similar. Make sure you are using the correct interface as shown by the ifconfig command output.

2. Add your local network in /usr/local/etc/networks.cfg. This file already comes with 3 default networks (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), so adjust accordingly. For example, my IP address is 192.168.0.112, so I’ll use one of them and remove the rest:

3. Start the ZeekControl shell:

4. Run the deploy command to check the configuration, install, and start the Zeek instance:

To check if Zeek is running use the status command:

Awesome! Zeek is now up and running.

Tips

Other useful commands include:

  • diag for troubleshooting errors.
  • cleanup for deleting files.
  • start or stop for starting or stopping the Zeek process respectively.

It’s worth mentioning that you don't have to start the ZeekControl interactive shell every time you want to operate Zeek, you can just run both commands altogether, such as: zeekctl start.

Zeek Logs

Now that Zeek is running, all the logs will be located in /usr/local/var/logs/current. If you stop the service, this directory will be empty and the logs will be compressed and moved to the current day directory.

Also, the default output format is TSV (tab-separated values), and depending on your Mac you may have a similar list of log files:

Running Zeek automatically

Running Zeek with the ZeekControl shell is great for the first few times. But what if you wanted it to be running in the background even after it crashes or your Mac reboots? I don't like dealing with services manually, so I decided to automate the Zeek service with a script.

Apple has its own framework for managing services called launchd. I’ve used it successfully in the past to create other daemons. However, I tried to set up a Zeek job this time but it didn’t work quite well. So instead, I created a good old Bash script, scheduled it to run every few minutes via crontab and it was successful.

Add the zeek.sh script to the root crontab with sudo crontab -e:

In the above example, the script will be executed every 5 min. Modify the frequency according to your needs.

Important: If you send the output to a log, you may need to grant Full Disk Access to cron in Security & Privacy settings. For more details you can review this article. Otherwise, you may get the error: Operation not permitted.

Next Steps

Bravo! I’m glad that you have a fully working Zeek instance on your Mac. Now what? You can start analyzing all the Zeek logs manually on your terminal. But what if you wanted to have more fun with your network data, like running queries, getting alerts, or viewing graphs? Then, I recommend you integrate Zeek with a SIEM/log management solution. In a future article, I’ll show you how to do it with Devo and its Data Analytics Platform. Stay tuned!

--

--

Roberto Meléndez
Mac O’Clock

Engineer @devo_Inc, an Enterprise Logging and Security Analytics unicorn | Tech enthusiast | Traveler | Music Lover | Mexican 🔗 linkedin.com/in/rcmelendez