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

We have a Linux box connected to a mirror port on a Juniper router. If I use tcpdump or tethereal to view packets live, I cannot filter by VLAN, but I can by host, e.g.
tethereal -i eth2 -n host works, while
tethereal -i eth2 -n vlan 123 and host does not.
If I record a pcap file, e.g.
tethereal -i eth2 -w my.cap -c 400
then I can replay it with e.g.
tcpdump -r my.cap -n vlan and host
tcpdump -r my.cap -n vlan 123 host
but not
tcpdump -r my.cap -n host

It is particularly annoying that we cannot filter live by VLAN, e.g.
tethereal -i eth2 -n vlan 123
On an older router (Nortel Passport), this worked.

We have libpcap-1.4.0 on CentOS 6 with a Mellanox driver v2.0 and a MT26448 card, connected to a Juniper EX9008 router.

I want to be able to filter live by VLAN number. Is this something I can do with the right syntax, or is it an issue with the driver or OS or hardware ?

asked 17 Oct '14, 16:15

adaviel's gravatar image

accept rate: 0%

could you please post the output of the following commands on your system?

tcpdump -d vlan 123 and host
tcpdump -d host

tcpdump -ni eth2 -w - | od -x

please add the expected VLAN and traffic (IPs, protocol, ports, etc.)

HINT: the last command could produce a lot of output, depending on the traffic!

(21 Oct '14, 07:39) Kurt Knochner ♦

The web form won't let me add that much text. See

I tried building the latest tarballs from but they have the same issue.

(22 Oct '14, 17:16) adaviel

can you please add the output of the following command:

tcpdump -ni eth2 -w - | od -x

this is without writing a capture file to disk.

(23 Oct '14, 12:04) Kurt Knochner ♦

OK, I've updated the link. How exactly is that different ? Is tcpdump -w x.cap different from tcpdump -w - > x.cap ? Reading from a file or stdin, they seem identical

(23 Oct '14, 14:26) adaviel

Linux does annoying things to VLAN tags in packets received on PF_PACKET sockets (libpcap uses PF_PACKET sockets on Linux), and libpcap doesn't yet compensate for that in the code that compiles filters. It does attempt to undo the things Linux does to the tags, so you see the packets complete with VLAN tags, so filters on a file containing those reconstructed packets works.

permanent link

answered 18 Oct '14, 01:02

Guy%20Harris's gravatar image

Guy Harris ♦♦
accept rate: 19%

Do you have any details ? Is it possible to patch libpcap or the network driver so that it will work ?

(20 Oct '14, 17:26) adaviel talks about some of the problems. There was a blog entry on it as well, can't find that anymore.

(21 Oct '14, 05:45) Jaap ♦

That's talking about kernel patches added in 2008. I believe that the one to linux/if_vlan.h is included in 2.6.32. I don't understand whether the patch is supposed to fix my problem, or whether it causes my problem.

(22 Oct '14, 17:30) adaviel

Take note of this part: "There are mainly two remaining problems with this approach:" which suggests to me that there are residual problems even after these patches applied.

(23 Oct '14, 02:01) Jaap ♦

This may be fixed in libpcap 1.7.x See issue 390

permanent link

answered 04 Nov '14, 14:02

adaviel's gravatar image

accept rate: 0%

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: 17 Oct '14, 16:15

question was seen: 2,709 times

last updated: 04 Nov '14, 14:02

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