Packet Filter (BPF) not working / ignored

Hi Community.

I need some assistance getting BPF working.
We’re streaming from a MikroTik RouterOS firewall to Suricata 7.0.7 using trafr and -r /dev/stdin
sudo /bin/sh -c '/usr/bin/trafr -s | /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /run/suricata.pid -r /dev/stdin -v not host 10.10.111.200 -l /var/log/suricata/'
I’m trying to exclude our monitoring system which is scanning the networking via SNMP.

Even a simple filter like this seems to be ignored completely - I still see all traffic in the Suricata logs.
-v not host 10.10.111.200

Specifying the filter in file /etc/suricata/capture-filter.bpf also doesn’t work:
sudo /bin/sh -c '/usr/bin/trafr -s | /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /run/suricata.pid -r /dev/stdin -F /etc/suricata/capture-filter.bpf -l /var/log/suricata/'

What am I doing wrong, is this not supported for reading from pacp (-r) or is it even a BUG?

I’m thankful for any hint.

Best regards, Flo.

The BPF is supposed to the last part of the suricata commandline, so you could try moving it there. Alternatively you can put the filter in a file and load it from the commandline with -F <file path>.

Hi Victor,
thanks a lot for your fast response :slight_smile:

I already tried that by using a pbf file which also didn’t work (see my initial post above).

Even when I move it at the end, the filter is completely ignored:
sudo /bin/sh -c '/usr/bin/trafr -s | /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /run/suricata.pid -r /dev/stdin -l /var/log/suricata/ -v not host 10.10.111.200'

Same if I put -F /path/to/file.bpf at the end of the command:
sudo /bin/sh -c '/usr/bin/trafr -s | /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /run/suricata.pid -r /dev/stdin -l /var/log/suricata/ -F /etc/suricata/capture-filter.bpf'

It’s really strange - Anyone has an idea why this doesn’t work ?

You may have already tried this but I’ll ask. Can you use tcpdump -r - <your-bpf-filter> to see if you can the results you’re expecting?

1 Like

Hey @Jeff_Lucovsky - thanks.
Yes, tried that and it works with tcpdump…

Let’s see if Suricata is using the correct values for the BPF

Please run

/usr/bin/suricata -c /etc/suricata/suricata.yaml -l /var/log/suricata/  --dump-config -v not host 10.10.111.200 | grep -i bpf

/usr/bin/suricata -c /etc/suricata/suricata.yaml -l /var/log/suricata/  --dump-config -v -F /etc/suricata/capture-filter.bpf | grep -i  bpf