Linux的路由表详解

一 在Linux下执行route命令
[root@localhost backup]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 enp0s3
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
 
[root@localhost backup]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp0s3
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
 
二 route命令详解
1、命令语法
route [-n]
选项与参数:
-n:将主机名以IP方式显示
 
2、查询结果分析
Destination  :其实就是Network的意思。
Gateway      :就是该接口的 Gateway的IP,若为0.0.0.0,表示不需要额外的IP。
Genmask    :就是Netmask,与 Destination组合成一台主机或网络。
Flags           :共有多个标志可以来表示该网络或主机代表的意义。
                                U:代表该路由可用。
                        G:代表需要经过 Gateway来帮忙传递。
                        H:代表该行路由为一台主机,而非一个网络。
Iface            :就是interface(接口)的意思。

猜你喜欢

转载自cakin24.iteye.com/blog/2336157