Hello Rakshit
Let’s say you have a setup like this:
Host A wants to ping Host B. The following will occur:
- Host A will encapsulate an IP packet with a source IP of 10.0.0.100 and a destination IP of 20.0.0.100. The host sees that the destination IP is not in the same subnet as the source IP.
- When this is encapsulated into an Ethernet frame, the MAC of the next hop must be determined. Since the destination is not in the same subnet, the host will need the MAC of the default gateway, which is the SVI of VLAN 10 with an IP address of 10.0.0.1. If the host has this MAC in its ARP table, it will use that as a destination MAC. If not, it will send out an ARP request, find it out, and put it in the destination MAC. The frame is then sent on its way.
- The switch will receive this frame on it’s port, and will populate the MAC address table with the source MAC and the port number. The destination MAC is read and it is that of the SVI (the switch itself), so the switch decapsulates the frame, and sees that the destination IP in the IP header is 20.0.0.100. Because this is a L3 switch, it knows that this address is in a network that it is directly attached to so it routes the packet.
- The IP packet will then be encapsulated into a new frame, with the source MAC as the SVI of VLAN 20 and the destination MAC of the Host B, which is either learned via ARP or already in the ARP table.
- The switch will then look at the destination MAC and determine in the MAC address table if an entry exists. If it does, it will send it out of the right port and it reaches Host B. If it does not, then it sends it out all of the ports on VLAN 20.
I hope this has been helpful!
Laz