Centos 6方法
查看当前路由
[root@test ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.125.192.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 1002 0 0 eth0
0.0.0.0 10.125.192.254 0.0.0.0 UG 0 0 0 eth0
Flags:总共有多个旗标,代表的意义如下:
U (route is up):该路由是有效的;
H (target is a host):目标是一部主机 (IP) 而非网域;
G (use gateway):需要透过外部的主机 (gateway) 来转递封包(一般指向默认网关);
R (reinstate route for dynamic routing):使用动态路由时,恢复路由资讯的旗标;
D (dynamically installed by daemon or redirect):已经由服务或转 port 功能设定为动态路由
M (modified from routing daemon or redirect):路由已经被修改了;
! (reject route):这个路由将不会被接受(用来抵挡不安全的网域
添加临时网关(重启失效)例:
方法1
[root@test ~]# route add -net 192.168.1.0/24 gw 10