Port mirroring is the ability of a router to send a copy of an IPv4 or IPv6 packet to an external host address or a packet analyzer for analysis. Port mirroring is different from traffic sampling. In traffic sampling, a sampling key based on the packet header is sent to the Routing Engine. There, the key can be placed in a file, or cflowd packets based on the key can be sent to a cflowd server. In port mirroring, the entire packet is copied and sent out through a next-hop interface.
One application for port mirroring sends a duplicate packet to a virtual tunnel. A next-hop group can then be configured to forward copies of this duplicate packet to several interfaces. For more information about next-hop groups, see Configuring Next-Hop Groups.
All M Series Multiservice Edge Routers, T Series Core Routers, and MX Series 3D Universal Edge Routers support port mirroring for IPv4 or IPv6. The M120, M320, and MX Series routers support port mirroring for IPv4 and IPv6 simultaneously.
Port mirroring for VPLS traffic is supported on M7i and M10i routers configured with an Enhanced CFEB (CFEB-E), on M120 routers, on M320 routers configured with an Enhanced III Flexible PIC Concentrators (FPCs), and MX Series routers.
In Junos OS Release 9.3 and later, port mirroring is supported
for Layer 2 traffic on MX Series routers. For information
about how to configure port mirroring for Layer 2 traffic, see
the Junos OS Layer 2 Configuration Guide
.
In Junos OS Release 9.6 and later, port mirroring is supported for Layer 2 VPN traffic on M120 routers and M320 routers configured with an Enhanced III FPC. You can also set the maximum length of the mirrored packet. When set, the mirrored packet is truncated to the specified length.
When configuring port mirroring, the following restrictions apply:
By default, firewall filters cannot be applied to port-mirroring destination interfaces. To enable port-mirroring destination interfaces to support firewall filters, use the no-filter-check statement to disable filter checking on the interfaces. You can include the no-filter-check statement at the following hierarchy levels:
To configure port mirroring, include the port-mirroring statement at the [edit forwarding-options] hierarchy level:
To configure port mirroring, include the port-mirroring statement. To configure the address family type of traffic to sample, include the family statement. To configure the rate of sampling, length of sampling, and the maximum size for the mirrored packet, include the input statement. To specify on which interface to send duplicate packets and the next-hop address to send packets, include the output statement. To determine whether there are any filters on the specified interface, include the no-filter-check statement.
For information about the rate and run-length statements, see Configuring Traffic Sampling.
In Junos OS Release 9.5 and later, you can configure multiple
port-mirroring instances on the M120, M320, and MX Series routers.
On the M120 router, you can associate each instance with a specific
Forwarding Engine Board (FEB). You cannot associate a port-mirroring
instance with an FEB configured as a backup FEB. On the M320 router,
you can associate each instance with a specific Flexible PIC Concentrator
(FPC). Associating a port-mirroring instance with an FPC or an FEB
enables you to mirror packets to different destinations. Multiple
port-mirroring instances are also supported on MX Series routers.
For information about configuring multiple port-mirroring instances
on MX Series routers, see the Junos OS Layer 2 Configuration Guide
.
To configure a port-mirroring instance, include the instance port-mirroring-instance statement at the [edit forwarding-options port-mirroring] hierarchy level:
You can configure multiple port-mirroring instances. Specify a unique port-mirroring-instance-name for each instance you configure.
You can associate a port-mirroring instance with a specific FPC on an M320 router or with a specific FEB on an M120 router. You can associate only one port-mirroring instance with each FPC on an M320 router or with each FEB on an M120 router. On an M120 router, you cannot associate a port-mirroring instance with a FEB configured as a backup FEB.
To associate a port-mirroring instance with an FPC on an M320 router, include the port-mirror-instance port-mirroring-instance-name statement at the [edit chassis fpc slot-number] hierarchy level:
For slot-number, specify the slot
number of the FPC you want to associate with the port-mirroring instance.
For port-mirroring-instance-name, specify
the name of a port-mirroring instance you configured at the [edit
forwarding-options port-mirroring] hierarchy level. For more
information about configuring an FPC on an M320 router, see the Junos OS System Basics Configuration Guide
.
To associate a port-mirroring instance with a FEB on an M120 router, include the port-mirror-instance port-mirroring-instance-name statement at the [edit chassis feb slot-number] hierarchy level:
For slot-number, specify the slot
number of the FEB you want to associate with the port-mirroring instance.
For port-mirroring-instance-name, specify
the name of a port-mirroring instance you configured at the [edit
forwarding-options port-mirroring] hierarchy level. For information
about configuring FEB redundancy on an M120 router, see the Junos OS High Availability Configuration Guide
.
For information about configuring FPC-to-FEB connectivity on an M120
router, see the Junos OS System Basics Configuration Guide
.
On MX Series and M120 routers only, you can configure port mirroring so that the router mirrors traffic only once. If you configure port mirroring on both ingress and egress interfaces, the same packet could be mirrored twice. To mirror packets only once and prevent the router from sending duplicate sampled packets to the same mirroring destination, include the mirror-once statement at the [edit forwarding-options port-mirroring] hierarchy level:
![]() | Note: The mirror-once statement is supported only in the global port-mirroring instance. |