Merge pull request #26314 from geekpi/translating

translated
This commit is contained in:
geekpi
2022-07-04 08:41:31 +08:00
committed by GitHub
2 changed files with 109 additions and 109 deletions

View File

@@ -1,109 +0,0 @@
[#]: subject: "Finding Your Routers IP Address (Default Gateway) in Ubuntu and Other Linux"
[#]: via: "https://itsfoss.com/router-ip-address-linux/"
[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
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][1] or simply [searching for what is my ip][2] in [DuckDuckGo][3].
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][4], screenshots may look different.
Open System Settings:
![go to settings][5]
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][6]
It will open a new window with several details about your connection such as the IP address, DNS, and [Mac address][7]. You can also see the [saved wifi password][8] 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][9]
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][10]
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][11]
In case you didnt know, you have to [use the Ctrl+C to stop a running command in Linux][12].
I hope you find this tip useful when you need it.
--------------------------------------------------------------------------------
via: https://itsfoss.com/router-ip-address-linux/
作者:[Abhishek Prakash][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lkxed
[1]: https://www.showmyip.com/
[2]: https://duckduckgo.com/?q=what+is+my+ip&t=h_&ia=answer
[3]: https://itsfoss.com/duckduckgo-easter-eggs/
[4]: https://itsfoss.com/best-linux-desktop-environments/
[5]: https://itsfoss.com/wp-content/uploads/2022/02/go_to_settings.jpg
[6]: https://itsfoss.com/wp-content/uploads/2022/06/access-network-settings-ubuntu-800x448.png
[7]: https://itsfoss.com/change-mac-address-linux/
[8]: https://itsfoss.com/how-to-find-saved-wireless-wifi-passwords-ubuntu/
[9]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-gateway-ip-ubuntu.png
[10]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-route-linux-terminal.png
[11]: https://itsfoss.com/wp-content/uploads/2022/06/ping-gateway.png
[12]: https://itsfoss.com/stop-program-linux-terminal/

View File

@@ -0,0 +1,109 @@
[#]: subject: "Finding Your Routers IP Address (Default Gateway) in Ubuntu and Other Linux"
[#]: via: "https://itsfoss.com/router-ip-address-linux/"
[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
在 Ubuntu 和其他 Linux 系统中找到你的路由器的 IP 地址(默认网关)
======
你可能已经知道如何在 Linux 中获得你的系统的 IP 地址。
但是你怎么知道你的路由器的 IP 地址呢?
我说的不是你可以通过连接到 [Show My IP][1] 这样的网站或简单地在 [DuckDuckGo][3] 中 [搜索“我的 ip”][2] 获得的面向公众的 IP。
我说的是默认网关 IP你的 Linux 桌面使用它来连接。
你为什么需要它?嗯,如果你需要改变你的 Wi-Fi/网络的 SSID、密码或其他配置你必须连接到它。简单的方法是在网络浏览器中输入路由器的 IP 地址,然后使用路由器的用户名和密码。
虽然我不能帮助你获得路由器的用户名和密码,但我肯定可以告诉你如何获得它的 IP。
一如既往,我将展示 GUI 和命令行两种方法。
### 方法 1在 Linux 中使用 GUI 获取路由器的 IP 地址
这其实很简单。我在这里使用的是 Ubuntu 的 GNOME 桌面。如果你使用一些[其他桌面环境][4],截图可能会有所不同。
打开系统设置:
![go to settings][5]
现在进入 Wi-Fi 或网络(如果你使用的是有线、以太网连接)。在这里,点击你当前使用的网络旁边的小设置符号。
![access network settings ubuntu][6]
它将打开一个新窗口,里面有关于你的连接的一些细节,如 IP 地址、DNS 和 [Mac 地址][7]。你还可以在安全标签下看到[保存的 wifi 密码][8]。
你还会看到一个名为“默认路由”的条目。这就是你要找的东西。你的路由器的 IP 地址。
![defaul gateway ip ubuntu][9]
你的系统和网络上的所有其他设备都使用这个 IP 地址连接到路由器。这就是大多数家庭的设置。
现在我已经展示了 GUI 的方法,让我们去看看终端的路线。
### 方法 2在 Linux 命令行中获取路由器的 IP 地址
打开一个终端,使用以下命令:
```
ip route
```
它将显示几个条目。
```
[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
```
第一行,以 “default via” 开头,给了你网关的 IP。这是你的路由器的 IP 地址。
![defaul route linux terminal][10]
你可以看到192.168.1.1 是我的路由器的 IP 地址。通常情况下,路由器的 IP 地址是子网的第一个数字。然而,这并不是一个硬性规定。我也见过有 x.y.z.30 地址的路由器。
### 额外技巧
正如 Samir 在评论中所分享的你也可以使用ping命令来获得网关 IP
```
ping _gateway
```
![ping gateway][11]
以防你不知道,你必须[在 Linux 中使用 Ctrl+C 来停止一个正在运行的命令][12]。
我希望你在需要的时候能发现这个技巧是有用的。
--------------------------------------------------------------------------------
via: https://itsfoss.com/router-ip-address-linux/
作者:[Abhishek Prakash][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lkxed
[1]: https://www.showmyip.com/
[2]: https://duckduckgo.com/?q=what+is+my+ip&t=h_&ia=answer
[3]: https://itsfoss.com/duckduckgo-easter-eggs/
[4]: https://itsfoss.com/best-linux-desktop-environments/
[5]: https://itsfoss.com/wp-content/uploads/2022/02/go_to_settings.jpg
[6]: https://itsfoss.com/wp-content/uploads/2022/06/access-network-settings-ubuntu-800x448.png
[7]: https://itsfoss.com/change-mac-address-linux/
[8]: https://itsfoss.com/how-to-find-saved-wireless-wifi-passwords-ubuntu/
[9]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-gateway-ip-ubuntu.png
[10]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-route-linux-terminal.png
[11]: https://itsfoss.com/wp-content/uploads/2022/06/ping-gateway.png
[12]: https://itsfoss.com/stop-program-linux-terminal/