DMIRror
Manage directed port mirroring
- DMIRror
Shortest form:
dmir.Set up per-port mirroring (“directed mirroring”): copy packets received and/or sent on some ports to a destination port or trunk.
dmirror <ports> show mirroring of <ports> dmirror SHow show every port that mirrors dmirror <ports> Mode=<OFF|ON|Ingress|Egress|All> [DestPort=<port>] [DestModule=<modid>] [DestTrunk=<tgid>] [MirrorTagProtocolID=<tpid>] [MirrorVlanID=<vid>]<ports>is a port list such asxe0,ce1,ce2orall(seepbmp). The CPU port (cpu0) can be a destination.Ingressmirrors received packets,Egresssent packets, andAllboth.The shell behaves differently from the built-in help in these ways:
The help shows
Modeas optional. In fact it is required whenever any option is given; otherwise the shell printsmust specify a mode.The help says “DestTrunk overrides DestModule/DestPort”. In fact giving both
DestPortandDestTrunkis refused (cannot specify both DestPort and DestTrunk). Any mode other thanOFFneeds one of them (missing DestPort or DestTrunk).dmirror showworks but is not in the help.The mirror TPID and VLAN are applied only when both are given and the destination is a local port, not a trunk.
Warning
Mode=OFFremoves every mirror destination on those ports, both ingress and egress, including mirror sessions (SPAN/ERSPAN) that SONiC configured. Setting a mirror uses the same hardware mirror resources as SONiC’s mirror sessions. Neither change is visible to SONiC.Seeing mirrored traffic with
tcpdump: Capture port traffic with tcpdump.Unvalidated — Copy everything received on xe0 to the CPU (prints nothing on success)
drivshell> dmirror xe0 mode=ingress destport=cpu0Unvalidated — Stop mirroring on xe0 (also removes any other mirror on xe0)
drivshell> dmirror xe0 mode=offHardware-validated — Show the mirror state of one port
drivshell> dmirror xe0 xe0: -
With a port list and no options,
dmirrorprints one line per port, for examplexe0: Mirror ingress to local port cpu0, orxe0: -when the port does not mirror. A trunk destination shows asto trunk group <n>, and a configured mirror VLAN is appended as(TPID=…, VLAN=…).- dmirror SHow
Show every port that mirrors, one line per port in the format above. If no port mirrors, it prints
DMIRror: No mirror ports configured(the prefix is the command’s table name, not what you typed). A SONiC switch without mirror sessions prints this line. Safe.Hardware-validated
drivshell> dmirror show DMIRror: No mirror ports configured
Built-in help
Parameters: <ports> [Mode=<Off|On|Ingress|Egress|All>] [DestPort=<port>] [DestModule=<modid>] [DestTrunk=<tgid>] [MirrorTagProtocolID=<tpid>] [MirrorVlanID=<vid> DestTrunk overrides DestModule/DestPort. TPID and VLAN are set only if DestPort is a local port.Further reading
bcmsh.md (published as https://kamelnetworks.github.io/sonic/bcmsh.html), BCM_SDK命令.