Hi, as we know sometimes we need to capture the packets to help us to locate the network problem, in which situation, the port mirroring could help us to capture the packets conveniently.
In this post, we'll introduce the port mirroring detailly.
1. Overview of Port Mirroring
![]()
In some scenarios, we need to monitor incoming or outgoing packets on a
specific port of a switch or analyze specific traffic. For example, in the
preceding figure, GE0/0/24 on the switch carries a large amount of traffic, and
incoming and outgoing packets on this interface need to be analyzed to locate
network faults. We can connect a PC to GE0/0/5 on the switch, install a protocol
analysis software on the PC, and deploy port mirroring to mirror the incoming
and outgoing packets on GE0/0/24 to GE0/0/5. Then we can check the packets
through the protocol analysis software on the PC.
Port mirroring copies traffic on a specific port to a monitoring port. Without
the port mirroring technology, the packets can be sent to the monitoring PC
only when the destination of these packets is the port connected to the PC.
Port mirroring is typically used for traffic measurement, traffic statistics
collection, and fault locating.
Mirroring Types
· Port mirroring
The port mirroring function copies data on a mirrored port to an observing port for analysis and monitoring.
· Traffic mirroring
The traffic mirroring function copies service flows matching ACL rules to an observing port for analysis and monitoring.
2. Port Mirroring
In port mirroring, a switch copies incoming or outgoing packets passing through
a mirrored port and sends the packets to a specified observing port for
analysis and monitoring. During port mirroring, all the packets passing through
a mirrored port are copied to an observing port. Ethernet switches support N:1
mirroring. That is, packets on multiple ports are copied to one monitoring
port.
Port mirroring is
classified into local port mirroring and remote port mirroring.
· Local port mirroring
In local port mirroring, a monitoring host is directly connected to an
observing port.
· Remote port mirroring
In remote port mirroring, a monitoring host and an observing port are connected
through a Layer 2 or Layer 3 network.
Layer 2 port mirroring (RSPAN: remote switched port analyzer): When a
monitoring host and an observing port are connected through a Layer 2 network,
the S9300 adds a VLAN ID to packets passing through a mirrored port, and
broadcasts the packets in the remote mirroring VLAN through an observing port.
After receiving the packets, the remote device compares the VLAN ID in the
packets with the local VLAN ID configured for remote mirroring. If the VLAN IDs
are the same, the remote device forwards the packets to the remote observing
port.
Layer 3 port mirroring (ERSPAN: encapsulated remote SPAN): When a monitoring
host and an observing port are connected through a Layer 3 network, the S9300
encapsulates the mirrored packets into GRE packets or decapsulates the packets
so that the mirrored packets can traverse the Layer 3 network. In this way, the
device where the mirrored port resides and the device where the observing port
resides implement port mirroring through the Layer 3 network.
3. Traffic Mirroring
![]()
The traffic mirroring function copies specified flows passing through a
mirrored port to an observing port or the CPU for analysis and monitoring. A
traffic policy containing the traffic mirroring behavior is applied to the
mirrored port. Packets matching the traffic classifier in the traffic policy on
the mirrored port are copied and then sent to the observing port or the CPU.
Traffic can be mirrored to a port or the CPU.
Traffic mirrored to a port: Packets meeting requirements on a port enabled with
traffic mirroring are copied and then sent to an observing port for analysis
and diagnosis.
Traffic mirrored to the CPU: Packets meeting requirements on a port enabled
with traffic mirroring are copied and then sent to the CPU for analysis and
diagnosis. Here, the CPU refers to the CPU of the LPU where traffic mirroring
is enabled.
4. Configuring Local Port Mirroring
![]()
Mirror the incoming and outgoing packets on GE0/0/24 of the switch to GE0/05.
The switch configuration is as follows:
[SW] observe-port 1 interface gigabitethernet0/0/5
[SW] interface gigabitethernet0/0/24
[SW-gigabitethernet0/0/24] port-mirroring to observe-port 1 both
5. Packet Analysis
![]()
l Traffic of various types is transmitted on an IP network.
l Proper running
of protocols or services depends on normal exchange of packets. As shown in the
preceding figure, SW1 and SW2 run OSPF. The two switches exchange OSPF packets
constantly so that OSPF can work normally. If a user logs in to SW2 from SW1
through Telnet, related packets are exchanged between them.
6. Packet Analysis Tools
Common
packet analysis tools include Ethereal, Wireshark, and Sniffer.
The following figure shows the Wireshark user interface (UI). After the
software is installed, start it and select the network interface card (NIC) to
listen on. Then packets on the NIC are obtained. The obtained packets are shown
in the following figure.
![]()
Quiz:
![]()
Configure IP addresses of the PC and switch, as shown in the preceding figure.
Enable the Telnet service on the switch.
Start Wireshark on the PC and configure Wireshark to listen on the Ethernet NIC
of the switch.
Telnet the switch from the PC and check the obtained packets. Telnet packets
are transmitted in plaintext. Therefore, the user name and password for Telnet
login and operations performed on the switch are obtained. Therefore, the
Telnet protocol is not secure.
Reminder: Wireshark is a non-standard software. Unauthorized installation of
Wireshark is a violation of information security regulations. Therefore, to
install and use Wireshark, follow the related process or use it on your PC.
That's all for this post, hope you enjoy this.
If you have any suggestions or features want to learn, describe it.
If you are looking for other information, you can visit our support website( click here ) or KB( click here ).
