Default Gateway

A default gateway is the router that an end device uses when the destination of a packet lies outside the device’s local subnet. It acts as the device’s main exit point toward other networks, including the internet.

Although the term is often associated with home routers, a default gateway may be a router, a Layer 3 switch, a firewall, or another device capable of forwarding traffic between network segments. The default gateway is selected through the device’s default route, which is used whenever no more specific route matches the destination address.
Before sending a packet, an IPv4 device compares the destination address with its own IP address and subnet mask:

  • If the destination belongs to the same subnet, the device sends the packet directly to the destination host.
  • If the destination is outside the local subnet, the device sends the packet to its configured default gateway.

For example, a computer with the address 192.168.1.50/24 can reach 192.168.1.20 directly because both addresses share the 192.168.1.0/24 network. However, it cannot deliver a packet to 8.8.8.8 directly. The operating system first sends that packet to the gateway, commonly 192.168.1.1, using the gateway’s MAC address.

The gateway then examines its routing table and forwards the packet toward the destination. This process may involve several routers, but the original device generally needs to know only one next hop: its default gateway.

A default route is commonly represented as:

0.0.0.0/0 via 192.168.1.1

In IPv6 networks, the equivalent route is usually shown as:

::/0 via fe80::1

The default gateway does not necessarily provide internet access, perform network address translation, or terminate the application connection. Its responsibility is simply to forward packets for destinations that cannot be reached through a more specific route.

Finding the Default Gateway

Windows

Use Command Prompt or PowerShell:

ipconfig /all

Locate the section for the active network adapter and review the Default Gateway entry. If several adapters are listed, identify the one associated with the network currently in use.

A quick summary is also available with:

ipconfig

Linux

Display the default route with:

ip route show default

A typical result looks like this:

default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.50 metric 100

The address immediately after via is the default gateway.

To confirm which gateway the kernel would use for a particular destination, run:

ip route get 1.1.1.1

macOS

Use the following command:

route -n get default

The output identifies the gateway interface and gateway address. The route table can also be inspected with:

netstat -nr

How the Default Gateway Is Configured

In most home and enterprise networks, the default gateway is supplied automatically by DHCP. Along with an IP address, subnet mask, DNS servers, and other options, the DHCP server normally provides the address of the router that clients should use as their default gateway.

Manual configuration is occasionally necessary for servers, static network endpoints, or devices managed outside the normal DHCP system. A host with a manually assigned address generally needs:

  • A valid IP address
  • The correct subnet prefix or mask
  • A default gateway within the same directly connected network
  • DNS server addresses, if hostname resolution is required

The following Netplan example configures a static IPv4 address and default route on Ubuntu or Debian:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8

Here, 192.168.1.100/24 is assigned to the interface, while the default route sends all otherwise unmatched traffic through 192.168.1.1.

After changing a Netplan configuration, the configuration can be tested and applied with:

sudo netplan try
sudo netplan apply

Manual configuration should be used carefully. An incorrect gateway address, subnet mask, or interface assignment can leave the device unable to communicate outside its local network.

Common Troubleshooting Scenarios

The gateway cannot be reached

Test the local connection first:

ping 192.168.1.1

A failed reply may indicate a disconnected cable, incorrect Wi-Fi credentials, a disabled interface, a VLAN mismatch, or an IP configuration error. However, some routers and firewalls block ICMP traffic, so an unsuccessful ping does not always prove that the gateway is offline.

Local hosts are reachable, but remote services are not

If other devices on the same subnet can be contacted while internet destinations cannot be reached, inspect the host’s routing table:

ip route

On Windows, use:

route print

Verify that a default route exists and points to the correct gateway.

The wrong gateway is being used

Check which route would be selected for a specific destination:

ip route get 8.8.8.8

This command can reveal duplicate default routes, an unexpected virtual VPN route, or a stale configuration left by a previous network.

The gateway is reachable, but website names do not resolve

Reaching the gateway and resolving hostnames are separate functions. If IP addresses work but domain names do not, the problem is more likely related to DNS than to the default route. Review the configured DNS servers and test a specific DNS resolver directly.

The problem began after an IP address change

A device may still contain an old gateway address after moving to a different network or VLAN. Renewing its DHCP lease, reviewing the active adapter configuration, and checking for duplicate IP addresses can resolve this situation.

Understanding the default gateway is fundamental to diagnosing network connectivity. The key distinction is between local delivery and off-subnet forwarding: local traffic may travel directly between devices, while traffic to more distant networks is handed to the default gateway for routing.