How to Find Your Default Gateway IP Address in the Linux Terminal

When troubleshooting network connectivity issues on a Linux machine, one of the first things you need to verify is your connection to your router (also known as your default gateway). If you cannot ping your router, you certainly won’t be able to reach the wider internet.

Unlike Windows, which prominently displays this information in the graphical Network settings, finding your default gateway IP address in Linux is often fastest via the command line.

Using the ‘ip route’ Command

The most modern and universally supported method for checking routing tables in Linux is the ip command.

  1. Open your terminal application.
  2. Type the following command and press Enter:
    ip route

You will see a few lines of output. Look for the line that begins with the word default. It will typically look something like this:

default via 192.168.1.1 dev eth0 proto dhcp metric 100

The IP address immediately following the word “via” (in this example, 192.168.1.1) is the IP address of your router. The “dev” specifies which network interface (e.g., your Wi-Fi card or Ethernet port) is connecting to it.

Using the ‘route -n’ Command (Older Systems)

If you are working on an older Linux distribution or a stripped-down server that does not have the ip tools installed, you can use the classic route command.

  1. Open your terminal.
  2. Type the following command and press Enter:
    route -n

This will display a formatted table. Look in the leftmost column (Destination) for the entry that says 0.0.0.0. The IP address listed in the second column (Gateway) on that exact same row is your router’s IP address.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.