Monitoring your home network can be challenging without enterprise-grade equipment. Although monitoring your home network can prove to be difficult, Proxmox and Zeek provide the perfect solution to monitor your home network. This blog post will cover how to setup Zeek+PF_Ring to monitor network traffic on Proxmox.
Goals
- Setup a NON-standalone Zeek
- manager
- proxy
- worker – multiple processes
- PF_RING to capture network traffic
- Proxmox + OpenVswitch
- OpenVswitch to allow traffic monitoring
Background
What is Proxmox?
Proxmox VE is a completely open-source platform for enterprise virtualization. With the built-in web interface, you can easily manage VMs and containers, software-defined storage and networking, high-availability clustering, and multiple out-of-the-box tools on a single solution.
My Proxmox box
My Proxmox box(hypervisor) is a custom build with server grade hardware:
- CPU: Intel Xeon quad-core
- Memory: 64Gbs of DDR4 ECC
- SSD: Kingston 120GB – Proxmox install
- HDD: 2x 4TB Western Digital enterprise drives
- ZFS “RAID 1” for 4TB of storage
- NIC: Intel PRO/1000 VT
- Has 4 ports
What is Zeek?
Zeek is a passive, open-source network traffic analyzer. It is primarily a security monitor that inspects all traffic on a link in depth for signs of suspicious activity. More generally, however, Bro supports a wide range of traffic analysis tasks even outside of the security domain, including performance measurements and helping with troubleshooting.
What is pf-ring?
PF_RING is a high-speed packet capture library that turns a commodity PC into an efficient and cheap network measurement box suitable for both packet and active traffic analysis and manipulation. Moreover, PF_RING opens totally new markets as it enables the creation of efficient application such as traffic balancers or packet filters in a matter of lines of codes
Network diagram
The diagram below displays Zeek running on a separate box but, in reality, it is actually running on Proxmox. This was done intentionally to show all the physical cabling for my home network.
Proxmox
Install/Setup openVswitch for mirror ports on Proxmox 5.3
ASSUMPTIONS
This blog post ASSUMES your Proxmox box has TWO PHYSICAL ethernet ports. One interface is dedicated for Proxmox maintenance and VM traffic. The second interface is dedicated to being a mirror port for Zeek.
Install/Setup OpenVswitch
- SSH into Proxmox
apt-get update -y && apt-get install openVswitch-switch -y
Add mirror port
- Browse to https://<IP addr of proxmox>: is 8006 and login
- Expand “datacenter” in the left and select the Proxmox node you want to run Zeek on
- Expand “System” then “network”
- Select “Create” at the top then select “OVS bridge”
- Leave the name as the default
- Note this name for the next section
- Check “Autostart”
- Enter “<interface>” into “Bridge ports”
- Enter “mirror port” into “Comments”
- Leave the name as the default
- Select “Create”
Create Ubuntu 18.04 VM for Zeek
For my homelab, I have VM templates created that I clone from. At this point, I assume you have a VM created or have created a clone.
- Select the VM
- Select “Hardware”
- Set CPU to have 4 cores
- Set memory to 4GB
- Select “Add” then “Network device”
- Select “vmbrX” – mirror port
- Leave the VLAN blank
- Select “Intel E1000” for Model
- Select “Add”
- Start VM
Add mirror port on boot
- SSH into Proxmox
cd /srv
ip a | grep tap | grep ovs-system
- Note the tap<VM ID>i<X>
-
cat > /srv/mirror_port.sh << 'EOF' #!/bin/dash MIRRORPORTLOG=/srv/mirror_port.log date >> $MIRRORPORTLOG echo "####################" >> $MIRRORPORTLOG echo "Clearing any existing mirror..." >> $MIRRORPORTLOG ovs-vsctl clear bridge <OVS bridge interface name - vmbrX> mirrors echo "Creating mirror on <OVS bridge interface name - vmbrX> for Zeek" >> $MIRRORPORTLOG ovs-vsctl -- --id=@p get port <tap interface> \ -- --id=@m create mirror name=span1 select-all=true output-port=@p \ -- set bridge <OVS bridge interface name - vmbrX> mirrors=@m >> $MIRRORPORTLOG echo "Showing existing mirrors" >> $MIRRORPORTLOG ovs-vsctl list Mirror >> $MIRRORPORTLOG echo "####################" >> $MIRRORPORTLOG EOF
chmod 700 /srv/mirror_port.sh
./mirror_port
echo "@reboot /srv/mirror_port.sh" >> /var/spool/cron/crontabs/root
Install/Setup Zeek + pf-ring from source
My network
As you can see in the diagram above, my home network has multiple VLANs(mini-networks) all connected to the switch. For Zeek to monitor all the traffic in my network, I created a mirror port on the switch. Therefore, the switch is making a copy of each packet that flows through it to the mirror port. This allows Zeek to monitor all the traffic on my home network.
Manual install
Update machine
sudo su
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
reboot
sudo apt-mark hold linux-image-generic linux-headers-generic
- DISABLING kernel updates
- Because we compiled PFRing in this kernel, any kernel builds may cause the PFRing module to fail to load. You will need to recompile PFRing if you update your kernel after compiling.
Enable monitoring interface on boot
ip link set <interface> up
echo "@reboot ip link set <interface> up" >> /var/spool/cron/crontabs/root
Install/Setup pf-ring from source
apt-get install cmake make gcc g++ flex bison libpcap-dev libssl-dev python-dev swig zlib1g-dev libgeoip-dev build-essential libelf-dev -y
cd /opt
git clone https://github.com/ntop/PF_RING.git
cd PF_RING/kernel
make
insmod ./pf_ring.ko
cd ../userland
make
cd lib
./configure –prefix=/opt/PF_RING
make install
cd ../libpcap
./configure --prefix=/opt/PF_RING/
make install
cd ../tcpdump-*
./configure --prefix=/opt/PF_RING/
make install
cd ../../kernel
make
make install
echo "pf_ring" >> /etc/modules
- Load pf_ring at boot
reboot
lsmod | grep pf_ring
Install/Setup Zeek from source
sudo su
apt-get install cmake make gcc g++ flex bison libpcap-dev libssl-dev python-dev swig zlib1g-dev git -y
cd /tmp
git clone --recursive https://github.com/zeek/zeek
cd zeek
./configure --with-pcap=/opt/PF_RING --prefix=/opt/bro/
make
make install
echo "$PATH:/opt/bro/bin" >/etc/environment
export PATH=/opt/bro/bin:$PATH
Setup/Configure Zeek
-
cat > /opt/bro/etc/node.cfg << 'EOF' # Example BroControl node configuration. # # This example has a standalone node ready to go except for possibly changing # the sniffing interface. ## Below is an example clustered configuration. [manager] type=manager host=localhost # [proxy-1] type=proxy host=localhost # [worker-1] type=worker host=localhost interface=ens18 lb_method=pf_ring lb_procs=5 EOF
vim /opt/bro/etc/network.cfg
- Add networks in CIDR notation that Zeek will be monitoring
-
# List of local networks in CIDR notation, optionally followed by a # descriptive tag. # For example, "10.0.0.0/8" or "fe80::/64" are valid prefixes. 10.0.0.0/8 172.16.0.0/16 192.168.1.0/24
- Save and exit
Start Zeek
-
/opt/bro/bin/broctl
install
deploy
status
Ansible
host.ini
git clone https://github.com/CptOfEvilMinions/BlogProjects.git
cd BlogProjects/zeek_pfring
vim hosts.ini
and set:ansible_host
for zeek01
- Save and exit
group_vars/all.yml
vim group_vars/all.yml
- General
timezone
– Set timezone for Zeek machine
- Zeek
zeek_hostname
– Set hostname of Zeek machinezeek_interface
– Set interface for Zeek to monitorzeek_mail_to
– E-mail to send Zeek alertszeek_geoip
– Enable/Disable GeoIP taggingzeek_file_extraction
– Enable/Disable file extractionzeek_stats
– Enable/Disable Zeek statszeek_custom_scripts
-Enable/Disable custom scripts in conf/Zeek/scripts
- Slack
slack_token
– OPTIONAL – Ansible noticationsslack_channel
– OPTIONAL – Ansible notications
- General
- Save and exit
Zeek configs
mv conf/zeek/networks.cfg.example conf/zeek/networks.cfg
vim conf/zeek/networks.cfg
- Add networks in CIDR notation that Zeek will be monitoring
# List of local networks in CIDR notation, optionally followed by a# descriptive tag. # For example, "10.0.0.0/8" or "fe80::/64" are valid prefixes. 10.0.0.0/8 172.16.0.0/16 192.168.1.0/24
- Save and exit
- Add networks in CIDR notation that Zeek will be monitoring
Deploy
ansible-playbook -i hosts.ini deploy_zeek_pf_ring.yml -u <user> -K
Verify Zeek is running
Running processes
/opt/bro/bin/broctl status
Logs
ls /opt/bro/logs/current
tail -f /opt/bro/logs/curren/conn.log
Debugging
/opt/bro/bin/broctl diag
/opt/bro/bin/broctl check
Credit
Black Hills Infosec
Shoutout to Black Hills Infosec on the tutorial to set up Bro(now Zeek) on ESXi. The idea for this blog post came from this setup but I modified it for Proxmox.
vext.info
Shoutout to vext.info on the tutorial on how to setup a mirror port on Proxmox with OpenVswitch.
Really good tutorial, thank you for this!