一:显示现在所有路由
:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.147.9.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
link-local * 255.255.0.0 U 1000 0 0 eth0
192.168.0.0 192.168.1.1 255.255.0.0 UG 0 0 0 wlan0
default 10.147.9.1 0.0.0.0 UG 0 0 0 eth0
:~#
结果是自上而下, 就是说, 哪条在前面, 哪条就有优先, 前面都没有, 就用最后一条default
举例, 添加一条路由(发往192.168.62这个网段的全部要经过网关192.168.1.1)
route add -net 192.168.62.0 netmask 255.255.255.0 gw 192.168.1.1
删除一条路由
route del -net 192.168.122.0 netmask 255.255.255.0
删除的时候不用写网关
二:使用 route 命令添加
[@more@] 使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:
//添加到主机的路由
# route add –host 192.168.168