This is our old Q&A Site. Please post any new questions and answers at


How might I write a display filter for a tcp port range?

I'm wanting to filter two sets of ranges. TCP/8600-8619 and TCP/8400-8402



asked 10 Jul '13, 06:43

JTech_17's gravatar image

accept rate: 0%

Please try this:

(tcp.dstport >= 8600 and tcp.dstport <= 8619) or (tcp.dstport >= 8400 and tcp.dstport <= 8402)

HINT: That will only show traffic in one direction, which is from client --> server. However, that should be enough the figure out the tcp stream number, and then filter on that in a second step, possibly with tshark.

tshark -nr input.pcap -R "(tcp.dstport >= 8400 and tcp.dstport <= 8402) or (tcp.dstport >= 8400 and tcp.dstport <= 8402)" -T fields -e | sort

Then use that output and filter on


permanent link

answered 10 Jul '13, 07:01

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
accept rate: 15%

edited 10 Jul '13, 07:20

Thanks for the extra Tshark component, very nice.


(10 Jul '13, 07:57) JTech_17

With newer versions of libpcap (0.9.1 and later):

(tcp portrange 8600-8619) or (tcp portrange 8400-8402)

You can break it down further if you care about source or destination ports. As an example:

(tcp dst portrange 8600-8619) or (tcp src portrange 8400-8402)

More information can be found on the manpages

permanent link

answered 25 Nov '15, 11:49

SwDevMan81's gravatar image

accept rate: 50%

edited 25 Nov '15, 11:54

That's a capture filter, not a display filter; it's useful, but it doesn't solve this particular problem.

(26 Nov '15, 13:44) Guy Harris ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 Jul '13, 06:43

question was seen: 56,259 times

last updated: 26 Nov '15, 13:44

p​o​w​e​r​e​d by O​S​Q​A