1

I had a managed or layer 3 supported switch (it can process both layer 2 and layer 3 packets). Now a packet from a connected host comes to it, sending traffic. How does the switch decide to process it as layer 2 or layer 3?

3
  • we can close this question, query has been answered, not sure how to close, hence adding a comment
    – ka re
    Nov 4, 2020 at 16:34
  • You need to accept one of the answers below to close the question. Voting for useful questions is also appreciated.
    – Zac67
    Nov 7, 2020 at 9:39
  • Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could post and accept your own answer.
    – Ron Maupin
    Dec 31, 2020 at 3:50

2 Answers 2

1

Understand that a layer-3 switch is primarily a layer-2 switch, but it has a routing module built into it. Since you did not specify a model or vendor, I will give you a generic Cisco example.

A Cisco layer-3 switch will default to all switch interfaces as layer-2 interfaces. That is, with the switchport interface command as the default for all switch interfaces, and without the global ip routing command enabled.

To use the Cisco switch as a layer-3 switch, you need to configure the global ip routing (or, for IPv6, the global ipv6 unicast routing), command. Then, you can configure some physical interfaces with the no switchport and ip address <address> <mask> (ipv6 address <address/length> for IPv6) commands. Then that physical interface will be a layer-3 interface.

You can also configure virtual interfaces for VLANs (SVIs) with the global interface Vlan <number> command to create the virtual interface. You can then assign addressing to the virtual interface.

You can have all the physical interfaces as layer-2 interfaces and assigned to VLANs, then configure layer-3 SVI and do all the routing from SVI to SVI, or you could configure some or all the physical interfaces as layer-3 interfaces and it will route between any layer-3 interfaces (physical and/or virtual) you have created.

Just like a router, you cannot configure multiple layer-3 interfaces that are in the same network because routers route packets between networks, not from a network back to the same network. to send traffic on the same network, you use layer-2 bridging/switching.

How the interface is configured determines if a frame is switched at layer-2, or if the frame is stripped off the packet and the packet is routed at layer-3.

3
  • It's ok with config commands "switchport/no switchport", the device could differentiate while traffic departing from it. But a device which receives from a dumb host, still missing clarity.. Confusion is an IP Packet always had L2, L3 Headers, BTW It is a Core BCM ASIC say Qumran, not any OEM Specific.
    – ka re
    Nov 3, 2020 at 17:28
  • 1
    If a frame comes into a switch interface that is configured as a layer-2 interface, it is switched at layer-2. If the frame comes into a switch interface that is configured as a layer-3 interface, the frame is stripped off the packet, and the packet is routed at layer-3. That is really all there is to it. The configuration of the switch interface determines if it is a layer-2 or layer-3 interface, and that determines the treatment of the frame entering the switch.
    – Ron Maupin
    Nov 3, 2020 at 17:31
  • Thanks alot Ron !!! That clears my doubt.. :)
    – ka re
    Nov 3, 2020 at 17:33
1

How does the switch decides to process it as layer 2 or layer 3's ?

Very simple: a switch's L3 interface (often an "SVI" bound to a VLAN) uses a MAC address and when that MAC address is the destination, the L3 switch acts as a router. As long as the destination MAC is some other address it acts as a layer-2 switch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.