Skip to content
Back to skills

Routeros Sniffer

ASecurity

RouterOS packet capture and TZSP streaming for protocol debugging. Use when: capturing packets on RouterOS, setting up /tool/sniffer, streaming live traffic via TZSP, using firewall mangle action=sniff-tzsp, debugging network protocols on MikroTik, receiving TZSP with Wireshark or tshark, saving pcap files from RouterOS, or when the user mentions packet sniffer, TZSP, sniff-tzsp, /tool/sniffer, or packet capture on RouterOS.

  • 94 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added May 26, 2026
devopsgotestingdebugginggitapi

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 21, 2026

npx -y skills add tikoci/routeros-skills --skill routeros-sniffer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Routeros Sniffer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Routeros Sniffer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tikoci-routeros-sniffer/badge)](https://www.skillsdirectory.com/skills/tikoci-routeros-sniffer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: routeros-sniffer
description: "RouterOS packet capture and TZSP streaming for protocol debugging. Use when: capturing packets on RouterOS, setting up /tool/sniffer, streaming live traffic via TZSP, using firewall mangle action=sniff-tzsp, debugging network protocols on MikroTik, receiving TZSP with Wireshark or tshark, saving pcap files from RouterOS, or when the user mentions packet sniffer, TZSP, sniff-tzsp, /tool/sniffer, or packet capture on RouterOS."
---

# RouterOS Packet Capture & TZSP Streaming

RouterOS has a built-in packet sniffer (`/tool/sniffer`) and firewall mangle actions that can mirror traffic — either saving to a file on the router or streaming live to a remote host via TZSP (TaZmen Sniffer Protocol). This is the primary way to capture packets on RouterOS since standard tools like `tcpdump` do not exist (see `routeros-fundamentals` skill).

## Why This Matters for Agents

When debugging any network protocol issue on RouterOS, agents should know they can:

1. **Stream live packets** from the router to the host machine via TZSP — no hardware needed if using a CHR VM
2. **Save pcap/pcapng files** on the router's flash and download them for analysis
3. **Use firewall mangle rules** for surgical, per-flow packet mirroring without touching the sniffer config

Combined with a QEMU CHR instance (see `routeros-qemu-chr` skill), this gives agents a complete packet-level debugging workflow with zero physical hardware.

## Method 1: /tool/sniffer (Full Capture Tool)

The built-in sniffer captures packets on specified interfaces with extensive filtering. It supports **three independent output modes** that can be combined:

| Output | Setting | Notes |
|--------|---------|-------|
| Memory buffer | (always on) | Viewable via `quick`, `packet`, `protocol`, `host`, `connection` submenus. Packets available for 10 minutes |
| File on flash | `file-name=capture.pcapng` | PCAPNG since RouterOS 7.20, whatever the file name says[^tzsp-lab] |
| TZSP stream | `streaming-enabled=yes` | UDP to `streaming-server` on `streaming-port` (default 37008) |

### Live TZSP Streaming

```routeros
# Configure sniffer to stream via TZSP to a remote host
/tool/sniffer
set streaming-enabled=yes streaming-server=<RECEIVER-IP>:37008 filter-stream=yes

# Optional: filter to a specific interface or protocol
set filter-interface=ether1
set filter-ip-protocol=icmp

# Start capture (runs until stopped or router reboots)
/tool/sniffer/start

# Stop when done
/tool/sniffer/stop
```

The receiver host runs Wireshark, tshark, or another TZSP-capable tool (see [TZSP receivers reference](./references/tzsp-receivers.md)).

### File-Based Capture

```routeros
# Capture to file on router flash
/tool/sniffer
set file-name=capture.pcapng filter-interface=ether1

/tool/sniffer/start
# ... let it capture ...
/tool/sniffer/stop

# Or save the memory buffer to a file manually
/tool/sniffer/save file-name=/flash/debug.pcapng

# Download via SCP or fetch
# From the host:
# scp admin@<ROUTER-IP>:/flash/debug.pcapng .
```

File + streaming can run simultaneously:

```routeros
/tool/sniffer
set file-name=capture.pcapng streaming-enabled=yes streaming-server=<RECEIVER-IP>:37008 filter-stream=yes
/tool/sniffer/start
```

### Quick Mode (Interactive CLI)

For quick one-off inspection directly on the router console:

```routeros
# Quick-capture ICMP traffic on ether1
/tool/sniffer/quick ip-protocol=icmp interface=ether1
```

This shows a live scrolling table on the console with source/dest MAC, IP, protocol, and size.

### Sniffer Filter Properties

Key filter options for `/tool/sniffer/set`:

| Property | Description |
|----------|-------------|
| `filter-interface` | Interface name or `all` (default: `all`) |
| `filter-ip-address` | Up to 16 IP/mask entries |
| `filter-dst-ip-address` | Up to 16 destination IP/mask entries |
| `filter-src-ip-address` | Up to 16 source IP/mask entries |
| `filter-port` | Up to 16 ports (supports `!` negation) |
| `filter-ip-protocol` | Up to 16 protocols (tcp, udp, icmp, etc.) |
| `filter-mac-protocol` | Up to 16 MAC protocols (ip, arp, ipv6, vlan, etc.) |
| `filter-direction` | `any`, `rx`, or `tx` |
| `filter-stream` | `yes`/`no` — filter out sniffer's own TZSP packets (default: `no` on 7.24.6 and 7.25.1)[^tzsp-lab] |
| `filter-vlan` | Up to 16 VLAN IDs |
| `memory-limit` | Memory buffer size (default: 100 KiB) |
| `file-limit` | Max file size (default: 1000 KiB) |
| `only-headers` | Save only packet headers, not the full payload. On the x86_64 CHRs a 1000-byte ping arrived as its first 60 bytes of Ethernet frame, with no TZSP tag giving the original length[^tzsp-lab] |
| `filter-operator-between-entries` | How filters combine: `or` (default) or `and`[^tzsp-lab] |

**Important:** set `filter-stream=yes` whenever you stream. It is off by default, and with it off a filter that matches the stream's own UDP captures the stream: on x86_64 CHRs (7.24.6 and 7.25.1), one ping with `filter-ip-protocol=icmp,udp` became about 800 nested TZSP datagrams in 4 s.[^tzsp-lab]

Entries within one filter combine with `or` by default (`filter-operator-between-entries`); different filters must all match. With `filter-operator-between-entries=and` and only `filter-ip-protocol=icmp,udp` set, nothing streamed in the same lab.

## Method 2: Firewall Mangle (Targeted Mirroring)

Firewall mangle rules offer **granular per-flow mirroring** using the full firewall matcher. Two sniff-related actions exist:

### action=sniff-tzsp (Stream to Remote TZSP Receiver)

Mirrors matching packets as TZSP to a remote host. Uses the firewall's full matching engine (src/dst address, protocol, port, connection state, interface, etc.):

```routeros
# Mirror all forwarded ICMP to a TZSP receiver
/ip/firewall/mangle
add action=sniff-tzsp chain=forward protocol=icmp \
    sniff-target=<RECEIVER-IP> sniff-target-port=37008 \
    comment="TZSP mirror ICMP to Wireshark"

# Mirror traffic from a specific host
/ip/firewall/mangle
add action=sniff-tzsp chain=forward src-address=192.168.88.100 \
    sniff-target=<RECEIVER-IP> sniff-target-port=37008

# Mirror DNS queries
/ip/firewall/mangle
add action=sniff-tzsp chain=forward protocol=udp dst-port=53 \
    sniff-target=<RECEIVER-IP> sniff-target-port=37008
```

Properties for `sniff-tzsp`:

- `sniff-target` (IP) — destination IP for the TZSP UDP packets
- `sniff-target-port` (port, default 37008) — destination UDP port

`sniff-tzsp` accepts `sniff-id=` on `add` but doesn't keep it: it is missing from the REST record, `print detail` and `export`, and the datagrams carry no tag for it.[^tzsp-lab]

On the x86_64 CHRs, the router's own echo requests copied in the `output` and `postrouting` chains arrived behind an Ethernet header with all-zero MACs, while `prerouting` and `input` copies kept the link's MACs.[^tzsp-lab]

**Key behavior:** `sniff-tzsp` acts like `passthrough` — after matching, the packet continues to the next mangle rule. The original packet is NOT modified or dropped; only a copy is sent as TZSP.

### action=sniff-pc (Not TZSP)

The other sniff action, `sniff-pc`, keeps `sniff-id` but doesn't send TZSP. On the tested x86_64 CHRs each datagram had the id as 4 big-endian bytes, then 8 bytes that changed per packet, the IPv4 packet (no Ethernet header) at offset 12, and 14 trailing bytes.[^tzsp-lab] A TZSP receiver can't read it; use `sniff-tzsp` for Wireshark or tshark.

### Mangle vs /tool/sniffer: When to Use Which

| Scenario | Use |
|----------|-----|
| Capture all traffic on an interface | `/tool/sniffer` |
| Mirror specific flows (by IP, port, protocol) | Mangle `sniff-tzsp` |
| Save a capture file on router flash | `/tool/sniffer` with `file-name` |
| Stream live to Wireshark/tshark | Either — `/tool/sniffer` with `streaming-enabled` or mangle `sniff-tzsp` |
| Multiple independent mirrors to different receivers | Mangle rules (one per target) |
| Quick interactive CLI view | `/tool/sniffer/quick` |

## TZSP Protocol Overview

TZSP is a simple UDP encapsulation — the router wraps the captured frame in a TZSP header and sends it as a UDP datagram:

```text
UDP (port 37008) → TZSP header (4 bytes) → tags (variable) → TAG_END → captured frame bytes
```

- **Default port:** 37008 (`0x9090`) — not IANA-registered but the RouterOS/Wireshark standard
- **Encapsulation:** Typically Ethernet (type 1); 802.11 for wireless captures
- **Tags:** Optional metadata (WLAN signal strength, channel, etc.); Ethernet captures usually have no tags
- **Record type:** the tested RouterOS streams (both senders, 7.24.6 and 7.25.1) used type 0 "received": every datagram began `01 00 00 01 01` (version 1, type 0, Ethernet, end tag, no tags).[^tzsp-lab] No type 4 keepalives appeared in those short runs, so don't rely on them

## CHR Testing Pattern

A QEMU CHR instance provides a complete packet capture lab with zero hardware. The free CHR license has a **1 Mbps speed limit** but this is sufficient for protocol debugging and sniffer testing.

```sh
# 1. Boot a CHR instance with port forwarding for REST API and SSH
qemu-system-x86_64 -M q35 -m 256 \
  -drive file=chr.img,format=raw,if=virtio \
  -netdev user,id=net0,hostfwd=tcp::9180-:80,hostfwd=tcp::9122-:22 \
  -device virtio-net-pci,netdev=net0 \
  -display none -serial stdio

# 2. Configure sniffer via REST API once booted
curl -u admin: -X POST http://<router-ip>/rest/tool/sniffer/set \
  -H 'Content-Type: application/json' \
  -d '{"streaming-enabled":"yes","streaming-server":"10.0.2.2:37008","filter-stream":"yes"}'

# 3. Start capture
curl -u admin: -X POST http://<router-ip>/rest/tool/sniffer/start

# 4. Listen for TZSP on the host
tshark -i any -f "udp port 37008" -O tzsp

# 5. Generate test traffic (e.g., ping from the CHR)
curl -u admin: -X POST http://<router-ip>/rest/ping \
  -H 'Content-Type: application/json' \
  -d '{"address":"8.8.8.8","count":"3"}'
```

**QEMU user-mode networking note:** The CHR's default gateway (10.0.2.2) is the host. Use this IP as `streaming-server` when using QEMU `-netdev user`. The host must listen on all interfaces (or 10.0.2.2 specifically) to receive the TZSP packets.

For full QEMU setup details, see the `routeros-qemu-chr` skill. For CHR licensing details (free tier, 60-day trial, speed limits), see [CHR licensing](../routeros-qemu-chr/references/chr-licensing.md).

## Gotchas

- **Hardware-offloaded bridge traffic** is NOT visible to the sniffer — only flooded packets (unknown unicast, broadcast, multicast) may appear
- **Wireless client-to-client** unicast with forwarding enabled is NOT visible
- **Sniffed packets in memory expire after 10 minutes** — save to file or use streaming for persistent capture
- **PCAPNG format** (RouterOS 7.20+) is what saved files contain, even when the name ends in `.pcap` — RouterOS keeps the name exactly as given. In the CHR lab each direction was its own interface (`ether1 rx`, `ether1 tx`), timestamps were in nanoseconds, and each packet carried a `cpu:0 fp:0` comment. Older tools may need PCAP
- **`filter-stream` is off by default** — set `filter-stream=yes` when streaming, or the sniffer can capture its own TZSP packets in a feedback loop
- **1 Mbps CHR speed limit** may cause "slow" captures — this is the free license limit, not a sniffer issue. See [CHR licensing](../routeros-qemu-chr/references/chr-licensing.md)
- **`file-limit` should not exceed free memory** — the router may crash or behave unexpectedly

## Cleanup

Always clean up sniffer config and mangle rules after debugging:

```routeros
# Stop sniffer
/tool/sniffer/stop

# Reset sniffer config to defaults
/tool/sniffer
set streaming-enabled=no streaming-server=0.0.0.0 file-name=""

# Remove mangle rules (find by comment)
/ip/firewall/mangle/remove [find comment~"TZSP"]
```

## Additional Resources

- To identify MikroTik-specific traffic in a capture (by port or EtherType) and find decoding references: [routeros-proprietary-protocols](../routeros-proprietary-protocols/SKILL.md).

**Reference files:**

- For TZSP receiver setup (Wireshark, tshark, tcpdump): see [TZSP receivers reference](./references/tzsp-receivers.md)

**Related skills:**

- For QEMU CHR setup and boot patterns: see `routeros-qemu-chr` skill
- For CHR licensing (free tier, 60-day trial, speed limits): see `routeros-qemu-chr` skill
- For RouterOS CLI/REST basics: see `routeros-fundamentals` skill
- For the `/console/inspect` command tree: see `routeros-command-tree` skill

**MCP tools:**

- For RouterOS docs lookup: use the `rosetta` MCP server tools (`routeros_search`, `routeros_get_page`)

[^tzsp-lab]: tikoci/tzsp-sniff TZSP sender lab, 2026-11-19: quickchr CHRs on 7.25.1 (x86_64 and arm64) and 7.24.6 long-term (x86_64), raw datagrams and saved files retained as evidence. [`test/lab/tzsp-senders/REPORT.md`](https://github.com/tikoci/tzsp-sniff/blob/c548cfe47f5a675da77b508f10bad29b7a46c2d1/test/lab/tzsp-senders/REPORT.md) (tikoci/tzsp-sniff#7).

Files in this skill

  • SKILL.md10.2 KB
  • references/tzsp-receivers.md4.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.