route 命令

route

一般来说,只要有网络接口,该接口就会产生一个路由。route命令主要用来查看,修改主机网络接口路由信息。

    1. 查看路由表
        常见参数:
            -n: 不要使用通讯协议或主机名,直接使用 IP 或 端口号
            -ee:显示更详细的信息

        # route
        [root@www chenli]# route 
        Kernel IP routing table
        Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
        172.16.26.0     *               255.255.255.0   U     1      0        0 eth1
        default         172.16.26.1     0.0.0.0         UG    0      0        0 eth1

        # route -n
        [root@www chenli]# route -n
        Kernel IP routing table
        Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
        172.16.26.0     0.0.0.0         255.255.255.0   U     1      0        0 eth1
        0.0.0.0         172.16.26.1     0.0.0.0         UG    0      0        0 eth1

        # route -nee
        [root@www chenli]# route -nee
        Kernel IP routing table
        Destination     Gateway         Genmask         Flags Metric Ref    Use Iface    MSS   Window irtt
        172.16.26.0     0.0.0.0         255.255.255.0   U     1      0        0 eth1     0     0      0
        0.0.0.0         172.16.26.1     0.0.0.0         UG    0      0        0 eth1     0     0      0

        # Destination 目标网络,0.0.0.0表示默认路由
        # Gateway  路由的下一跳地址,0.0.0.0 表示该路由是透过局域网络的 MAC 直接传送
        # Genmask 目标网络子网掩码
        # 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):这个路由将不会被接受(用来抵挡不安全的网域!)

        # Iface:这个路由传递封包的接口

猜你喜欢

转载自blog.csdn.net/cl2010abc/article/details/79916968
今日推荐