While the ability to monitor your network traffic is critical, the process is different on a switch than on a router. In this edition of Cisco Routers and Switches, David Davis tells you how you can monitor traffic on your switch ports using SPAN and RSPAN.
The ability to monitor your network traffic is critical. If you really need to get down to the packet level, using a protocol analyzer is your best bet.
I've heard from a number of TechRepublic members who have questions about using a protocol analyzer (i.e., sniffer), such as Ethereal, to decode, monitor, and understand their network traffic. To do so, they want to connect their monitoring station to a switch and view all data going across that switch or across the network.
If you're using a hub, this works fine. However, most of us don't use hubs anymore; instead, we use switches. And trying to monitor all network traffic with a switch won't work.
When using a protocol analyzer such as Ethereal, you typically want to see as much network traffic as you can get your hands on. From there, you can filter it to exactly what you want. But if you try to run a protocol analyzer on a computer connected to a switch, all you'll see is traffic to and from your computer, as well as broadcasts on your network.
Why is this the case? Each port on a switch is a private network segment. This is much different from a hub. A hub really works as a multi-port repeater, sending out any traffic that comes into one port to all other ports. And in the process, all devices on the hub share the same bandwidth.
But with a switch, each port has its own private bandwidth—it doesn't have to share it with the other ports/devices. The switch keeps a table of all ports and all Ethernet MAC addresses on those ports.
So that means that the switch will send you network traffic destined for your workstation. Unlike a router, it will also send you broadcast traffic meant for all devices on the LAN.
How do you copy all traffic on a switch to your network protocol analyzer? To get the job done and allow your network protocol analyzer to see all the traffic, you need a Cisco switch feature called Switched Port Analyzer (SPAN) or Remote SPAN (RSPAN). Other vendors call this feature port mirroring.
Here's how SPAN works: It takes all traffic from a single switch port, multiple switch ports, or an entire VLAN, and it copies that traffic to the destination port. In addition to specifying the source and destination ports, you can also indicate whether you want all sent traffic, received traffic, or both sent and received traffic to go to the destination port.
RSPAN enables you to send traffic sourced from multiple switches across the network to your destination port. For example, let's say VLAN 20 spreads across five switches in multiple areas on the LAN. With RSPAN, you can determine that all traffic destined for VLAN 20—from any of these five switches—goes to your destination switch port. Once there, the network protocol analyzer can examine the traffic.
Configuring SPAN is pretty simple. Keep in mind that there are a number of &quot;rules&quot; for source and destination ports. You also need to understand how SPAN works with other protocols, such as STP, VTP, and CDP. I recommend reading the Cisco IOS documentation listed below before you begin.
Here's an example for configuring SPAN. Let's say we want to mirror all traffic going to and from the first 23 Ethernet ports on a 24-port switch. Then we want to send copies of all that traffic to port 24 for protocol analysis. Here's what we would do:
Switch(config)# monitor session 1 source interface FastEthernet 0/1 - 23 both Switch(config)# monitor session 1 destination interface FastEthernet0/24
Keep in mind that port mirroring a lot of traffic can be very performance intensive to the switch. Make sure you disable all monitoring when you're finished. Here's an example:
Switch(config)# no monitor session 1
You can use the show monitor command to check the status of monitoring. Here's an example:
Switch# show monitor
Just about everyone uses switching today. That's why it's important that you know how to perform port mirroring by enabling SPAN on Cisco switches so you can monitor traffic.
For more information on Ethereal, check out these TechRepublic articles:
- &quot;How do I… Monitor traffic on a network for free with Ethereal&quot;
- &quot;Packet sniffing with Ethereal&quot;
- &quot;Ethereal is a serious, simple, and free protocol analyzer&quot;
Have you used SPAN, RSPAN, or port mirroring? Share your experiences in this article's discussion.
Miss a column?
Check out the Cisco Routers and Switches Archive, and catch up on David Davis' most recent columns.
Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.