Hello Shivam
Let me try to clarify. If we are talking about HSRP where two routers play the role of the redundant gateway, then the interfaces of the routers that are acting as the redundant gateways must be in the same subnet. This can be seen in this diagram here:
The Gi0/2 interfaces of C1 and C2 must be in the same subnet/network segment. In other words, a Layer 2 infrastructure must connect them. Why? There are two reasons:
- A gateway is used to reach networks outside of the local subnet. The interfaces that act as the redundant default gateways must both be in the local subnet for which they will act as gateways.
- The second reason is that HSRP requires that these interfaces communicate directly with each other to exchange HSPR messages. This exchange takes place over the same Layer 2 connection between them.
Now how are these principles applied when we have L3 switches with SVIs? Take a look at this topology:
Here we have SW1 and SW2 and each one has an SVI of VLAN 10 assigned to the 192.168.1.0/24 network, just like the routed ports. In order to ensure that the SVIs can communicate with each other to exchange HSRP messages, we must have the same prerequisites as before. The SVIs must have the same VLAN SVI on each switch, they must be on the same subnet, and they must be able to communicate with each other at Layer 2. The only way they can do this in the above topology is if they have a trunk link between them that includes VLAN 10.
With such a topology, the trunk between the switches also acts as a path for the hosts to reach either default gateway.
Alternatively, you can have a topology like this:
In this topology, you don’t need a trunk between SW1 and SW2 because the SVIs can communicate with each other (for HSRP) via SW3. But this adds an additional device in the communication path between SW1 and SW2.
Ideally, you should create a trunk between the L3 switches that includes the VLAN for which the SVIs have been configured with HSRP, regardless of what other infrastructure you place between the L3 switches and the hosts that are served by those redundant SVIs.
I hope this has been helpful!
Laz