博客
关于我
路由表添加和删除
阅读量:773 次
发布时间:2019-03-24

本文共 2510 字,大约阅读时间需要 8 分钟。

Understanding the Routing Table Information

The routing table in Linux kernel is a crucial component for managing IP packet destinations. Below is a detailed explanation of each column in the routing table:

output item Explanation
Destination The target network or host address
Gateway The gateway (router) address. An asterisk (*) indicates that the destination is on the local network, so no gateway is needed
Genmask The network mask, which defines the range of IP addresses for which this route applies
Flags Route flags indicating the type and status of the route (e.g., U for active, H for host on interface)
Metric The cost metric of the route, which is typically used in routing protocols like RIP or OSPF
Ref The reference count of the route, which may be used for routing with certain algorithms
Use The number of active routes using this route
Iface The interface through which the route is used

Deleting Entries from the Routing Table

To delete an entry from the routing table, you can use the route -n command to view the current routes and then use route del with the appropriate parameters.

Example of Using route -n to View Routes

$ route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface0.0.0.0         192.168.2.1     0.0.0.0         UG    0      0        0 wlan00.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0192.168.1.0     *               255.255.255.0   U     0      0        0 eth0192.168.2.0     *               255.255.255.0   U     0      0        0 wlan0

Deleting Specific Routes

  • Delete the first route

    $ route del -net 0.0.0.0 gw 192.168.2.1 netmask 0.0.0.0 dev wlan0
  • Delete the second route

    $ route del -net 0.0.0.0 gw 192.168.1.1 netmask 0.0.0.0 dev eth0
  • Delete the third route

    $ route del -net 192.168.1.0 gw 0.0.0.0 netmask 255.255.255.0 dev eth0
  • Delete the fourth route

    $ route del -net 192.168.2.0 gw 0.0.0.0 netmask 255.255.255.0 dev wlan0
  • After running these commands, the routing table should reflect the deletions.

    Adding Entries to the Routing Table

    To add an entry to the routing table, you can use the route add command with the appropriate parameters. For example, to add a route for the wireless interface:

    $ route add-net 192.168.2.0 gw 0.0.0.0 netmask 255.255.255.0 dev wlan0 metric 0

    This command adds a route for the network 192.168.2.0 through the wireless interface (wlan0), with the gateway at 0.0.0.0 and a network mask of 255.255.255.0. The metric is set to 0 in this example.

    转载地址:http://btvkk.baihongyu.com/

    你可能感兴趣的文章
    NCNN源码学习(1):Mat详解
    查看>>
    nc命令详解
    查看>>
    NC综合漏洞利用工具
    查看>>
    ndarray 比 recarray 访问快吗?
    查看>>
    ndk-cmake
    查看>>
    NdkBootPicker 使用与安装指南
    查看>>
    ndk特定版本下载
    查看>>
    NDK编译错误expected specifier-qualifier-list before...
    查看>>
    Neat Stuff to Do in List Controls Using Custom Draw
    查看>>
    Necurs僵尸网络攻击美国金融机构 利用Trickbot银行木马窃取账户信息和欺诈
    查看>>
    Needle in a haystack: efficient storage of billions of photos 【转】
    查看>>
    NeHe OpenGL教程 07 纹理过滤、应用光照
    查看>>
    NeHe OpenGL教程 第四十四课:3D光晕
    查看>>
    Neighbor2Neighbor 开源项目教程
    查看>>
    neo4j图形数据库Java应用
    查看>>
    Neo4j图数据库_web页面关闭登录实现免登陆访问_常用的cypher语句_删除_查询_创建关系图谱---Neo4j图数据库工作笔记0013
    查看>>
    Neo4j图数据库的介绍_图数据库结构_节点_关系_属性_数据---Neo4j图数据库工作笔记0001
    查看>>
    Neo4j图数据库的数据模型_包括节点_属性_数据_关系---Neo4j图数据库工作笔记0002
    查看>>
    Neo4j安装部署及使用
    查看>>
    Neo4j电影关系图Cypher
    查看>>