OPNsense Forum

English Forums => 26.7 Series => Topic started by: 1001001 on August 04, 2026, 07:52:03 AM

Title: wrong byte counters
Post by: 1001001 on August 04, 2026, 07:52:03 AM
Running 26.7.1_1 and trying to figure out how many bytes are received per protocol (ipv4/ipv6) on my wan interface (igc0):
netstat -nib -I igc0 --libxo json | jq '{ \
  total: ([.statistics.interface[] | select(.network | startswith("<Link")) | ."received-bytes"][0] // 0), \
  ipv4: ([.statistics.interface[] | select(.network | test("^[0-9]+\\.")) | ."received-bytes"] | add // 0), \
  ipv6: ([.statistics.interface[] | select(.network | contains(":")) | ."received-bytes"] | add // 0) \
}'
results in
{
  "total": 23410011429,
  "ipv4": 23001947,
  "ipv6": 17767223
}
The total counter is correct, but not the v4/v6 counters, they are much to low!
Am I doing something wrong or a bug?
Title: Re: wrong byte counters
Post by: pfry on August 04, 2026, 03:11:55 PM
Offhand I'd guess that the protocol-specific counters are "terminated on device" rather than "forwarded". The statistics do not appear to be clearly defined (from a quick scan of the docs).
Title: Re: wrong byte counters
Post by: 1001001 on August 04, 2026, 03:32:21 PM
Hm good point.
Any idea how to get protocol specific in/out counters?
Like /proc/self/net/dev_snmp6/eth0 on linux.
Title: Re: wrong byte counters
Post by: pfry on August 04, 2026, 07:45:39 PM
Have you dug into the FreeBSD proc filesystem ("mount -t procfs proc /proc")? I haven't looked in there in a while... never can tell. Would session/rule counters give you what you want?
Title: Re: wrong byte counters
Post by: 1001001 on August 04, 2026, 08:19:46 PM
found nothing in /proc
maybe I will try to write paketfilter rules