TranslateProject/sources/tech/20220629 Finding Your Router-s IP Address -Default Gateway- in Ubuntu and Other Linux.md
2022-06-30 08:27:02 +08:00

4.5 KiB
Raw Blame History

Finding Your Routers IP Address (Default Gateway) in Ubuntu and Other Linux

You probably already know how to get your systems 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 simples way is to type the IP address of the router in a web browser and then use the routers 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, Ill show both GUI and command-line methods.

Method 1: Get the routers IP address in Linux using GUI

Its 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

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.

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

defaul gateway ip ubuntu

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, lets go to the terminal route.

Method 2: Get the routers IP address in Linux command line

Open a terminal and use the following command:

ip route

It will show you a few entries.

[email protected]:~$ ip route
default via 192.168.1.1 dev wlp0s20f3 proto dhcp metric 600 
169.254.0.0/16 dev wlp0s20f3 scope link metric 1000 
192.168.1.0/24 dev wlp0s20f3 proto kernel scope link src 192.168.1.34 metric 600

The first line, which starts with default via, gives you the gateway IP. This is your routers IP address.

defaul route linux terminal

As you can see, 192.168.1.1 is the IP address of my router. Usually, the routers 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

In case you didnt 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.


via: https://itsfoss.com/router-ip-address-linux/

作者:Abhishek Prakash 选题:lkxed 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出