The default gateway is the device that routes traffic from one network to other networks. Usually, router work as the default gateway. Which allows devices on one network to communicate with devices in another network. Therefore default simply means that this gateway is used by default unless an application specifies another gateway.
If you use the similarity that a network is like a home. The rooms in a home are like a computer in the network. The main gate of your home as just like a default gateway. If you want to get into another home then you will use the main gate of your home. Same is for a computer network; when you want to go outside from your network you will use the interface which is connected to outside networks. PC or computer that does not know the IP address of the default gateway is like a person, in a home, that does not know where the main gate is. They can talk to other people in the home or network, but if they do not know the default gateway address, or there is no gateway, then there is no way out.
The default gateway’s main purpose in most homes and small offices is to direct Internet traffic from the local network to the cable or DSL modem, which connects to the Internet service provider (ISP), and vice versa. The default IP address for gateway assigned by vendors of consumer routers.
The Host Default Gateway
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 on the same network.
A host’s routing table will usually include a default gateway. The host receives the IPv4 address of the default gateway dynamically from Dynamic Host Configuration Protocol (DHCP) or configured manually. In figure 1, PCs in the local network are configured with the default gateway’s IPv4 address of 192.168.1.1. If a default getaway is configured, it creates a default route in the routing table of the PC. A default route is a route, your computer will take when it tries to contact a remote network. IPv4 address 192.168.1.1 is the address of router interface. The default route is derived from the default gateway configuration and is placed in the host computer’s routing table. In addition, all computer on the local network will have a default route to send all traffic destined to remote networks to ISP Router.
The figures 2 show a topology of a router with two networks 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 gateway address.PCs are in the same subnet, so they don’t need a gateway to communicate. It’s only required destination IP address and MAC address.
When PC1 sends a packet to PC2 on the same network, the gateway address 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.
The Switch Default Gateway
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 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 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 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.