Linux查看网关命令:route n(linux查看网关命令)

/

Linux下查看网关命令一般使用route -n命令,下面给出命令的具体用法及使用示例:

1. 用法:route -n

2. 作用:该命令就会列出所有网络接口及其网关地址。

下面给出一个使用实例:

[root@localhost ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0

0.0.0.0 192.168.0.254 0.0.0.0 UG 0 0 0 eth0

以上命令列出来的即为系统所有网络接口及其网关地址,我们只能够看出设备的IP和子网掩码,查看的网关信息就位于Gateway(网关)列中。

对于route -n命令,下面简单给出一些参数说明:

-n 表示仅显示数字格式,不显示名称

-v 在显示结果上面打印出详细表格

-e 显示route 命令的扩展结果

另外,我们还可以使用netstat -rn命令来查看网关信息:

[root@localhost ~]# netstat -rn

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0

0.0.0.0 192.168.0.254 0.0.0.0 UG 0 0 0 eth0

通过netstat -rn命令,我们也可以查看网关信息。因此,为了查看Linux系统下所有网络接口及其网关,我们可以结合route -n 和netstat -rn命令,这两个命令都是非常有用的命令,我们可以结合这两个命令来查看更多有用的信息。


数据运维技术 » Linux查看网关命令:route n(linux查看网关命令)