The responsibility of the default gateway is to route traffic from one network to another network. Generally, the router works as the default gateway and allows devices on one network to communicate with the devices in another network. It’s the main purpose in most homes and small offices are 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.
If you consider the similarity of the network is like a home. The rooms in a home are like a computer in the network. The main gate of the home as just likes a default gateway. If you want to get into another home then you will use the main gate of your home and another home gate to enters someone’s home. Same as 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 gateway address, or there is no gateway, then there is no way out.
The Host Default Gateway
When the host wants to communicate outside the local network, he uses the gateway. Usually, the host default gateway address is the router interface address which has connected 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 usually includes a gateway address. The host can receive the IPv4 address of the default gateway dynamically from DHCP services or we can configure it manually.
The figure below illustrates the PCs in the local network configured with the gateway’s IPv4 address of 192.168.10.1. If a default getaway is configured on the host, it creates a default route in the routing table of the hosts. A default route is a route a computer will take when it tries to contact a remote network. IPv4 address 192.168.10.1 is the address of router interface, which is the default gateway for the hosts. The default route resultant from the default gateway configuration and placed in the host computer’s routing table.
If host1 send a packet to http://networkustad.com, which is not in the same network with host1. The host1 then sends 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 using the correct interface to reach networkustad.com.
As the figure illustrates that the router has connected with two networks, local network, and the internet provider. Each host device configured with the right gateway address. The hosts are in the same subnet, so they don’t need a gateway to communicate with each other. It’s the only required destination IP address and MAC address. When host1 sends a packet to host2 on the same network; the gateway address is not used. Host1 forwards the packet directly to Host2 through the switch using the IP address of the PC-2.
The Switch Default Gateway
As we discussed earlier that switch is a layer2 device and layer2 devices do not need an IP address to work properly. But, if you want to connect to the switch remotely for administration purpose over multiple networks; you will need to configure the SVI with an IPv4 address; subnet mask, and 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 can access 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 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 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 using packets originating from the switch.
Host routing table
We can check the host routing table on windows operating system using any one of the following commands.
- route print
- netstat -r
The commands can display the host routing table. Both commands generate the same result. Entering the netstat -r command or the route print command displays the result which has three sections related to the current TCP/IP network connections:
This section lists and show the MAC address and assigned interface number of every network-capable interface on the host, including Ethernet, WI-Fi, and Bluetooth adapters.
IPv4 Routing Table
This section display all IPv4 routes, as well as direct connections, local network, and local default routes.
IPv6 Routing Table
This section display all IPv6 routes, as well as direct connections, local network, and local default routes.