CRS312-4C+8XG port mirroring

Hello,

i would require some help. I am trying to mirror port Ether2 to Ether7 (so Ether7 is the port i want to tap into and capture using Wireshark).
The documentation at https://wiki.mikrotik.com/wiki/Manual:Switch_Chip_Features#Port_Mirroring says:

/interface ethernet switch
set switch1 mirror-source=ether2 mirror-target=ether7

but “mirror-source” is basically unknown and the command fails with

[admin@crs312] /interface/ethernet/switch> set mirror-source=ether2 mirror-target=ether7
expected end of command (line 1 column 19)

I don’t have Winbox handy (I am using macOS). How can i accomplish what i want? Many thanks in advance!

What do you get with:

/interface ethernet switch print

The command seems loosely of the kind:
set <attribute1=value1> <attribute2=value2>

Once you are in:
/interface/ethernet/switch
the command:
set switch1 mirror-source=ether2 mirror-target=ether7
is different from the one you posted:
set mirror-source=ether2 mirror-target=ether7

my bad. The command above as per documentation from Mikrotik fails the same; i already tried to fiddle around with the command to make it work.

[admin@crs312] /interface/ethernet/switch> set switch1 mirror-source=ether2 mirror-target=ether7
expected end of command (line 1 column 13)

If i enter “set switch1 mirror” the auto-completed line reads “set switch1 mirror-target=”. That’s why i deduced it does not know the command “mirror-source”.

I am on 7.16rc4, but it also happened with 7.15.

But do you have a “switch1”?

I asked for the output of
/interface/ethernet/switch
because yours could be called “switch2” or “mickey mouse”, and in some cases it may be easier to refer to the number (that you should get from the output of print).

Or try command line autocompletion from the beginning, , i.e.
set [TAB]
and see what options you have

sorry, here it is:

[admin@crs312] /interface/ethernet/switch> print
Columns: NAME, TYPE, L3-HW-OFFLOADING, QOS-HW-OFFLOADING

NAME TYPE L3-HW-OFFLOADING QOS-HW-OFFLOADING

0 switch1 Marvell-98DX8212 yes yes
1 switch2 Atheros-8227 no no

Ether2 and Ether7 belong to switch1

[admin@crs312] /interface/ethernet/switch> port print
Flags: R - RUNNING
Columns: NAME, SWITCH, L3-HW-OFFLOADING, STORM-RATE

NAME SWITCH L3-HW-OFFLOADING STORM-RATE

0 ether9 switch2
1 R ether1 switch1 yes 100
2 R ether2 switch1 yes 100
3 R ether3 switch1 yes 100
4 ether4 switch1 yes 100
5 R ether5 switch1 yes 100
6 ether6 switch1 yes 100
7 R ether7 switch1 yes 100
8 ether8 switch1 yes 100
9 R combo1 switch1 yes 100
10 combo2 switch1 yes 100
11 combo3 switch1 yes 100
12 R combo4 switch1 yes 100
13 switch1-cpu switch1 100
14 switch2-cpu switch2

Entering “set " and ” to auto-complete (or the line below, “set switch1 ”) results in:

[admin@crs312] /interface/ethernet/switch> set
switch1 switch2 cpu-flow-control l3-hw-offloading mirror-target name numbers qos-hw-offloading rspan rspan-egress-vlan-id rspan-ingress-vlan-id switch-all-ports
[admin@crs312] /interface/ethernet/switch> set switch1
cpu-flow-control l3-hw-offloading mirror-target name qos-hw-offloading rspan rspan-egress-vlan-id rspan-ingress-vlan-id switch-all-ports

Is it possible the documentation is not up to date?
If i go to /interface/ethernet/switch and do “port set ” i get:

[admin@crs312] /interface/ethernet/switch> port set
combo1 combo3 ether… switch2-cpu ingress-rate limit-broadcasts limit-unknown-unicasts mirror-ingress storm-rate
combo2 combo4 switch1-cpu egress-rate l3-hw-offloading limit-unknown-multicasts mirror-egress numbers

https://help.mikrotik.com/docs/display/ROS/CRS3xx%2C+CRS5xx%2C+CCR2116%2C+CCR2216+switch+chip+features#CRS3xx,CRS5xx,CCR2116,CCR2216switchchipfeatures-PortBasedMirroring

Port Based Mirroring

Starting from RouterOS version 7.15, it is possible to configure multiple source ports and selectively choose whether to mirror incoming traffic, outgoing traffic, or both. In this example, both incoming and outgoing traffic from the ether2 interface will be copied and sent to the ether3 interface for monitoring or analysis.

Since RouterOS v7.15

/interface ethernet switch port
set ether2 mirror-egress=yes mirror-ingress=yes
/interface ethernet switch
set switch1 mirror-target=ether3

Older RouterOS:

/interface ethernet switch
set switch1 mirror-source=ether2 mirror-target=ether3

many thanks, this was the information that i failed to find!
I have yet to verify it but the commands worked and i see traffic flowing in Wireshark so i am optimistic!

[admin@crs312] /interface/ethernet/switch/port> set ether2 mirror-egress=yes mirror-ingress=yes
[admin@crs312] /interface/ethernet/switch> set switch1 mirror-target=ether7

It is one of those (actually trifling) things that make you believe that sometimes the good Mikrotik guys do not think too much before changing a syntax.
I mean, I do understand how the new syntax allows to select whether the miroring is ingress or egress traffic (or both) but it could have been implemented differently, the “old” syntax was “easy” :

Older RouterOS:

/interface ethernet switch
set switch1 mirror-source=ether2 mirror-target=ether3

the new one is (IMHO without reason) stupidly complex, as the settings are divided into two different submenus:

Since RouterOS v7.15

/interface ethernet switch port
set ether2 mirror-egress=yes mirror-ingress=yes
/interface ethernet switch
set switch1 mirror-target=ether3

They could have done (still IMHO) :

#Hypothetical syntax
/interface ethernet switch
set switch1 mirror-source=ether2 mirror-target=ether3 mirroring=ingress|egress|both

With the default being “both”, this way all settings would have remained on one line.

The new one is (potentially) flexible, it may allow this scenario:

/interface ethernet switch port
set ether2 mirror-egress=yes mirror-ingress=no
set ether4 mirror-egress=no mirror-ingress=yes
set ether5 mirror-egress=yes mirror-ingress=yes
/interface ethernet switch
set switch1 mirror-target=ether3

I don’t see how this can be achieved using old syntax … multiple mirror sorces yes, but not selection of direction to be mirrored per mirrored source port.

Here you are:

#Hypothetical syntax
/interface ethernet switch
set switch1 mirror-source1=ether2 mirror-source2=ether4  mirror-source3=ether4 mirror-target=ether3 mirroring1=egress mirroring2=ingress mirroring3=both

sorry, but this doesn’t scale … and changes names of properties (to which you opposed).

Well, if I have ether1, ether2, etc., I surely can have mirror-source1, mirror-source2 and mirroring1, mirroring2, etc.
BTW, I don’t oppose to changing names of properties/obiects/whatever I am opposing to the idea that something to work needs settings in two different places.

Another, still IMHO valid approach could have been putting it (still all together) in a dedicated level, like:

#Hypothetical syntax
/interface ethernet switch mirroring
add name=mirror1 mirror-target=ether3 mirror-sources=ether2,ether4,ether5 mirroring=egress,ingress,both

I agree that it’s only too confusing to have to configure one functionality in multiple places (VLANs is a good example of this lunacy).

Instead here’s my proposal:

/interface ethernet switch port
set ether2 mirroring=egress mirror-targets=ether3
set ether4 mirroring=ingress mirror-targets=ether3
set ether5 mirroring=both mirror-targets=ether3,ether6

Even more scalable as it easily allows to set-up several mirroring targets and even miroring to multiple target ports. Surely this is not supported by many switch chips, but in case some future switch chips will support multiple mirror targets/pairs/whatever, this would then allow to utilize feature to its fullest without another syntax change.
ROS would have to carefully check the validity of settings (and observe the switch chip limitations). E.g. it should not allow setting mirror pair (source, destination) where all involved ports are not controlled by same switch chip (on devices with multiple switch chips installed) … ditto for ports connected directly to CPU. But those rules could be simply baked into ROS and then it would be only up to proper error reporting in case that user entered invalid parameter combination.

And yes, I like your concept of mirroring=none|both|ingress|egress instead of directly setting bits for the table (yuck!) … where none would disable the mirroring altogether for that particular port.

Yep, your proposal is just fine, everything is in one place, and it would be even better if the settings would be moved from “main”
/interface ethernet switch port
to its own level:
/interface ethernet switch port mirroring
or
/interface ethernet switch port mirrors

apart from the discussion how the syntax could have been adopted less impacting, less changed, yet more flexible, i basically just did not find the 7.15-7.16rc4 info on the page i received as google result when searching for the obvious search terms.

Yep, rest assured it is not you fault, usually when searching on Google the first results are on the (old) wiki that often gives obsolete info, then, when you get to the right “help” site finding the relevant information you are looking for is often challenging.
The way the topics are organized in Mikrotik documentation ranges from extremely simple, logical and straightforward to completely senseless, but on average they seem to me more like if a smart, good willing, alien from Alpha Centauri was trying to explain the way the engine of his flying saucer works, the overall principles can often be understood but most of the details are either missing (or omitted/given as implied/obvious) and the whole stuff is somehow permeated by a logic that while similar to ours remains slightly alien.
It seems like a relatively large group of non-native English speaking programmers were co-authoring the documentation without an editor and/or sufficient coordination … :exclamation: :wink: