Ask Your Question

How do I filter using a range IPv4 addresses?

asked 2018-03-15 14:35:19 +0000

frubin gravatar image

updated 2018-03-15 15:48:23 +0000

cmaynard gravatar image

I am attempting to a track data from a range of IP addresses for servers in a cluster and cannot seem to get the verbiage correct to achieve this. I have tried:

  • ip.addr == (expression is green, but nothing returns)
  • ip.address == or (expression turn red)
  • ip contains (expression is green, but nothing shows as being captured but when I do ip.addr ==any of individual address in that range, it shows packets)
  • host or host (expression turns red)
  • ip host (expression turns red)
  • net

This is being attempted on 2.4.4

Thank you

edit retag flag offensive close merge delete


Are you certain that ip.addr == (with 38 after the /, not some value between 1 and 32) doesn't turn the display filter box red?

Guy Harris gravatar imageGuy Harris ( 2018-03-15 23:28:33 +0000 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-03-15 16:03:01 +0000

cmaynard gravatar image

I'll address each one in turn:

  • ip.addr == This is invalid because the maximum number of bits is /32. You probably want ip.addr == (Ideally, the Wireshark display filter validation could be improved to detect this and turn the expression red instead of green.)
  • ip.address == or This is invalid because there is no field called "ip.address" and you need to specify the field name for the second IP address too. You probably want ip.addr == or ip.addr ==
  • ip contains Again, /38 is invalid, but also the contains operator does not work with IP addresses. Refer to the wireshark-filter man page for more information.

As the red color indicates, the following are not valid Wireshark display filter syntax. They are pcap-filter capture filter syntax and can't be used in this context. Refer to the pcap-filter man page for more information.

  • host or host
  • ip host
  • net
edit flag offensive delete link more


Oops, grahamb beat me to the answer while I was typing/linking/formatting.

cmaynard gravatar imagecmaynard ( 2018-03-15 16:03:55 +0000 )edit

This is invalid

...and should be reported as an error, just as libpcap does:

$ tcpdump -i en0 -d net
tcpdump: mask length must be <= 32

At least in the master branch, it does get reported:

$ dftest 'ip.addr =='
Filter: "ip.addr =="
dftest: Netmask bits in a CIDR IPv4 address should be <= 32, not 38

but if a green background is displayed with that filter, that's a bug.

Guy Harris gravatar imageGuy Harris ( 2018-03-15 22:12:59 +0000 )edit

Indeed, a /38 is indicated as being invalid even with version 2.4.5, the specific message being, "Invalid filter: Netmask bits in a CIDR IPv4 address should be <= 32, not 38", just as described.

But @frubin indicated version 2.4.4 was in use and that the filter was "green", so either that can't be the case - a different version was in use or the filter wasn't "green" - or the display filter syntax checking was improved some time between those 2 releases, although I don't find any mention of that in the release notes. Or something else?

EDIT: And annoyingly, dftest still isn't included in the Windows installer ... at least not for 2.4.x.

cmaynard gravatar imagecmaynard ( 2018-03-15 22:48:30 +0000 )edit

The check for that issue appears to be in the current 2.4 branch and, in fact, 2.4.5 does turn the display filter bar in the main window and in the "Capture Options" dialog red for "ip.addr ==", at least in the macOS version.

Guy Harris gravatar imageGuy Harris ( 2018-03-15 23:25:55 +0000 )edit

...and that check was added back in 2001, so it's been there for a long while. In fact, the check was part of the initial checkin of code to support CIDR netmasks in display filters, so it's been there for as long as it's been possible to say "/NN" in tests of IP addresses in display filters.

Guy Harris gravatar imageGuy Harris ( 2018-03-15 23:27:32 +0000 )edit

answered 2018-03-15 15:52:40 +0000

grahamb gravatar image

updated 2018-03-15 16:18:07 +0000

You seem to be confused by the differing syntaxes of capture and display filters.

Capture filter syntax is explained here, and allows use of the following keywords to identify ip addresses:

  • host- identifies a particular host, if a name, the resolved ip(s) are all used, if an ip, then that is used.
  • net - identifies a network of addresses, usually in CIDR notation, e.g.

Display syntax is explained here and uses a form of ==, e.g:

  • ip.addr == or ip.addr == myhost filters any packets to or from the ip address or host name
  • ip.addr == filters any packets in the class c subnet.

Assuming you're trying to create a display filter for address in the range - 38 you can either use:

  • individual address: ip.addr == or ip.addr == or ip.addr == or ip.addr == or ip.addr ==
  • a subnet, unfortunately your range of addresses doesn't map neatly so you'll have to use a slightly bigger subnet, e.g. ip.addr == which will permit address in the range -

You could also combine a mix of explicit addresses and a smaller subnets:

ip.addr == or ip.addr == or ip.addr ==

edit flag offensive delete link more


Thank you very much, we just installed it 3 days ago and I have been reading a lot about this software since then, but I was unable to determine what the proper syntax that would be needed. Thank you!

frubin gravatar imagefrubin ( 2018-03-15 15:57:38 +0000 )edit

If an answer has solved your issue, please accept it to assist others with the same question by clicking the checkmark icon by the side of the answer.

grahamb gravatar imagegrahamb ( 2018-03-15 16:19:19 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-03-15 14:35:19 +0000

Seen: 56,237 times

Last updated: Mar 15 '18