Showing posts with label Switching. Show all posts
Showing posts with label Switching. Show all posts

Wednesday, February 19, 2020

Cisco IOS SPAN and RSPAN

Cisco Catalyst Switches have a feature called SPAN (Switch Port Analyzer) that lets you copy all traffic from a source port or source VLAN to a destination interface. This is very useful for a number of reasons:
  • If you want to use wireshark to capture traffic from an interface that is connected to a workstation, server, phone or anything else you want to sniff.
  • Redirect all traffic from a VLAN to an IDS / IPS.
  • Redirect all VoIP calls from a VLAN so you can record the calls.
The source can be an interface or a VLAN, the destination is an interface. You can choose if you want to forward transmitted, received or both directions to the destination interface.
Cisco SPAN Example
When you use a destination interface on the same switch as your switch we call it SPAN, when the destination is a remote interface on another switch we call it RSPAN (Remote SPAN).  When using RSPAN you need to use a VLAN for your RSPAN traffic so that traffic can travel from the source switch to the destination switch.
cisco switch rspan example
When you use RSPAN you need to use a VLAN that carries the traffic that you are copying. In the picture above you see SW1 which will copy the traffic from the computer onto a “RSPAN VLAN”. SW2 doesn’t do anything with it while SW3 receives the traffic and forwards it to a computer that has wireshark running. Make sure the trunks between the switches allow the RSPAN VLAN.
SPAN and RSPAN are great but there are a couple of things you need to keep in mind…

Restrictions

Both SPAN and RSPAN have some restrictions, I’ll give you an overview of the most important ones:
  • The source interface can be anything…switchport, routed port, access port, trunk port, etherchannel, etc.
  • When you configure a trunk as the source interface it will copy traffic from all VLANs, however there is an option to filter this.
  • You can use multiple source interfaces or multiple VLANs, but you can’t mix interfaces and VLANs.
  • It’s very simple to overload an interface. When you select an entire VLAN as the source and use a 100Mbit destination interface…it might be too much.
  • When you configure a destination port you will “lose” its configuration. By default, the destination interface will only be used to forward SPAN traffic to. However, it can be configured to permit incoming traffic from a device that is connected to the destination interface.
  • Layer 2 frames like CDP, VTP, DTP and spanning-tree BPDUs are not copied by default but you can tell SPAN/RSPAN to copy them anyway.
This should give you an idea of what SPAN / RSPAN are capable of. The configuration is pretty straight-forward so let me give you some examples…

SPAN Configuration

Let’s start with a simple configuration. I will use the example I showed you earlier:
Cisco SPAN Example
Switch(config)#monitor session 1 source interface fa0/1
Switch(config)#monitor session 1 destination interface fa0/2
You can verify the configuration like this:
Switch#show monitor session 1
Session 1
---------
Type                   : Local Session
Source Ports           :
    Both               : Fa0/1
Destination Ports      : Fa0/2
    Encapsulation      : Native
          Ingress      : Disabled
As you can see, by default it will copy traffic that is transmitted and received (both) to the destination port. If you only want the capture the traffic going in one direction you have to specify it like this:
Switch(config)#monitor session 1 source interface fa0/1 ?
  ,     Specify another range of interfaces
  -     Specify a range of interfaces
  both  Monitor received and transmitted traffic
  rx    Monitor received traffic only
  tx    Monitor transmitted traffic only
Just add rx or tx and you are ready to go. If interface FastEthernet 0/1 were a trunk you could add a filter to select the VLANs you want to forward:
Switch(config)#monitor session 1 filter vlan 1 - 100
This filter above will only forward VLAN 1 – 100 to the destination. If you don’t want to use an interface as the source but a VLAN, you can do it like this:
Switch(config)#monitor session 2 source vlan 1
Switch(config)#monitor session 2 destination interface fa0/3
I am unable to use session 1 for this because I am already using source interfaces for that session. It’s also impossible to use the same destination interface for another session. This is why I created another session number and picked FastEthernet 0/3 as a destination.
hostname Switch
!
monitor session 1 source interface Fa0/1
monitor session 1 destination interface Fa0/2
monitor session 2 source vlan 1
monitor session 2 destination interface Fa0/3
end
So far so good? Let’s look at RSPAN!

RSPAN Configuration

To demonstrate RSPAN I will use a topology with two switches:
cisco rspan sw1 sw2
The idea is to forward traffic from FastEthernet 0/1 on SW1 to FastEthernet 0/1 on SW2. There are a couple of things we have to configure here:
SW1(config)#vlan 100
SW1(config-vlan)#remote-span
SW2(config)#vlan 100
SW2(config-vlan)#remote-span
First we need to create the VLAN and tell the switches that it’s a RSPAN vlan. This is something that is easily forgotten. Secondly we will configure the link between the two switches as a trunk:
SW1(config)#interface fastEthernet 0/24
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport mode trunk
SW2(config)#interface fastEthernet 0/24
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#switchport mode trunk
Now we can configure RSPAN:
SW1(config)#monitor session 1 source interface fastEthernet 0/1
SW1(config)#monitor session 1 destination remote vlan 100
This selects FastEthernet 0/1 as the source and VLAN 100 as the destination…
SW2(config)#monitor session 1 source remote vlan 100
SW2(config)#monitor session 1 destination interface fastEthernet 0/1
And on SW2, we select VLAN 100 as the source and FastEthernet 0/1 as its destination. Here’s the output of the show monitor session command:
SW1#show monitor session 1
Session 1
---------
Type                   : Remote Source Session
Source Ports           :
    Both               : Fa0/1
Dest RSPAN VLAN        : 100
SW2#show monitor session 1
Session 1
---------
Type                   : Remote Destination Session
Source RSPAN VLAN      : 100
Destination Ports      : Fa0/1
    Encapsulation      : Native
          Ingress      : Disabled
That’s all there is to it.
hostname SW1
!
vlan 100
 remote-span
!
interface FastEthernet0/24
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
monitor session 1 source interface Fa0/1
monitor session 1 destination remote vlan 100
end
hostname SW2
!
vlan 100
 remote-span
!
interface FastEthernet0/24
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
monitor session 1 source remote vlan 100
monitor session 1 destination interface fastEthernet 0/1
end
I hope these examples have been helpful to you!

Layer 3 Etherchannel on Cisco IOS Switch

In a previous tutorial I explained how Etherchannels work and how to configure them, but I didn’t write about layer 3 Etherchannels before. In this tutorial, I’ll show you how to configure them.
A layer 3 etherchannel is similar to an interface on a router. The switch won’t “switch” traffic on this interface but route it. Because it’s a layer 3 interface, we configure an IP address on it.
I’ll be using two switches for this:
Etherchannel L3 Addresses
Before we configure the port channel settings you need to make sure that all interfaces have the exact same configuration. Once you use the channel-group command, the port-channel interface will automatically inherit all settings from your physical interface. If you forget to run the no switchport command on an interface, your etherchannel will be layer 2 instead of layer 3!
Having said that, let’s configure our switches:
SW1(config)#interface range fastEthernet 0/1 - 2
SW1(config-if-range)#no switchport
SW1(config-if-range)#channel-group 12 mode on
Creating a port-channel interface Port-channel 12
SW2(config)#interface range fa0/1 - 2
SW2(config-if-range)#no switchport
SW2(config-if-range)#channel-group 12 mode on
Creating a port-channel interface Port-channel 12
This creates our Etherchannel, we can verify our work like this:
SW1#show etherchannel 12 summary 
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator

        M - not in use, minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port

Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
12     Po12(RU)         -        Fa0/1(P)   Fa0/2(P)
Above you can see that our port-channel 12 interface is layer 3 and it’s operational. Just like any other layer 3 interface we can configure an IP address on this port-channel interface:
SW1(config)#interface port-channel 12
SW1(config-if)#ip address 192.168.12.1 255.255.255.0
SW2(config)#interface port-channel 12
SW2(config-if)#ip address 192.168.12.2 255.255.255.0
Let’s see if that works:
SW1#ping 192.168.12.2       

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms
No problem at all! If you enabled ip routing on your switch you will see that the switch uses the port-channel interface in its routing table:
SW1#show ip route connected 
C    192.168.12.0/24 is directly connected, Port-channel12
That’s all there is to it, I hope this tutorial has been useful to you!

Etherchannel on Cisco IOS Catalyst Switch

In this tutorial we‟ll take a look at etherchannel which is also known as link aggregation. Etherchannel is a technology that lets you bundle multiple physical links into a single logical link. We”ll take a look at how it works and what the advantages of etherchannel are. Let’s start with an example of a small network:
sw1 sw2 two hosts gigabit fastethernet
Take a look at the picture above. I have two switches and two computers connected to the switches. The computers are connected with 1000 Mbit interfaces while the link between the
switches is only 100 Mbit. If one of the computers would send traffic that exceeds 100 Mbit of bandwidth we”ll have congestion and traffic will be dropped.
There are two solutions to this problem:
  • Replace the link in between the switches with something that has a higher bandwidth, perhaps a gigabit or 10gigabit link.
  • Add multiple links and bundle them into an etherchannel.
Since this tutorial is about Etherchannel, we’ll take a look at adding multiple links. Here’s an example:

sw1 sw2 two hosts 4 fastethernet links
In the picture above I have added a couple of extra links. The problem with this setup is that we have a loop so spanning tree would block 3 out of 4 links. Etherchannel solves this problem because it will create a single virtual link out of these physical links:
sw1 sw2 two hosts etherchannel 400 mbit
By combining 4x 100 Mbit I now have a 400 Mbit link. Spanning tree sees this link as one logical link so there are no loops! Etherchannel will do load balancing among the different links that we have and it takes care of redundancy. Once one of the links fails it will keep working and use the links that we have left.
There’s a maximum to the number of links you can use: 8 physical interfaces.
If you want to configure an Etherchannel there are two protocols you can choose from:
  • PAgP (Cisco proprietary)
  • LACP (IEEE standard)
These protocols can dynamically configure an etherchannel. It‟s also possible to configure a static etherchannel without these protocols doing the negotiation of the link for you. If you are going to create an etherchannel you need to make sure that all ports have the same configuration:
  • Duplex has to be the same.
  • Speed has to be there same.
  • Same native AND allowed VLANs.
  • Same switchport mode (access or trunk).
PAgp and LACP will check if the configuration of the interfaces that you use are the same.
If you want to configure PAgP there are a number of options you can choose from, the interface can be configured as:
  • On (interface becomes member of the etherchannel but does not negotiate).
  • Desirable (interface will actively ask the other side to become an etherchannel).
  • Auto (interface will wait passively for the other side to ask to become an etherchannel).
  • Off (no etherchannel configured on the interface).
Let me show you an example how to configure PAgP between two switches. I’ll use SW1 and SW2 for this demonstration:
    sw1 sw2 fa013 fa014
SW1 and SW2 each have a FastEthernet 0/13 and 0/14 interface. We’ll bundle these into a single logical link.
SW1(config)#interface fa0/13
SW1(config-if)#channel-group 1 mode ?
  active     Enable LACP unconditionally
  auto       Enable PAgP only if a PAgP device is detected
  desirable  Enable PAgP unconditionally
  on         Enable Etherchannel only
  passive    Enable LACP only if a LACP device is detected
First we go to the interface level where we can create a channel-group. I’m going to use channel-group number 1. Above you can see the different options that we have for PAgP and LACP.
SW1(config)#interface fa0/13
SW1(config-if)#channel-group 1 mode desirable 
Creating a port-channel interface Port-channel 1
SW1(config)#interface fa0/14
SW1(config-if)#channel-group 1 mode desirable
I configure SW1 for PAgP desirable mode. It will actively ask SW2 to become an Etherchannel this way.
SW2(config)#interface fa0/13
SW2(config-if)#channel-group 1 mode auto 
SW2(config)#interface fa0/14
SW2(config-if)#channel-group 1 mode auto
Here’s the configuration of SW2. I used the PAgP auto mode so it will respond to requests to become an etherchannel.
SW1 %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
SW2 %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
You’ll see a message on your switches like mine above. The switch will create a port-
channel interface.
SW1(config)#interface port-channel 1
SW1(config-if)#switchport trunk encapsulation dot1q 
SW1(config-if)#switchport mode trunk
SW2(config)#interface port-channel 1
SW2(config-if)#switchport trunk encapsulation dot1q 
SW2(config-if)#switchport mode trunk
The port-channel interface can be configured. I’ve set mine to use 802.1Q encapsulation and to become a trunk.
SW1#show etherchannel 1 port-channel 
  Port-channels in the group: 
  ---------------------------

Port-channel: Po1
------------

Age of the Port-channel   = 0d:00h:10m:16s
Logical slot/port   = 2/1          Number of ports = 2
GC                  = 0x00010001      HotStandBy port = null
Port state          = Port-channel Ag-Inuse 
Protocol            =   PAgP
Port security       = Disabled

Ports in the Port-channel: 

Index   Load   Port     EC state        No of bits
------+------+------+------------------+-----------
  0     00     Fa0/13   Desirable-Sl       0
  0     00     Fa0/14   Desirable-Sl       0

Time since last port bundled:    0d:00h:00m:07s    Fa0/14
Time since last port Un-bundled: 0d:00h:04m:08s    Fa0/13
Here’s one way to verify your configuration. Use the show etherchannel port-channel command to check if the port-channel is active or not. You can also see that we are using PAgP. Interface fa0/13 and fa0/14 are both in use for this etherchannel.
SW1#show etherchannel summary 
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator

        M - not in use, minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port

Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)         PAgP      Fa0/13(P)   Fa0/14(P)
If you have many etherchannels you can also use the show etherchannel summary command. It will give you a quick overview of all the etherchannels and the interfaces that are in use.
SW1#show interfaces fa0/14 etherchannel 
Port state    = Up Mstr In-Bndl 
Channel group = 1           Mode = Desirable-Sl    Gcchange = 0
Port-channel  = Po1         GC   = 0x00010001      Pseudo port-channel = Po1
Port index    = 0           Load = 0x00            Protocol =   PAgP

Flags:  S - Device is sending Slow hello.  C - Device is in Consistent state.
        A - Device is in Auto mode.        P - Device learns on physical port.
        d - PAgP is down.
Timers: H - Hello timer is running.        Q - Quit timer is running.
        S - Switching timer is running.    I - Interface timer is running.

Local information:
                                Hello    Partner  PAgP     Learning  Group
Port      Flags State   Timers  Interval Count   Priority   Method  Ifindex
Fa0/14    SC U6/S7   H 30s  1        128        Any      5001

Partner's information:

          Partner              Partner          Partner         Partner Group
Port      Name                 Device ID        Port       Age  Flags   Cap.
Fa0/14    SW2              0019.569d.5700 Fa0/14      19s SAC 10001 

Age of the port in the current state: 0d:00h:02m:37s
The third method to verify your etherchannel is to use the show interfaces etherchannel command. In my example I am looking at the information of my fa0/14 interface. Besides information of our local switch you can also see the interface of our neighbor switch (SW2 in my example).
The last thing I want to share with you about PAgP are the different modes you can choose from:
  • On
  • Desirable
  • Auto
  • Off
I have configured SW1 to use desirable and SW2 to use auto mode. Not all the different combinations work:
OnDesirableAutoOff
OnYesNoNoNo
DesirableNoYesYesNo
AutoNoYesNoNo
OffNoNoNoNo
Here’s an overview with all the different options. Keep in mind that configuring your etherchannel as “on” doesn’t use any negotiation so it will fail if the other side is configured for auto or desirable.
hostname SW1
!
interface FastEthernet0/13
 channel-group 1 mode desirable 
!
interface FastEthernet0/14
 channel-group 1 mode desirable 
!
interface port-channel 1
 switchport trunk encapsulation dot1q 
 switchport mode trunk
!
end
hostname SW2
!
interface FastEthernet0/13
 channel-group 1 mode auto 
!
interface FastEthernet0/14
 channel-group 1 mode auto
!
interface port-channel 1
 switchport trunk encapsulation dot1q 
 switchport mode trunk
!
end
LACP is similar to PAgP. You also have different options to choose from when you configure the interface:
  • On (interfaces becomes member of the etherchannel but does not negotiate).
  • Active (interface will actively ask the other side to become an etherchannel).
  • Passive (interface will wait passively for the other side to ask to become an etherchannel).
  • Off (no etherchannel configured on the interface).
It’s basically the same thing as PAgP but the terminology is different. Let’s configure LACP to see what it does.
SW1(config)#default interface fa0/13
Interface FastEthernet0/13 set to default configuration
SW1(config)#default interface fa0/14
Interface FastEthernet0/14 set to default configuration
SW2(config)#default interface fa0/13
Interface FastEthernet0/13 set to default configuration
SW2(config)#default interface fa0/14
Interface FastEthernet0/14 set to default configuration
SW1(config)#no interface port-channel1
SW2(config)#no interface port-channel1
Don’t forget to clean up PAgP before you start playing with LACP.
SW1(config-if)#interface fa0/13
SW1(config-if)#channel-group 1 mode active 
Creating a port-channel interface Port-channel 1
SW1(config-if)#interface f0/14
SW1(config-if)#channel-group 1 mode active
I’ll configure SW1 to use LACP active mode.
SW2(config)#interface fa0/13
SW2(config-if)#channel-group 1 mode passive 
Creating a port-channel interface Port-channel 1
SW2(config-if)#interface fa0/14
SW2(config-if)#channel-group 1 mode passive
SW2 will use LACP passive mode.
SW1#show  etherchannel 1 port-channel 
  Port-channels in the group: 
  ---------------------------

Port-channel: Po1    (Primary Aggregator)

------------

Age of the Port-channel   = 0d:00h:03m:04s
Logical slot/port   = 2/1          Number of ports = 2
HotStandBy port = null 
Port state          = Port-channel Ag-Inuse 
Protocol            =   LACP
Port security       = Disabled

Ports in the Port-channel: 

Index   Load   Port     EC state        No of bits
------+------+------+------------------+-----------
  0     00     Fa0/13   Active             0
  0     00     Fa0/14   Active             0

Time since last port bundled:    0d:00h:00m:54s    Fa0/14
We can use the show etherchannel port-channel command again to verify our configuration again. As you can see the protocol is now LACP and interfaces fa0/13 and fa0/14 are active.
The configuration of PAgP and LACP is similar. Keep in mind that PAgP can only be used between Cisco devices while LACP is a IEEE standard, you can use it to form etherchannels with devices from other vendors.
OnActivePassiveOff
OnYesNoNoNo
ActiveNoYesYesNo
PassiveNoYesNoNo
OffNoNoNoNo
Here’s an overview with the different modes and combinations for LACP. It’s similar to PAgP but now we have the active and passive mode.
Last thing I want to show you about etherchannel is load-balancing:
SW1#show etherchannel load-balance 
EtherChannel Load-Balancing Configuration:
        src-mac

EtherChannel Load-Balancing Addresses Used Per-Protocol:
Non-IP: Source MAC address
  IPv4: Source MAC address
  IPv6: Source MAC address
Use the show etherchannel load-balance command to see what the default configuration is. As you can see our etherchannel load-balances based on the source MAC address.
SW1(config)#port-channel load-balance ?
  dst-ip       Dst IP Addr
  dst-mac      Dst Mac Addr
  src-dst-ip   Src XOR Dst IP Addr
  src-dst-mac  Src XOR Dst Mac Addr
  src-ip       Src IP Addr
  src-mac      Src Mac Addr
You can use the global port-channel load-balance command to change this behavior. You can see you can choose between source/destination MAC/IP address or a combination of source/destination.
Why should you care about load balancing? Take a look at the picture below:
cisco etherchannel load balance scenario
On the left side, we have SW1 and four computers. On the right side, we have SW2 and a router. The default load-balancing mechanism is source MAC address. This means that ALL traffic from one MAC address will be sent down one and the same physical interface, for example:
  • MAC address AAA will be sent using SW1’s fa0/13 interface.
  • MAC address BBB will be sent using SW1’s fa0/14 interface.
  • MAC address CCC will be sent using SW1’s fa0/13 interface.
  • MAC address DDD will be sent using SW1’s fa0/14 interface.
Since we have multiple computers this is fine, both physical links on SW1 will be used for our etherchannel so depending on how much traffic the computers send it will be close to a 1:1 ratio.
It’s a different story for SW2 since we only have one router with MAC address EEE. It will pick one of the physical interfaces so ALL traffic from the router will be sent down interface fa0/13 OR fa0/14. One of the physical links won’t be used at all…
SW2(config)#port-channel load-balance dst-mac
If this is the case it’s better to change the load balancing mechanism. If we switch it to destination MAC address on SW2 traffic from our router to the computer will be load-balanced amongst the different physical interfaces because we have multiple computers with different destination MAC addresses.
hostname SW1
!
interface FastEthernet0/13
 channel-group 1 mode active 
!
interface FastEthernet0/14
 channel-group 1 mode active
!
interface port-channel 1
 switchport trunk encapsulation dot1q 
 switchport mode trunk
!
end
hostname SW2
!
interface FastEthernet0/13
 channel-group 1 mode passive
!
interface FastEthernet0/14
 channel-group 1 mode passive
!
interface port-channel 1
 switchport trunk encapsulation dot1q 
 switchport mode trunk
!
port-channel load-balance dst-mac
!
end

That’s all I have on Etherchannels for now, hopefully this has been helpful to you! If you have any questions feel free to leave a comment.