Installing and Configuring Zeek NSM on Linux: Real-World Network Traffic Monitoring

Network tutorial - IT technology blog
Network tutorial - IT technology blog

Early-Morning Bandwidth Nightmares

Managing an office of 50 employees alongside an internal cluster of 15 servers sounds straightforward enough. But everything changes when your router starts screaming on a Monday morning because a 1 Gbps pipe is completely saturated. Or worse, when alerts trigger at 2:00 AM because an accounting workstation opened hundreds of suspicious outbound connections to an unfamiliar IP in Russia.

The instinctive reaction for most network admins is to fire up tcpdump. Capture traffic for just 15 minutes, and the resulting .pcap file has already swallowed 12 GB of disk space. Open it in Wireshark, and your workstation instantly freezes. Sifting through raw payloads across three million packets to pinpoint a data leak feels like searching for a needle in a haystack—especially with your manager breathing down your neck for answers.

Why Traditional Packet Capture Tools Fall Short

There is nothing inherently wrong with full packet capture. The problem is that it is overwhelmingly resource-intensive for everyday operational needs:

  • Excessive storage overhead: Packet sniffers capture every byte of raw payload. Yet in 90% of initial incident investigations, all you really need is metadata: source and destination IPs, ports, timestamps, protocol, and transferred byte counts.
  • NetFlow lacks application context: NetFlow and sFlow are lightweight, but they stop at Layer 4. They cannot tell you which domain was resolved over DNS, whether an SSL certificate has expired, or what HTTP status code was returned.
  • Alert fatigue: Signature-based IDSs like Snort or Suricata only trigger when traffic matches a known signature. When facing novel malware or DNS tunneling techniques, they stay silent. Conversely, benign but unusual traffic patterns can easily trigger thousands of false alarms every day.

Three Common Approaches to Network Traffic Analysis

Depending on the problem and infrastructure budget, sysadmins typically consider the following options:

1. Rotating tcpdump Captures via Bash Scripts

Running tcpdump -C 100 -W 10 retains the 10 most recent files (at 100 MB each). This prevents your disk from filling up, but manually parsing through rotated pcap dumps takes hours and does not automatically decode application-layer protocols.

2. Using a NetFlow/IPFIX Collector

Exporting flows from a core switch to PRTG or ntopng is great for monitoring aggregate link utilization. However, when malware beacons out via HTTP every 30 seconds with a 64-byte payload to receive C2 instructions, NetFlow graphs will barely show a blip.

3. Context-Aware Protocol Analysis with Zeek (Bro)

Zeek is neither a conventional signature-based IDS nor a raw packet sniffer. It reassembles TCP sessions, decodes over 30 common network protocols, and outputs structured, tabular log files: conn.log, dns.log, ssl.log, and http.log. The resulting log footprint is roughly 1% of the equivalent PCAP capture, while retaining nearly all actionable forensic value.

Hands-On: Deploying Zeek Standalone on Ubuntu

The simplest and most effective setup is a dedicated Ubuntu server with its network interface connected to a SPAN/mirror port on your switch. Here is the exact, battle-tested configuration running smoothly in production.

Step 1: Install Zeek LTS

# Install required dependencies
sudo apt update && sudo apt install -y curl gnupg2 ethtool

# Add repository key and Zeek repo for Ubuntu 22.04
curl -fsSL https://download.opensuse.org/repositories/security:zeek/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/security_zeek.gpg > /dev/null
echo 'deb http://download.opensuse.org/repositories/security:/zeek/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/security:zeek.list

# Install zeek-lts package
sudo apt update
sudo apt install -y zeek-lts

# Add Zeek to PATH
echo 'export PATH=$PATH:/opt/zeek/bin' >> ~/.bashrc
source ~/.bashrc

Step 2: Optimize the Capture Interface (NIC Tuning)

If you skip this step, Zeek will continuously drop packets. When hardware offloading is enabled on the NIC, the Linux kernel aggregates small packets into larger ones before Zeek can inspect them, leading to checksum errors and dropped frames.

Assuming your SPAN capture interface is eth1:

# Disable all offloading features on the capture interface
sudo ethtool -K eth1 rx off tx off sg off tso off gso off gro off lro off

# Put the interface into promiscuous mode to capture all frames
sudo ip link set eth1 promisc on up

To persist these settings across system reboots, configure them via a systemd service or directly within your Netplan configuration.

Step 3: Define Subnets and Interfaces

Zeek needs to distinguish between inbound, outbound, and internal traffic. Open /opt/zeek/etc/networks.cfg:

sudo nano /opt/zeek/etc/networks.cfg

Enter the IP ranges used in your network:

10.10.0.0/16       Datacenter Servers
192.168.1.0/24     Office LAN Workstations
192.168.20.0/24    Guest Wi-Fi

Next, configure your capture interface in /opt/zeek/etc/node.cfg:

sudo nano /opt/zeek/etc/node.cfg

Keep the standalone node configuration simple:

[zeek]
type=standalone
host=localhost
interface=eth1

Step 4: Managing Zeek with zeekctl

All engine management operations are handled via the zeekctl utility:

# Check configuration syntax
sudo /opt/zeek/bin/zeekctl check

# Deploy configuration and start processes
sudo /opt/zeek/bin/zeekctl deploy

# Check operational status
sudo /opt/zeek/bin/zeekctl status

Once the status reports running, Zeek begins logging data into /opt/zeek/logs/current/.

Step 5: Practical Log Analysis with zeek-cut

Without needing a heavy database setup, the bundled zeek-cut utility lets you extract specific log fields significantly faster than standard awk commands.

Identifying Top Outbound Data Senders

cd /opt/zeek/logs/current/
# Find top 10 IPs sending the most outbound bytes
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p orig_bytes | sort -nr -k4 | head -n 10

Detecting Anomalous DNS Queries (DGA Botnets, DNS Tunneling)

# Search for unusually long domains or high-frequency internal queries
cat dns.log | zeek-cut id.orig_h query qtype_name answers | grep -v "-" | head -n 15

Auditing Expired or Self-Signed SSL/TLS Certificates

# Extract SNI domain names, TLS versions, and certificate validation statuses
cat ssl.log | zeek-cut id.orig_h server_name version validation_status | grep -v "ok" | head -n 10

Best Practices for Production Stability

  • Disk space management: A 50-user network typically generates 150 MB to 350 MB of compressed logs per day. Zeek automatically rotates and compresses logs into /opt/zeek/logs/YYYY-MM-DD/ with gzip. Configure a cron job to purge logs older than 45 days to keep your root partition from filling up.
  • Centralized log shipping: Plain-text logs are easy to inspect manually, but difficult for visualizing trends. Consider using Filebeat to ship Zeek logs to an Elasticsearch cluster or Wazuh. Because Zeek logs are cleanly structured, setting up Kibana dashboards takes under half an hour.
  • Enable built-in detection scripts: In /opt/zeek/share/zeek/site/local.zeek, Zeek provides pre-packaged behavioral analysis frameworks. Simply uncomment @load protocols/ssh/detect-bruteforcing and run zeekctl deploy; Zeek will automatically flag SSH brute-force attempts in notice.log.
Share: