NETSNIFF-NG(8)
β¨ NAME β¨
netsniff-ng β the packet sniffing beast π no cap, bestie.
πΈ SYNOPSIS πΈ
netsniff-ng { [options] [filter-expression] }
π DESCRIPTION π
okay so listen up, netsniff-ng is this fast, minimal tool to analyze network packets, capture pcap files, replay pcap files, and redirect traffic between interfaces β all with the help of zero-copy packet(7) sockets. It uses both Linux-specific RX_RING and TX_RING interfaces to perform that zero-copy magic. Why? To avoid copy and system call overhead between kernel and user address space. When we started working on netsniff-ng, the pcap(3) library did not use this zero-copy facility. So we did it ourselves. πββοΈ
netsniff-ng is Linux specific, meaning there is literally no support for other operating systems. That's on purpose β it keeps the code footprint quite minimal and to the point. Linux packet(7) sockets and its RX_RING and TX_RING interfaces bypass the normal packet processing path through the networking stack. This is the fastest capturing or transmission performance one can get from user space out of the box, without having to load unsupported or non-mainline third-party kernel modules. We explicitly refuse to build netsniff-ng on top of ntop/PF_RING. Not because we do not like it (we do find it interesting), but because of the fact that it is not part of the mainline kernel. Therefore, the ntop project has to maintain and sync out-of-tree drivers to adapt them to their DNA. Eventually, we went for untainted Linux kernel, since its code has a higher rate of review, maintenance, security and bug fixes. π
netsniff-ng also supports early packet filtering in the kernel. It has support for low-level and high-level packet filters that are translated into Berkeley Packet Filter instructions. π§
netsniff-ng can capture pcap files in several different pcap formats that are interoperable with other tools. The following pcap I/O methods are supported for efficient to-disc capturing: scatter-gather, mmap(2), read(2), and write(2). netsniff-ng is also able to rotate pcap files based on data size or time intervals, thus making it a useful backend tool for subsequent traffic analysis. π
netsniff-ng itself also supports analysis, replaying, and dumping of raw 802.11 frames. For online or offline analysis, netsniff-ng has a built-in packet dissector for the current 802.3 (Ethernet), 802.11* (WLAN), ARP, MPLS, 802.1Q (VLAN), 802.1QinQ, LLDP, IPv4, IPv6, ICMPv4, ICMPv6, IGMP, TCP and UDP, including GeoIP location analysis. Since netsniff-ng does not establish any state or perform reassembly during packet dissection, its memory footprint is quite low, thus making netsniff-ng quite efficient for offline analysis of large pcap files as well. π
Note that netsniff-ng is currently not multithreaded. However, this does not prevent you from starting multiple netsniff-ng instances that are pinned to different, non-overlapping CPUs and f.e. have different BPF filters attached. Likely that at some point in time your harddisc might become a bottleneck assuming you do not rotate such pcaps in ram (and from there periodically scheduled move to slower medias). You can then use mergecap(1) to transform all pcap files into a single large pcap file. Thus, netsniff-ng then works multithreaded eventually. π
netsniff-ng can also be used to debug netlink traffic. π
π OPTIONS π
-i <dev|pcap|->,-d <dev|pcap|->,--in <dev|pcap|->,--dev <dev|pcap|->β Defines an input device. This can either be a networking device, a pcap file or stdin (-). In case of a pcap file, the pcap type (-Doption) is determined automatically by the pcap file magic. In case of stdin, it is assumed that the input stream is a pcap file. If the pcap link type is Netlink and pcap type is default format (usec or nsec), then each packet will be wrapped with pcap cooked header [2]. π-o <dev|pcap|dir|cfg|->,--out <dev|pcap|dir|cfg|->β Defines the output device. This can either be a networking device, a pcap file, a folder, atrafgen(8)configuration file or stdout (-). If the output device is a pcap ortrafgen(8)configuration file, it may include a time format as defined bystrfime(3). If used in conjunction with the-Foption, each rotated file will have a unique time stamp. In the case of a pcap file that should not have the default pcap type (0xa1b2c3d4), the additional option-Tmust be provided. If a directory is given, then, instead of a single pcap file, multiple pcap files are generated with rotation based on maximum file size or a given interval (-Foption). Optionally, sending theSIGHUPsignal to the netsniff-ng process causes a premature rotation of the file. A trafgen configuration file can currently only be specified if the input device is a pcap file. To specify a pcap file as the output device, the file name must have.pcapas its extension. If stdout is given as a device, then a trafgen configuration will be written to stdout if the input device is a pcap file, or a pcap file if the input device is a networking device. If the input device is a Netlink monitor device and pcap type is default (usec or nsec) then each packet will be wrapped with pcap cooked header [2] to keep Netlink family number (Kuznetzov's and netsniff-ng pcap types already contain family number in protocol number field). π₯-C <id>,--fanout-group <id>β If multiple netsniff-ng instances are being started that all have the same packet fanout group id, then the ingress network traffic being captured is being distributed/load-balanced among these group participants. This gives a much better scaling than running multiple netsniff-ng processes without a fanout group parameter in parallel, but only with a BPF filter attached as a packet would otherwise need to be delivered to all such capturing processes, instead of only once to such a fanout member. Naturally, each fanout member can have its own BPF filters attached. β¨-K <hash|lb|cpu|rnd|roll|qm>,--fanout-type <hash|lb|cpu|rnd|roll|qm>β This parameter specifies the fanout discipline, in other words, how the captured network traffic is dispatched to the fanout group members. Options are to distribute traffic by the packet hash (hash), in a round-robin manner (lb), by CPU the packet arrived on (cpu), by random (rnd), by rolling over sockets (roll) which means if one socket's queue is full, we move on to the next one, or by NIC hardware queue mapping (qm). π-L <defrag|roll>,--fanout-opts <defrag|roll>β Defines some auxiliary fanout options to be used in addition to a given fanout type. These options apply to any fanout type. In case ofdefrag, the kernel is being told to defragment packets before delivering to user space, androllprovides the same roll-over option as therollfanout type, so that on any different fanout type being used (e.g.qm) the socket may temporarily roll over to the next fanout group member in case the original one's queue is full. π¦-f,--filter <bpf-file|-|expr>β Specifies to not dump all traffic, but to filter the network packet haystack. As a filter, either abpfc(8)compiled file/stdin can be passed as a parameter or atcpdump(1)-like filter expression in quotes. For details regarding the bpf-file have a look atbpfc(8), for details regarding atcpdump(1)-like filter have a look at section βfilter exampleβ or atpcap-filter(7). A filter expression may also be passed to netsniff-ng without option-fin case there is no subsequent option following after the command-line filter expression. π-t,--type <type>β This defines some sort of filtering mechanisms in terms of addressing. Possible values for type arehost(to us),broadcast(to all),multicast(to group),others(promiscuous mode) oroutgoing(from us). πΈ-F,--interval <size|time>β If the output device is a folder, with-F, it is possible to define the pcap file rotation interval either in terms of size or time. Thus, when the interval limit has been reached, a new pcap file will be started. As size parameter, the following values are accepted<num>KiB/MiB/GiB; As time parameter, it can be<num>s/sec/min/hrs. β-J,--jumbo-supportβ By default, in pcap replay or redirect mode, netsniff-ng's ring buffer frames are a fixed size of 2048 bytes. This means that if you are expecting jumbo frames or even super jumbo frames to pass through your network, then you need to enable support for that by using this option. However, this has the disadvantage of performance degradation and a bigger memory footprint for the ring buffer. Note that this doesn't affect (pcap) capturing mode, since tpacket in version 3 is used! π-R,--rfrawβ In case the input or output networking device is a wireless device, it is possible with netsniff-ng to turn this into monitor mode and create amon<X>device that netsniff-ng will be listening on instead ofwlan<X>, for instance. This enables netsniff-ng to analyze, dump, or even replay raw 802.11 frames. π§-n <0|uint>,--num <0|uint>β Process a number of packets and then exit. If the number of packets is 0, then this is equivalent to infinite packets resp. processing until interrupted. Otherwise, a number given as an unsigned integer will limit processing. π-O <N>,--overwrite <N>β A number from 0 to N-1 will be used in the file name instead of a Unix timestamp. The previous file will be overwritten when number wraps around. The maximum value is2^32 - 1. Intended for rotating capture files when used with options-Fand-P. π-P <name>,--prefix <name>β When dumping pcap files into a folder, a file name prefix can be defined with this option. If not otherwise specified, the default prefix isdump-followed by a Unix timestamp. Use--prefex ""to set filename as seconds since the Unix Epoch e.g.1369179203.pcap. π-T <pcap-magic>,--magic <pcap-magic>β okay so you wanna pick which pcap type to save as? Different pcap types have different meta data superpowers, and you can see all of them with-D. If you don't specify, it defaults to0xa1b2c3d4β that's the classic tcpdump-capable pcap format, bestie. Also, pcap files with swapped endianness? Totally supported. π-D,--dump-pcap-typesβ this dumps every available pcap type, showing off their capabilities and magic numbers you can use with-T, straight to stdout, and then it exits. Slay. β¨-B,--dump-bpfβ if you've got a Berkeley Packet Filter (like via option-f), this dumps the BPF disassembly to stdout while the ring is being set up. It's just for info or verification, no cap. π«Ά-r,--randβ if both input and output device are networking devices, this randomizes the packet order in the output ring buffer. Shuffle mode activated. π-M,--no-promiscβ this keeps the networking interface out of promiscuous mode. By default, promiscuous mode is ON, so this is the off switch. π-N,--no-hwtimestampβ no hardware time stamps for RX packets. By default, if your network device supports hardware time stamping, those hardware stamps get used when writing packets to pcap files. This option turns that off and forces (kernel based) software time stamps instead, even if hardware ones are right there. Sorry bestie, software only. π-A,--no-sock-memβ normally on startup and shutdown, netsniff-ng tries to bump up socket read and write buffers if it makes sense. This option says βnah, don't do that.β π-m,--mmapβ usemmap(2)for pcap file I/O. This is the default when you're replaying pcap files. π-G,--sgβ use scatter-gather for pcap file I/O. This is the default when capturing pcap files. π-c,--clrwβ use the slowerread(2)andwrite(2)I/O. Not the default anywhere, but sometimes it's preferred because it has lower latency when writing back to disc. π’-S <size>,--ring-size <size>β manually set the RX_RING or TX_RING size using<num>KiB/MiB/GiB. By default, the size is auto-picked based on your network connectivity rate. π-k <uint>,--kernel-pull <uint>β manually set how often (in micro-seconds) the kernel gets poked to batch process ring buffer frames. Default is every10us, but you can stretch it out if you want. β±οΈ-b <cpu>,--bind-cpu <cpu>β pin netsniff-ng to a specific CPU, and also pin or migrate the NIC's IRQ CPU affinity to that same CPU. If you're expecting medium-to-high packet rates, use this with-s. π―-u <uid>,--user <uid>resp.-g <gid>,--group <gid>β after the ring is set up, drop privileges to a non-root user/group combo. Bye bye root. π-H,--prio-highβ make this process high priority so it gets more scheduling rate and CPU time. But heads up: this is NOT the default, because it could starve other processes β like low-priority kernel threads. Use with care. β οΈ-Q,--notouch-irqβ don't touch the NIC's IRQ CPU affinity settings. Leave them exactly as they are. β-s,--silentβ don't even enter the packet dissector, and don't print any packet info to the terminal. Just shut up and be silent. Bestie, this is the one to use with pcap recording or replay β because flooding your terminal causes a significant performance drop. No cap. π€«-q,--lessβ print a less verbose one-liner for each packet to the terminal. Less yapping. π-X,--hexβ only dump packets in hex format to the terminal. π’-l,--asciiβ only show ASCII printable characters. π€-U,--updateβ if you're using geographical IP location, this triggers the built-in database update to grab Maxmind's latest database. To configure where to look for databases, the file/etc/netsniff-ng/geoip.confholds possible addresses. So to save bandwidth or mirror Maxmind's databases (and bypass their traffic limit policy), you can put different hosts or IP addresses intogeoip.conf, each separated by a newline. π-w,--cookedβ replace each frame link header with a Linux βcookedβ header [3], which keeps info about link type and protocol. This lets you dump and dissect frames from different link types β like when-i "any"was specified, for example. π³-V,--verboseβ be extra verbose during startup β like, show detailed ring setup info. π£οΈ-v,--versionβ show version info and dip out. π¦-h,--helpβ show user help and exit. π
β¨ USAGE EXAMPLE β¨
netsniff-ng
The simplest vibe is to just run netsniff-ng. This will start listening on all available networking devices in promiscuous mode and dump the packet dissector output to the terminal. No files will be recorded. Just pure observation energy. π
netsniff-ng --in eth0 --out dump.pcap -s -T 0xa1e2cb12 -b 0 tcp or udp
Capture TCP or UDP traffic from the networking device eth0 into the pcap file named dump.pcap, which has netsniff-ng specific pcap extensions (see netsniff-ng -D for capabilities). Also, don't print the content to the terminal and pin the process and NIC IRQ affinity to CPU 0. The pcap write method is scatter-gather I/O. π₯
netsniff-ng --in wlan0 --rfraw --out dump.pcap --silent --bind-cpu 0
Put the wlan0 device into monitoring mode and capture all raw 802.11 frames into the file dump.pcap. Don't dissect and print the content to the terminal, and pin the process and NIC IRQ affinity to CPU 0. The pcap write method is scatter-gather I/O. π°οΈ
netsniff-ng --in dump.pcap --mmap --out eth0 -k1000 --silent --bind-cpu 0
Replay the pcap file dump.pcap which is read through mmap(2) I/O and send the packets out via the eth0 networking device. Don't dissect and print the content to the terminal, and pin the process and NIC IRQ affinity to CPU 0. Also, trigger the kernel every 1000us to traverse the TX_RING instead of every 10us. Note that the pcap magic type is detected automatically from the pcap file header. π¬
netsniff-ng --in eth0 --out eth1 --silent --bind-cpu 0 --type host -r
Redirect network traffic from the networking device eth0 to eth1 for traffic that is destined for our host, thus ignore broadcast, multicast and promiscuous traffic. Randomize the order of packets for the outgoing device and don't print any packet contents to the terminal. Also, pin the process and NIC IRQ affinity to CPU 0. π
netsniff-ng --in team0 --out /opt/probe/ -s -m --interval 100MiB -b 0
Capture on an aggregated team0 networking device and dump packets into multiple pcap files that are split into 100MiB each. Use mmap(2) I/O as a pcap write method, support for super jumbo frames is built-in (doesn't need to be configured here), and don't print the captured data to the terminal. Pin netsniff-ng and NIC IRQ affinity to CPU 0. The default pcap magic type is 0xa1b2c3d4 (tcpdump-capable pcap). ποΈ
netsniff-ng --in vlan0 --out dump.pcap -c -u `id -u bob` -g `id -g bob`
Capture network traffic on device vlan0 into a pcap file called dump.pcap by using normal read(2), write(2) I/O for the pcap file (slower but less latency). Also, after setting up the RX_RING for capture, drop privileges from root to the user and group βbobβ. Invoke the packet dissector and print packet contents to the terminal for further analysis. π΅οΈββοΈ
netsniff-ng --in any --filter http.bpf -B --ascii -V
Capture from all available networking interfaces and install a low-level filter that was previously compiled by bpfc(8) into http.bpf in order to filter HTTP traffic. Super jumbo frame support is automatically enabled and only print human readable packet data to the terminal, and also be more verbose during setup phase. Moreover, dump a BPF disassembly of http.bpf. π‘
netsniff-ng --in dump.pcap --out dump.cfg --silent
Convert the pcap file dump.pcap into a trafgen(8) configuration file dump.cfg. Don't print pcap contents to the terminal. π
netsniff-ng -i dump.pcap -f beacon.bpf -o -
Convert the pcap file dump.pcap into a trafgen(8) configuration file and write it to stdout. However, don't dump all of its content, but only the one that passes the low-level filter for raw 802.11 from beacon.bpf. The BPF engine here is invoked in user space inside of netsniff-ng, so Linux extensions are not available. π§
cat foo.pcap | netsniff-ng -i - -o -
Read a pcap file from stdin and convert it into a trafgen(8) configuration file to stdout. Pipe dreams do come true. π
netsniff-ng -i nlmon0 -o dump.pcap -s
Capture netlink traffic to a pcap file. This command needs a netlink monitoring device to be set up beforehand using the following commands using ip(1) from the iproute2 utility collection:
modprobe nlmon
ip link add type nlmon
ip link set nlmon0 up
To tear down the nlmon0 device, use the following commands:
ip link set nlmon0 down
ip link del dev nlmon0
rmmod nlmon
netsniff-ng --fanout-group 1 --fanout-type cpu --fanout-opts defrag --bind-cpu 0 --notouch-irq --silent --in em1 --out /var/cap/cpu0/ --interval 120sec
Start two netsniff-ng fanout instances. Both are assigned into the same fanout group membership and traffic is splitted among them by incoming cpu. Furthermore, the kernel is supposed to defragment possible incoming fragments. First instance is assigned to CPU 0 and the second one to CPU 1, IRQ bindings are not altered as they might have been adapted to this scenario by the user a-priori, and traffic is captured on interface em1, and written out in 120 second intervals as pcap files into /var/cap/cpu0/. Tools like mergecap(1) will be able to merge the cpu0/1 split back together if needed. π§©
π CONFIG FILES π
Bestie, the files chilling under /etc/netsniff-ng/ are all editable, and tweaking them literally levels up what netsniff-ng can do for you:
oui.confβ the OUI/MAC vendor database, aka who-made-this-NIC energyether.confβ Ethernet type descriptionstcp.confβ TCP port/services mapudp.confβ UDP port/services mapgeoip.confβ GeoIP database mirrors
π¦ FILTER EXAMPLE π¦
So netsniff-ng is a β¨bothβ¨ girl β it rocks low-level and high-level filters, and they get attached to its packet(7) socket. The low-level ones live in the bpfc(8) man page, iykyk.
Here's how you flex low-level filters with netsniff-ng:
bpfc foo > barnetsniff-ng -f barbpfc foo | netsniff-ng -i nlmon0 -f -
In that little scenario, foo is the bpfc program getting translated into a netsniff-ng readable "opcodes" file, then handed over to netsniff-ng through the -f option. Slay.
Similarly, a high-level filter can be passed through the -f option too, like -f "tcp or udp", or you can just drop it at the end of all the options, no -f required. Main character behavior.
The filter syntax is exactly the same as in tcpdump(8), which is described over in the pcap-filter(7) man page. Just to quote some examples for you:
host sundownβ selects every packet arriving at or departing from sundown.host helios and (hot or ace)β selects traffic between helios and either hot or ace.ip host ace and not heliosβ selects all IP packets between ace and any host except helios.net ucb-etherβ selects all traffic between local hosts and hosts at Berkeley.gateway snup and (port ftp or ftp-data)β selects all FTP traffic through the Internet gateway snup.ip and not net localnetβ selects traffic that's neither sourced from nor destined for local hosts. If you've got a gateway to another network, this traffic should never make it onto your local network.tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnetβ selects the start and end packets (the SYN and FIN packets) of each TCP conversation that involves a non-local host.tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)β selects all IPv4 HTTP packets to and from port 80, meaning it prints only packets that contain data β not, for example, SYN and FIN packets and ACK-only packets. (IPv6 is left as an exercise for the reader, bestie, good luck π)gateway snup and ip[2:2] > 576β selects IP packets longer than 576 bytes sent through gateway snup.ether[0] & 1 = 0 and ip[16] >= 224β selects IP broadcast or multicast packets that were not sent via Ethernet broadcast or multicast.icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreplyβ selects all ICMP packets that are not echo requests or replies (that is to say, not "ping" packets).
πΎ PCAP FORMATS πΎ
netsniff-ng supports a whole lil' squad of pcap formats, and you can peep them with netsniff-ng -D:
- tcpdump-capable pcap (default) β the pcap magic number is encoded as
0xa1b2c3d4resp.0xd4c3b2a1. As packet meta data, this format contains the timeval in microseconds, the original packet length and the captured packet length. - tcpdump-capable pcap with ns resolution β the pcap magic number is encoded as
0xa1b23c4dresp.0x4d3cb2a1. As packet meta data, this format contains the timeval in nanoseconds, the original packet length and the captured packet length. - Alexey Kuznetzov's pcap β the pcap magic number is encoded as
0xa1b2cd34resp.0x34cdb2a1. As packet meta data, this format contains the timeval in microseconds, the original packet length, the captured packet length, the interface index (sll_ifindex), the packet's protocol (sll_protocol), and the packet type (sll_pkttype). - netsniff-ng pcap β the pcap magic number is encoded as
0xa1e2cb12resp.0x12cbe2a1. As packet meta data, this format contains the timeval in nanoseconds, the original packet length, the captured packet length, the timestamp hw/sw source, the interface index (sll_ifindex), the packet's protocol (sll_protocol), the packet type (sll_pkttype) and the hardware type (sll_hatype).
If you want the deeper implementation tea, or you're adding format support to your own app, go peek at pcap_io.h in the netsniff-ng sources. π«Ά
π NOTE π
Okay so just to avoid any confusion: there's another network analyzer out there with a suspiciously similar name called NetSniff, and it is completely unrelated to the netsniff-ng project. Not the same girl, not the same vibe. π
If you're trying to introduce bit errors, delays with random variation and more while replaying pcaps, make use of tc(8) with its disciplines such as netem.
Also, real talk: netsniff-ng only does some basic, architecture generic tuning on startup. If you're thinking about doing high performance capturing, you genuinely need to carefully tune your machine β both hardware and software. Simply letting netsniff-ng run without thinking about your underlying system might not necessarily give you the desired performance. Note that tuning your system is always a tradeoff and a fine-grained balancing act (throughput versus latency). You should know what you are doing! No cap.
One recommendation for software-based tuning is tuned(8). Besides that, there are so many other things to consider. Just to throw you a few things you might want to look at: NAPI networking drivers, tickless kernel, I/OAT DMA engine, Direct Cache Access, RAM-based file systems, multi-queues, and many more things. Also, you might want to read the kernel's Documentation/networking/scaling.txt file regarding technologies such as RSS, RPS, RFS, aRFS and XPS. Also check your ethtool(8) settings, for example regarding offloading or Ethernet pause frames.
Moreover, to get a deeper understanding of netsniff-ng internals and how it interacts with the Linux kernel, the kernel documentation under Documentation/networking/{packet_mmap.txt, filter.txt, multiqueue.txt} might be of interest.
Now β how do you sniff in a switched environment? I rudely refer to dSniff's documentation that says:
The easiest route is simply to impersonate the local gateway, stealing client traffic en route to some remote destination. Of course, the traffic must be forwarded by your attacking machine, either by enabling kernel IP forwarding or with a userland program that accomplishes the same (fragrouter -B1).
Several people have reportedly destroyed connectivity on their LAN to the outside world by ARP spoofing the gateway, and forgetting to enable IP forwarding on the attacking machine. Do not do this. You have been warned. π¨
A safer option than ARP spoofing would be to use a "port mirror" function if your switch hardware supports it and if you have access to the switch.
If you don't need to dump all possible traffic, you have to consider running netsniff-ng with a BPF filter for the ingress path. For that purpose, read the bpfc(8) man page.
Also, to aggregate multiple NICs that you want to capture on, you should consider using team devices, further explained in libteam resp. teamd(8).
The following netsniff-ng pcap magic numbers are compatible with other tools, at least tcpdump or Wireshark:
0xa1b2c3d4 (tcpdump-capable pcap)
0xa1b23c4d (tcpdump-capable pcap with ns resolution)
0xa1b2cd34 (Alexey Kuznetzov's pcap)
Pcap files with different meta data endianness are supported by netsniff-ng as well. β¨
π BUGS π
When replaying pcap files, the timing information from the pcap packet header is currently ignored. (Not me ignoring my own schedule either π)
Also, when replaying pcap files, demultiplexing traffic among multiple networking interfaces does not work. Currently, it is only sent via the interface that is given by the --out parameter.
When performing traffic capture on the Ethernet interface, the pcap file is created and packets are received but without a 802.1Q header. When one uses tshark, all headers are visible, but netsniff-ng removes 802.1Q headers. Is that normal behavior?
Yes and no. The way VLAN headers are handled in PF_PACKET sockets by the kernel is somewhat "problematic" [1]. The problem in the Linux kernel is that some drivers already handle VLANs, others do not. Those who handle it can have different implementations, such as hardware acceleration and so on. So in some cases the VLAN tag is even stripped before entering the protocol stack, in some cases probably not. The bottom line is that a "hack" was introduced in PF_PACKET so that a VLAN ID is visible in some helper data structure that is accessible from the RX_RING.
Then it gets really messy in the user space to artificially put the VLAN header back into the right place. Not to mention the resulting performance implications on all of libpcap(3) tools, since parts of the packet need to be copied for reassembly via memmove(3).
A user reported the following, just to demonstrate this mess: some tests were made with two machines, and it seems that results depend on the driver ...
AR8131:
ethtool -k eth0 gives "rx-vlan-offload: on"
- wireshark gets the vlan header
- netsniff-ng doesn't get the vlan header
ethtool -K eth0 rxvlan off
- wireshark gets a QinQ header even though no one sent QinQ
- netsniff-ng gets the vlan header
RTL8111/8168B:
ethtool -k eth0 gives "rx-vlan-offload: on"
- wireshark gets the vlan header
- netsniff-ng doesn't get the vlan header
ethtool -K eth0 rxvlan off
- wireshark gets the vlan header
- netsniff-ng doesn't get the vlan header
Even if we agreed on doing the same workaround as libpcap, we still will not be able to see QinQ, for instance, due to the fact that only one VLAN tag is stored in the kernel helper data structure. We think that there should be a good consensus on the kernel space side about what gets transferred to userland first.
Update (28.11.2012): the Linux kernel and also bpfc(8) has built-in support for hardware accelerated VLAN filtering, even though tags might not be visible in the payload itself as reported here. However, the filtering for VLANs works reliable if your NIC supports it. See bpfc(8) for an example.
- [1] http://lkml.indiana.edu/hypermail/linux/kernel/0710.3/3816.html
- [2] http://www.tcpdump.org/linktypes/LINKTYPE_NETLINK.html
- [3] http://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html
πΈ LEGAL πΈ
netsniff-ng is licensed under the GNU GPL version 2.0.
π§ HISTORY π§
netsniff-ng was originally written for the netsniff-ng toolkit by Daniel Borkmann. Bigger contributions were made by Emmanuel Roullit, Markus Amend, Tobias Klauser and Christoph Jaeger. It is currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.
π SEE ALSO π
trafgen(8), mausezahn(8), ifpps(8), bpfc(8), flowtop(8), astraceroute(8), curvetun(8)
β¨ AUTHOR β¨
This manpage was written by <strong>Daniel Borkmann</strong>.</strong> π«Ά Absolute legend behavior, honestly β writing the tool and the docs? That's main character energy fr fr. π
π COLOPHON π
Okay so this page is part of the Linux netsniff-ng toolkit project. π If you wanna know more about the project, or you found a bug and need to go tell someone about it (respect, bestie, that's how it gets better), you can find all of that right here:
That's the spot. The whole description of the project lives there, and so does the bug-reporting info. Go be nosy, it's encouraged. π¦β¨
And that's the whole page, bestie!! You read a manual page cover to cover, which is lowkey iconic of you. πΈ Go sniff some packets, stay safe, and remember: always check your interface before you -i it. ππ
This little beauty comes from the <strong>Linux</strong> corner of the world, dated <strong>03 March 2013</strong>, and it goes by the name <strong>NETSNIFF-NG(8)</strong>. Periodt. π
π
π¦ where this page comes from
- arch rolling: netsniff-ng 0.6.9-2 Β· GPL-2.0-only
- debian bookworm: netsniff-ng 0.6.8-3 Β· GPL-2.0-only
- debian trixie: netsniff-ng 0.6.9-1 Β· GPL-2.0-only
- epel 10: netsniff-ng 0.6.9-2.el10_1 Β· GPL-2.0-only
- epel 9: netsniff-ng 0.6.8-11.el9 Β· GPLv2
- fedora 43: netsniff-ng 0.6.9-4.fc43 Β· GPL-2.0-only
- fedora 44: netsniff-ng 0.6.9-5.fc44 Β· GPL-2.0-only
- nixos 26.05: netsniff-ng 0.6.9
- nixpkgs unstable: netsniff-ng 0.6.9
- ubuntu jammy: netsniff-ng 0.6.8-2build1 Β· GPL-2.0-only
- ubuntu noble: netsniff-ng 0.6.8-3build2 Β· GPL-2.0-only
- ubuntu questing: netsniff-ng 0.6.9-1
- ubuntu resolute: netsniff-ng 0.6.9-2 Β· GPL-2.0-only
- ubuntu stonking: netsniff-ng 0.6.9-2build1 Β· GPL-2.0-only
- Copyright 2013 Daniel Borkmann
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms