Question on Layer 2 switch logic

TacrobTacrob Registered Users Posts: 3 ■□□□□□□□□□
Question: How do Layer 2 switches handle a conversation between two computers pointing at each others IP addresses, since the switch will only be able to handle layer 2 information? Do PC's store what MAC addresses correspond to destination IP's?

I was curious about this because it occurred to me that if I were to ping another computer via a layer 2 switch, the switch wouldn't know how to route based on the destination IP, and so (I imagine) it would flood all the ports in that vlan, and the correct computer would know to respond to me. If correct, does this mean that every time I seek to send a layer 3 packet via a layer 2 switch (with no destination MAC), the switch will flood the ports in the same vlan (which I assume would cause bandwidth issues)?

Thanks,
Tacrob

Comments

  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    L2 switches have no sense of IP address really. That is what interVLAN routing is for on an L3 switch. When ARP request is sent, the destination MAC (FFFF.FFFF.FFFF) is used to broadcast out all ports on the segment (VLAN) in which it is on. All devices on the segment will respond with a response of their MAC, and the switch will store it in the MAC table. Next time a frame is forwarded on an identical segment, the switch refers to its table. If it's not in the same subnet, it will require a point of routing, whether it be a router or layer 3 switch.
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • TacrobTacrob Registered Users Posts: 3 ■□□□□□□□□□
    I understand the role of MAC addresses and VLANs in all of this, but my question was in regards to when a PC sends a packet through a layer 2 switch with a destination IP address (in the same subnet) and no destination MAC.
    My question could really be broken down into two parts:
    1) Do PC's store the MAC address of a destination IP when they get a response from an IP address?
    2) Do layer 2 switches store ARP tables (or something similar to that) so that if they receive a packet with a destination IP and no destination MAC in the frame, they will know where to send it?

    In other words, when there is no router, and everyone is on the same subnet and VLAN, do layer 2 switches flood all layer 3 messages?
  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    1. Yes, if it's on the same segment. Remember, layer 2 headers are only relevant per hop, unless you're doing some kind of special tunneling.
    2. No. The ARP cache for things on the same segment is cached in the computer's ARP table. Type in arp -a in command prompt or power she'll and you'll see what I mean.
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • TacrobTacrob Registered Users Posts: 3 ■□□□□□□□□□
    Ahhhhhh I see. I re-read your first comment and realized I am a goof because I didn't think about the fact that there is always a destination MAC, namely the broadcast address when the destination MAC isn't known by the sender. My bad on that one.

    And that makes much more sense now. I tested that command out and yes, I do see what you mean lol Thank you very much, you were extremely helpful :)
Sign In or Register to comment.