Default gateways
I've covered how devices communicate using IP when the devices are on the same subnet. But what happens if they are on different networks? This is where the default gateway comes into play. As described previously, the source device and destination device are either on the same subnet or they're on different subnets. In this example, let's change our source IP address, while keeping the destination IP address the same. So now our source and destination address and subnet masks are:
192.168.99.15 255.255.255.0
192.168.40.39 255.255.255.0
Because we are still using /24 subnet masks, we know these two devices are in different subnets since the third octet for each is different. And because subnets are used to break up broadcasts, using the broadcast mechanism with an ARP table will not work in this situation. This is why we need a default gateway.
The default gateway address is used as the destination of all traffic that is not on the same subnet. The gateway is a layer 3 device such as a router or multi-layer switch that is used to route traffic on a hop-by-hop basis. But for the purposes of this discussion, the only thing the end device needs to know is whether the data is on the same subnet. If it's not, the source device delivers traffic to the end device through the default gateway.
The default gateway always resides in the same subnet as the end device IP. The gateway address can really be any unique address within the subnet itself, but most network administrators designate the first number of the subnet as the default gateway. Therefore, 192.168.99.1 would be the default subnet gateway of our source device given the fact that we have a 255.255.255.0 subnet mask.
PREVIOUS page: Broadcasts