This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

What is the capture filter for a specific IPv4 subnet?

0

What is the capture filter for a specific IPv4 subnet? I had thought that this would do:

net 192.168.1.0

However, I don't capture any traffic with this filter at all (where I know there is traffic, since I can see some on that subnet when capturing without the filter).

asked 20 May '13, 08:18

multipleinterfaces's gravatar image

multipleinte...
1.3k152340
accept rate: 12%


2 Answers:

3

You need to supply the netmask as well, e.g. net 192.168.1.0/24

answered 20 May '13, 08:24

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

edited 20 May '13, 08:24

(22 May '13, 05:54) Kurt Knochner ♦

5

I also thought that without a netmask, bpf would default to classfull addresses, but I never ran into it because I had CIDR subnets everywhere.

Or maybe the behavior has changed over time ... OK, the manpage says it all:

dst net net
          True if the IPv4/v6 destination address  of  the  packet  has  a
          network  number  of  net.   Net  may  be  either a name from the
          networks database (/etc/networks, etc.) or a network number.  An
          IPv4  network  number  can  be  written  as a dotted quad (e.g.,
          192.168.1.0), dotted triple (e.g., 192.168.1), dotted pair (e.g,
          172.16),   or   single   number   (e.g.,  10);  the  netmask  is
          255.255.255.255 for a dotted quad (which means that it's  really
          a  host  match),  255.255.255.0 for a dotted triple, 255.255.0.0
          for a dotted pair, or 255.0.0.0 for a single  number.   An  IPv6
          network  number  must  be  written  out  fully;  the  netmask is
          ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network"  matches  are  really
          always  host  matches,  and  a  network match requires a netmask
          length.

So, "net 192.168.1" will also work...

My "learn-something-new-item" for today :-)

answered 22 May '13, 02:00

SYN-bit's gravatar image

SYN-bit ♦♦
17.1k957245
accept rate: 20%