# Packet Filter (BPF) not working / ignored

**URL:** <https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234>\
**Category:** Uncategorized\
**Tags:** suricata\
**Created:** [January 15, 2025, 9:48am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234 "2025-01-15T09:48:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [January 15, 2025, 9:48am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/1 "2025-01-15T09:48:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vjulien](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/vjulien/32/4_2.png) [@vjulien](https://forum.suricata.io/u/vjulien)\
**Post date:** [January 15, 2025, 1:32pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/2 "2025-01-15T13:32:48Z")

</div>

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>`.

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [January 15, 2025, 6:44pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/3 "2025-01-15T18:44:56Z")

</div>

Hi Victor,  
thanks a lot for your fast response 🙂

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'`

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [February 3, 2025, 9:02am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/4 "2025-02-03T09:02:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Lucovsky](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/jeff_lucovsky/32/11_2.png) [@Jeff\_Lucovsky](https://forum.suricata.io/u/Jeff_Lucovsky)\
**Post date:** [February 4, 2025, 3:52pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/5 "2025-02-04T15:52:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [February 5, 2025, 7:25am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/6 "2025-02-05T07:25:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Lucovsky](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/jeff_lucovsky/32/11_2.png) [@Jeff\_Lucovsky](https://forum.suricata.io/u/Jeff_Lucovsky)\
**Post date:** [February 5, 2025, 1:36pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/7 "2025-02-05T13:36:30Z")

</div>

> [@the-project-group](#):
>
> /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’

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

Please run

```auto
/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

```

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [March 5, 2025, 11:41am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/8 "2025-03-05T11:41:47Z")

</div>

@Jeff_Lucovsky sorry for the late reply…

```auto
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/ --dump-config -v -F /etc/suricata/capture-filter.bpf' | grep -i bpf
bpf-filter = not (src host 172.17.0.39 and udp and dst port 161)

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/ --dump-config -v not host 172.17.0.39'|grep -i bpf
bpf-filter = not host 172.17.0.39

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Lucovsky](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/jeff_lucovsky/32/11_2.png) [@Jeff\_Lucovsky](https://forum.suricata.io/u/Jeff_Lucovsky)\
**Post date:** [March 5, 2025, 12:15pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/9 "2025-03-05T12:15:36Z")

</div>

Do the displayed `bpf-filter` values match the bpf you expect?

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [March 5, 2025, 12:40pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/10 "2025-03-05T12:40:40Z")

</div>

Yes, but they wont apply. Meaning: I see traffic from the host in eve.json / fast.log.

---

<div class="post-metadata">

**Author:** ![the-project-group](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/the-project-group/32/3382_2.png) [@the-project-group](https://forum.suricata.io/u/the-project-group)\
**Post date:** [March 5, 2025, 1:01pm UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/11 "2025-03-05T13:01:07Z")

</div>

Just tried it again to make 100% sure:  
`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 172.17.0.39' `

```auto
Notice: suricata: This is Suricata version 7.0.8 RELEASE running in USER mode
Info: cpu: CPUs/cores online: 8
Info: suricata: Setting engine mode to IDS mode by default
Info: logopenfile: fast output device (regular) initialized: fast.log
Info: logopenfile: eve-log output device (regular) initialized: eve.json
Warning: runmodes: eve module 'ikev2' has been replaced by 'ike'
Info: logopenfile: stats output device (regular) initialized: stats.log
Info: detect: 2 rule files processed. 95311 rules successfully loaded, 0 rules failed, 0
Info: threshold-config: Threshold config parsed: 0 rule(s) found
Info: detect: 95314 signatures processed. 1259 are IP-only rules, 4439 are inspecting packet payload, 89405 inspect application layer, 108 are decoder event only
Info: pcap: using bpf-filter "not host 172.17.0.39"
Info: pcap: Starting file run for /dev/stdin
Notice: threads: Threads created -> RX: 1 W: 8 FM: 1 FR: 1 Engine started.
Info: checksum: More than 1/10th of packets have an invalid checksum, assuming checksum offloading is used (128/1000)
Notice: detect: rule reload starting

```

The filter doesn’t work, I see traffic:

 ![CleanShot 2025-03-05 at 14.00.24@2x](https://canada1.discourse-cdn.com/flex030/uploads/suricata/original/2X/8/8d4f2fbdb2a8cc5bac8f2e28628a25e70cbbcb01.png)

---

<div class="post-metadata">

**Author:** ![s1ncr](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/s1ncr/32/3450_2.png) [@s1ncr](https://forum.suricata.io/u/s1ncr)\
**Post date:** [March 6, 2025, 11:32am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/12 "2025-03-06T11:32:56Z")

</div>

bpf filters definitely works with pcaps (-r)

I had kinda similar issue when i thought that i am crazy and bpf dont work for some reason, problem was that i had 2 instance of suricata running simultaneously, one with bpf working and one without bpf

I guess you can also check for that issue

---

<div class="post-metadata">

**Author:** ![Jeff\_Lucovsky](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/jeff_lucovsky/32/11_2.png) [@Jeff\_Lucovsky](https://forum.suricata.io/u/Jeff_Lucovsky)\
**Post date:** [March 7, 2025, 8:28am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/13 "2025-03-07T08:28:11Z")

</div>

I’m not able to replicate the failures you’re encountering.

We’ve verified that `suricata` is using the proper config value by displaying values with the `--dump-config` option.

---

<div class="post-metadata">

**Author:** ![s1ncr](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/s1ncr/32/3450_2.png) [@s1ncr](https://forum.suricata.io/u/s1ncr)\
**Post date:** [March 13, 2025, 7:35am UTC](https://forum.suricata.io/t/packet-filter-bpf-not-working-ignored/5234/14 "2025-03-13T07:35:42Z")

</div>

Does your traffic is ERSPAN by any chance?
