Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1444394
  • 博文数量: 165
  • 博客积分: 2068
  • 博客等级: 上尉
  • 技术积分: 2102
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-27 16:07
文章分类

全部博文(165)

文章存档

2018年(1)

2017年(22)

2016年(9)

2015年(22)

2014年(8)

2013年(25)

2012年(53)

2011年(25)

分类: 网络与安全

2013-02-03 16:03:20

    route命令用于显示主机路由信息,设定和操作路由器表

    route用来操作管理内核的IP路由表。主要作用是在使用ifconfig命令配置好网路接口之后,通过网络接口设定到特定主机或网络的静态路由表。

在Linux系统中可以使用route -h查看命令用法

octeon:~# route -h
Usage: route [-nNvee] [-FC] []           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.


       route {-h|--help} []              Detailed usage syntax for specified AF.
       route {-V|--version}                  Display version/author and exit.


        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -e, --extend             display other/more information
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB


  =Use '-A ' or '--'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
    x25 (CCITT X.25) 

   

    常见用法有add、del、-n、-ee

route -n :不使用主机名称而直接使用主机IP或端口号

[root@www ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0

route -nee 使用详细信息显示

[root@www ~]# route -nee
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface    MSS   Window irtt
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0     0     0      0
192.168.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0     0     0      0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0     0     0      0

Destination 目的主机或网络

Gateway   网关地址,如果没有则设置为*

Genmask  目标网络掩码,如果是目标主机则用255.255.255.255,如果是默认路由则用0.0.0.0

Flags   标志说明

    U    Up    表示此路由当前为启动状态

    H    Host 表示此网关为一主机

    G    Gateway    表示此网关为一路由器

    R    Reinstate Route    使用动态路由重新初始化的路由

    D    Dynamically    此路由为动态性地写入

    M    Modified    此路由是由路由守护程序或导向器动态修改

    !    表示此路由当前为关闭状态

Metric    到目标的距离(一般为条数)

Ref    此路由引用数目

Use    对此路由的查找

Iface    对于这个路由,数据包将要发往哪个接口(网卡)

route add(增加路由)route del(删除路由)选项的用法:

route add/del -net 192.168.0.0 netmask 255.0.0.0 gw 192.168.0.1 dev eth0

-net 表示后面指定一个网络

-host 表示后面指定一台主机

netmask表示网络掩码

gw是网关gateway的缩写,后面跟其IP

dev表示连接的设备(网卡)

route add default gw 192.168.0.1 dev eth0

default表示增加一条默认路由

[root@www ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
192.168.0.0     *               255.255.0.0     U     0      0        0 eth0
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0


阅读(2686) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~