Switch that is working in the workgroup is a layer 2 device that does not require an IP address to function properly. But, if you want to connect to the switch remotely for administration purpose over multiple networks; you will require configuring the SVI with an IPv4 address, subnet mask, and default gateway address. In other words, to remotely access the switch from another network using SSH or Telnet, the switch must have an SVI with an IPv4 address, subnet mask, and default gateway address configured. If the switch is accessed from a host within the local network; then the switch default gateway address is not required. The default gateway address is necessary to configure on each device that wants to communicate beyond the local network.
The default gateway address is typically the address of a router interface that is connected to switch. To configure a default gateway on a Cisco switch use the “ip default-gateway” command in global configuration mode.
Packets originating from host computers connected to the switch must already have the default gateway address configured on their host computer operating systems. So they host computer do not need a default gateway configured on the switch. Actually, the IP address and default gateway information are only used for packets that originate from the switch.
End device required configuration with correct IP address information, including the default gateway address of the network. The host default gateway is used when the host wants to communicate outside the network. Usually, the host default gateway address is the router interface address attached to the local network of the host. The host IP address and the router interface address should be in the same network.
The figures show a topology of a router with two network connected with its two interfaces. FE 0/0 is connected to network 192.168.10.0/24, while FE 0/1 is connected to network 192.168.20.0/24. Each host device is configured with the right default gateway address.PCs are in same subnet, so they don’t need a default gateway to communicate. Its only required destination IP address and MAC address.
When PC1 sends a packet to PC2 in the same network, the default gateway is not used. PC1 forwards the packet directly to PC2 through the switch using the IP address of the PC-2.
If PC1 sends a packet to PC4 which is not in the same network with PC-1. In this example, PC1 addresses the packet with the IP address of the PC3, but then forwards the packet to the router. The router accepts the packet, and then accesses its routing table to decide the correct exit interface based on the destination address, and then forwards the packet out of the correct interface to reach PC4.
Note – If you think your friends would find this useful, Please share it with them I’d really appreciate it.