route netstat -rn
-n :不要使用通讯协定或主机名称,直接使用ip或port number; -ee:使用更详细的资讯来显示 [root@NB data]# route -nee Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface MSS Window irtt 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 0 0 0 169.254.0.0 0.0.0.0 255.255.0.0 U 1009 0 0 br0 0 0 0 0.0.0.0 10.100.2.1 0.0.0.0 UG 0 0 0 br0 0 0 0 [root@NB data]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.122.0 0.0.0.0(表示该路由是直接由本机传送) 255.255.255.0 U 0 0 0 virbr0 169.254.0.0 0.0.0.0 255.255.0.0 U 1009 0 0 br0 0.0.0.0 10.100.2.1 0.0.0.0 UG 0 0 0 br0 [root@NB data]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0 link-local * 255.255.0.0 U 1009 0 0 br0 default 10.100.2.1 0.0.0.0 UG 0 0 0 br0 #default = 0.0.0.0/0.0.0.0 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):这个路由将不会被接受(用来抵档不安全的网域!) [root@NB data]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 169.254.0.0 0.0.0.0 255.255.0.0 U 1009 0 0 br0 0.0.0.0 10.100.2.1 0.0.0.0 UG 0 0 0 br0 上面的路由排列顺序,依序是由小网域(192.168.122.0/24 是Class C),逐渐到大网域(169.254.0.0/16 Class B)最后则是预设路由(0.0.0.0/0.0.0.0).然后当我们要判断某个网路封包应该如何传送的时候,该封包会经由这个路由的过程来判断
[root@NB src]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0 link-local * 255.255.0.0 U 1009 0 0 br0 default 10.100.2.1 0.0.0.0 UG 0 0 0 br0 #这个是系统的默认网关信息,表示去任何地方(0.0.0.0),都发给10.0.0.254,因为是默认网关,所以,放在了最后一条。路由也是有顺序的,如果不符合任何一条规则就交给默认网关处理。
sh-4.1# netstat -ra Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0 10.100.2.0 * 255.255.255.0 U 0 0 0 br0 link-local * 255.255.0.0 U 0 0 0 br0 default 10.100.2.1 0.0.0.0 UG 0 0 0 br0
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维