USING TRACEROUTE TO FIND L2 PATH
The Layer 2 traceroute utility (l2trace) is an extremely useful utility that is supported on the following Cisco Catalyst switch platforms:
- Catalyst 2950/3550 switches running Cisco IOS 12.1(12c)EA1 or higher
- Catalyst 4000/4500 switches running CatOS 6.2 or higher
- Catalyst 5000/5500 switches running CatOS 6.1 or higher
- Catalyst 6000/6500 switches running CatOS 6.1 or higher
The l2trace utility is similar in functionality to the IP traceroute utility; instead of indicating the router hops in the path to a destination IP address, the l2trace utility indicates the switch hops in the path to a destination MAC address within a Layer 2 network. This is very useful if you want to verify that traffic is flowing over the correct paths in a complex switched network and is most commonly used to verify spanning-tree topologies are being generated as planned. The only limitations of the l2trace utility are that all switches in the l2trace path must support the utility, CDP must be enabled on all switches, and it is supported only between devices in the same VLAN.
A useful feature of the Layer 2 traceroute is that you don’t have to execute the command from the switch that is connected to the source specified in the trace. For example in Figure 10-4, you can execute a Layer 2 traceroute between Host-A and Host-B from any switch in the network, not just Switch-B.
If you use the traceroute mac ip command, you need to specify only the source IP address and destination IP address for the traffic flow between the hosts that you want to trace. Because a Layer 2 traceroute works only for paths within a Layer 2 network (i.e., VLAN), you must ensure the source and destination IP address represent hosts within the same IP subnet/VLAN. The switch executing the trace consults its local ARP cache to determine the MAC addresses of the source and destination. If no Address Resolution Protocol (ARP) entries are cached, then the switch issues ARP requests for each IP address and begins the trace once the required source and destination MAC address information is known
On Cisco IOS, the same traceroute command used to perform Layer 3 traceroutes is also used to perform Layer 2 traceroutes when configured with the following syntax:
Switch# traceroute mac [interface interface-type interface-id] source-mac [interface interface-type interface-id] destination-mac [vlan vlan-id] [detail]
Switch# traceroute mac ip source-ip destination-ip [detail]
Switch-B# traceroute mac ip 192.168.1.101 192.168.1.100 detail
Translating IP to mac …..
192.168.1.101 => 0001.0200.d81d
192.168.1.100 => 00a0.d1d0.20b9
Source not directly connected, tracing source …..
Source 0001.0200.d81d found on Switch-C[WS-C3550-24] (192.168.1.3)
Switch-C / WS-C3550-24 / 192.168.1.3 :
Fa0/3 [auto, auto] => Fa0/1 [full, 100M]
Switch-A / WS-C4006 / 192.168.1.1 :
2/2 [full, 100M] => 2/1 [full, 100M]
Switch-B / WS-C3550-24 / 192.168.1.2 :
Fa0/1 [full, 100M] => Fa0/3 [auto, auto]
Destination 00a0.d1d0.20b9 found on Switch-B[WS-C3550-24] (192.168.1.2)
Layer 2 trace completed.
the switch first determines the MAC addresses associated with the specified IP addresses.
Once these MAC addresses are known, notice that because the specified source (192.168.1.101 or Host-B)
is not directly connected to Switch-B, Switch-B traces the switch to which Host-B is connected.
This is found to be Switch-C, and the Layer 2 traceroute begins.