路由表产生的类型:


[root@centos init.d]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.18.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1   <1
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1   <2
0.0.0.0         192.168.18.1    0.0.0.0         UG    0      0        0 eth1   <3

当主机需要发送数据包时,就会查阅上述的三个路由规则来了解如何发送数据包。

依据网络接口而存在的路由


上述的192.168.18.0的路由是因为网络接口的存在,如果两个网络接口则会有两个这样的路由存在。

在使用route命令之前,你需要有一个概念“你所规划的路由必须要是你的设备(如eth0)或者IP可以直接沟通的情况”

手动或默认路由(default route)

以上为例:
 [root@centos init.d]# route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.5.125
SIOCADDRT: 网络不可达

则会提示:
    SIOCADDRT: No such process

重点在于上述中“Flags参数中的G”G表示getway,说明该路由使用外部设备当做网关的。