Finding Your Router's IP Address (Default Gateway) in Ubuntu and Other Linux

Looking for a way to connect to your router but don't know its address? Here's how to get the IP address of your router in Ubuntu and other Linux systems.
Warp Terminal

You probably already know how to get your system’s IP address in Linux.

But how do you know the IP address of your router?

I am not talking about the public-facing IP which you can get by connecting to websites like Show My IP or simply searching for ‘what is my ip’ in DuckDuckGo.

I am talking about the default gateway IP which your Linux desktop uses to connect to it.

Why do you need it? Well, if you need to change the SSID, password, or other configuration of your wi-fi/network, you have to connect to it. And the simplest way is to type the router's IP address in a web browser and then use the router’s username and password.

While I cannot help you with the username and password of your router, I can surely tell you how to get its IP.

As always, I’ll show both GUI and command-line methods.

Method 1: Get the router’s IP address in Linux using GUI

It’s quite simple actually. I am using GNOME desktop with Ubuntu here. If you use some other desktop environments, screenshots may look different.

Open System Settings:

go to settings
Go to Settings

Now go to Wi-Fi or Network (if you are using a wired, Ethernet connection). Here, click on the little settings symbol beside your currently used network.

access network settings ubuntu

It will open a new window with several details about your connection such as the IP address, DNS, and Mac address. You can also see the saved wifi password under the security tab.

You’ll also see an entry named ‘Default Route’. This is what you are looking for. The IP address of your router.

defaul gateway ip ubuntu
Default Route is the IP address of your router

Your system and all other devices on your network connect to the router using this IP address. This is the setup most households have.

Now that I have shown the GUI method, let’s go to the terminal route.

Method 2: Get the router’s IP address in Linux command line

Open a terminal and use the following command:

ip route

It will show you a few entries.

abhishek@itsfoss:~$ ip route
default via dev wlp0s20f3 proto dhcp metric 600 dev wlp0s20f3 scope link metric 1000 dev wlp0s20f3 proto kernel scope link src metric 600

The first line, which starts with ‘default via’, gives you the gateway IP. This is your router’s IP address.

defaul route linux terminal
Getting default gateway in Linux command line

As you can see, is the IP address of my router. Usually, the router’s IP address is the first number of the subnet. However, this is not a hard and fast rule. I have seen routers with x.y.z.30 addresses as well.

Bonus tip

As shared by Samir in the comments, you can also use the ping command to get the gateway IP:

ping _gateway
ping gateway
Ping gateway

In case you didn’t know, you have to use the Ctrl+C to stop a running command in Linux.

I hope you find this tip useful when you need it.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world


Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.