mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
提交译文
This commit is contained in:
parent
c1786ee342
commit
17fa028a13
@ -7,42 +7,42 @@
|
||||
[#]: via: (https://www.2daygeek.com/check-find-default-gateway-or-router-ip-address-in-linux/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
Four Methods To Check The Default Gateway Or Router IP Address In Linux?
|
||||
======
|
||||
在 Linux 中检查默认网关或者路由 IP 地址的四个方法?
|
||||
==============================================
|
||||
|
||||
Your default gateway is the IP address of your router that you should aware of that.
|
||||
你应该意识到你的默认网关是你的路由器的 IP 地址。
|
||||
|
||||
Typically this is automatically detected by your operating system during installation, if not then you may need to change it.
|
||||
典型地这是在安装过程中由操作系统自动检测的,如果没有,你可能需要改变它。
|
||||
|
||||
If your system not able to ping self then probable it could be a gateway issue and you have to fix it.
|
||||
如果你的系统不能 ping 自身,那么很可能是一个网关问题,你必须修复它。
|
||||
|
||||
This might happen if you have multiple network adapters or routers on the network.
|
||||
在网络中,当你有多个网络适配器或路由器时,这种情况可能会发生。
|
||||
|
||||
A gateway is a router that acts as an access point to passes network data from one networks to another networks.
|
||||
一个网关是一个路由器扮演着一个入口点角色,从一个网络传递网络数据到另一个网络。
|
||||
|
||||
The below articles will help you to gather some other information which is similar to this topic.
|
||||
下面是一些可能帮助你收集到的与该话题相似的一些信息。
|
||||
|
||||
* **[9 Methods To Check Your Public IP Address In Linux Command Line][1]**
|
||||
* **[How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux?][2]**
|
||||
|
||||
|
||||
|
||||
This can be done using below Four commands.
|
||||
这可以通过下面的四个命令完成。
|
||||
|
||||
* **`route Command:`** route command is used to show and manipulate the IP routing table.
|
||||
* **`ip Command:`** IP command is similar to ifconfig, which is very familiar for assigning Static IP Address, Route & Default Gateway, etc.,.
|
||||
* **`netstat Command:`** netstat (“network statistics”) is a command-line tool that displays network connections related information (both incoming and outgoing) such as routing tables, masquerade connections, multicast memberships and a number of network interface
|
||||
* **`routel Command:`** routel command is used to list routes with pretty output format.
|
||||
* **`route 命令`** route 命令被用来显示和操作 IP 路由表。
|
||||
* **`ip 命令:`** IP 命令类似于 ifconfig, 非常熟悉赋值静态 IP 地址,路由 & 默认网关,等等。
|
||||
* **`netstat 命令`** netstat (“network statistics”)是一个命令行工具来显示网络连接相关的信息(包括入口和出口的)例如路由表,伪装连接,多播成员和很多网络接口。
|
||||
* **`routel 命令`** routel 命令被用来以好看的输出格式列出路由。
|
||||
|
||||
|
||||
|
||||
### 1) How To Check The Default Gateway Or Router IP Address In Linux Using route Command?
|
||||
### 1)在 Linux 中如何使用 route 命令检查默认的网关或者路由 IP 地址?
|
||||
|
||||
route command is used to show and manipulate the IP routing table.
|
||||
route 命令被用来显示和操作 IP 路由表。
|
||||
|
||||
Its primary use is to set up static routes to specific hosts or networks via an interface once the interface was configured.
|
||||
它主要用于通过一个已经配置的接口给特定的主机或者网络设置静态的路由。
|
||||
|
||||
When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
|
||||
当 add 或者 del 选项被使用时,route 修改路由表。没有这些选项,route 显示路由表的当前内容。
|
||||
|
||||
```
|
||||
# route
|
||||
@ -55,17 +55,17 @@ default www.routerlogin 0.0.0.0 UG 600 0 0 wlp8s0
|
||||
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp8s0
|
||||
```
|
||||
|
||||
### 2) How To Check The Default Gateway Or Router IP Address In Linux Using ip Command?
|
||||
### 2)如何在 Linux 中使用 ip 命令检查默认网关或者路由 IP 地址?
|
||||
|
||||
**[IP command][3]** is similar to ifconfig, which is very familiar for assigning Static IP Address, Route & Default Gateway, etc.,.
|
||||
**[IP 命令][3]** 相似于 ifconfig,非常熟悉配置静态 IP 地址,路由 & 默认网关,等等。
|
||||
|
||||
ifconfig command was deprecated due to no maintenance since so many years, even though it is still available on most Linux distributions.
|
||||
ifconfig 命令因为多年没有维持被遗弃了,即使它仍然在大多数 Linux 分发版上可获得。
|
||||
|
||||
ifconfig command has been replaced by IP command which is very powerful and performing several network administration tasks with one command.
|
||||
ifconfig 命令已经被 IP 命令替代了,IP 命令是非常强大的,只要一个命令就能执行几个网络管理任务。
|
||||
|
||||
IP command utility bundled with iproute2 package. By default iproute2 utility pre-installed all the major Linux distribution.
|
||||
IP 命令工具附带在 iproute2 包中。默认 iproute2 预安装在主要的 Linux 分发版中。
|
||||
|
||||
If no, you can install it by issuing iproute2 on your terminal with help of package manager.
|
||||
如果没有,你可以在你的终端中在包管理器的帮助下通过输入 iproute2 并安装它。
|
||||
|
||||
```
|
||||
# ip r
|
||||
@ -78,13 +78,13 @@ default via 192.168.1.1 dev wlp8s0 proto dhcp metric 600
|
||||
192.168.1.0/24 dev wlp8s0 proto kernel scope link src 192.168.1.6 metric 600
|
||||
```
|
||||
|
||||
### 3) How To Check The Default Gateway Or Router IP Address In Linux Using netstat Command?
|
||||
### 3)如何在 Linux 中使用 netstat 命令检查默认网关或者路由 IP 地址?
|
||||
|
||||
netstat stands for Network Statistics, is a command-line tool that displays network connections related information (both incoming and outgoing) such as routing tables, masquerade connections, multicast memberships and a number of network interface.
|
||||
netstat 代表 Network Statistics,是一个命令行工具来显示网络连接相关的信息(包括入口和出口的)例如路由表,伪装连接,多播成员和很多网络接口。
|
||||
|
||||
It lists out all the tcp, udp socket connections and the unix socket connections.
|
||||
它列出所有的 tcp, udp 套接字连接和 unix 套接字连接。
|
||||
|
||||
It is used for diagnosing network problems in the network and to determine the amount of traffic on the network as a performance measurement.
|
||||
它在网络中被用来诊断网络问题并判断网络中的交通总量来作为性能测量指标。
|
||||
|
||||
```
|
||||
# netstat -r
|
||||
@ -95,13 +95,13 @@ default www.routerlogin 0.0.0.0 UG 0 0 0 wlp8s0
|
||||
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp8s0
|
||||
```
|
||||
|
||||
### 4) How To Check The Default Gateway Or Router IP Address In Linux Using routel Command?
|
||||
### 4)如何在 Linux 中使用 routel 命令检查默认网关或者路由 IP 地址?
|
||||
|
||||
It used to list routes with pretty output format. These programs are a set of helper scripts you can use instead of raw iproute2 commands.
|
||||
它用来以好看的输出格式列出路由信息。这些程序是一系列你可以用来替代 iproute2 的帮助脚本。
|
||||
|
||||
The routel script will list routes in a format that some might consider easier to interpret then the ip route list equivalent.
|
||||
routel 脚本以一种被认为更容易解释并且等价于 route 输出列表的格式来输出路由信息。
|
||||
|
||||
The routef script does not take any arguments and will simply flush the routing table down the drain. Beware! This means deleting all routes which will make your network unusable!
|
||||
如果 routef 脚本不加任何参数,将仅仅简单的将路由表清空。小心!这意味着删除所有的路由,让你的网络不再可用。
|
||||
|
||||
```
|
||||
# routel
|
||||
@ -122,7 +122,8 @@ fe80::ad00:2f7e:d882:5add local kernel w
|
||||
ff00::/ 8 wlp8s0 local
|
||||
```
|
||||
|
||||
If you would like to print only default gateway then use the following format.
|
||||
如果你只想打印默认的网关那么使用下面的格式。
|
||||
|
||||
|
||||
```
|
||||
# routel | grep default
|
||||
@ -135,7 +136,7 @@ via: https://www.2daygeek.com/check-find-default-gateway-or-router-ip-address-in
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[warmfrog](https://github.com/warmfrog)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
Loading…
Reference in New Issue
Block a user