博客
关于我
路由表添加和删除
阅读量: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/

    你可能感兴趣的文章
    Nessus漏洞扫描教程之配置Nessus
    查看>>
    Nest.js 6.0.0 正式版发布,基于 TypeScript 的 Node.js 框架
    查看>>
    nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML.
    查看>>
    nestesd exception is java .lang.NoSuchMethodError:com.goolge.common.collect
    查看>>
    nestJS学习
    查看>>
    net core 环境部署的坑
    查看>>
    NET Framework安装失败的麻烦
    查看>>
    Net 应用程序如何在32位操作系统下申请超过2G的内存
    查看>>
    Net.Framework概述
    查看>>
    NET3.0+中使软件发出声音[整理篇]<转>
    查看>>
    net::err_aborted 错误码 404
    查看>>
    NetApp凭借领先的混合云数据与服务把握数字化转型机遇
    查看>>
    NetAssist网络调试工具使用指南 (附NetAssist工具包)
    查看>>
    Netbeans 8.1启动参数配置
    查看>>
    NetBeans IDE8.0需要JDK1.7及以上版本
    查看>>
    NetBeans之JSP开发环境的搭建...
    查看>>
    NetBeans之改变难看的JSP脚本标签的背景色...
    查看>>
    netbeans生成的maven工程没有web.xml文件 如何新建
    查看>>
    netcat的端口转发功能的实现
    查看>>
    NetCore 上传,断点续传,可支持流上传
    查看>>