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

    你可能感兴趣的文章
    LiveGBS user/save 逻辑缺陷漏洞复现(CNVD-2023-72138)
    查看>>
    localhost:5000在MacOS V12(蒙特利)中不可用
    查看>>
    mac mysql 进程_Mac平台下启动MySQL到完全终止MySQL----终端八步走
    查看>>
    Mac OS 12.0.1 如何安装柯美287打印机驱动,刷卡打印
    查看>>
    MangoDB4.0版本的安装与配置
    查看>>
    Manjaro 24.1 “Xahea” 发布!具有 KDE Plasma 6.1.5、GNOME 46 和最新的内核增强功能
    查看>>
    mapping文件目录生成修改
    查看>>
    MapReduce程序依赖的jar包
    查看>>
    mariadb multi-source replication(mariadb多主复制)
    查看>>
    MaterialForm对tab页进行隐藏
    查看>>
    Member var and Static var.
    查看>>
    memcached高速缓存学习笔记001---memcached介绍和安装以及基本使用
    查看>>
    memcached高速缓存学习笔记003---利用JAVA程序操作memcached crud操作
    查看>>
    Memcached:Node.js 高性能缓存解决方案
    查看>>
    memcache、redis原理对比
    查看>>
    memset初始化高维数组为-1/0
    查看>>
    Metasploit CGI网关接口渗透测试实战
    查看>>
    Metasploit Web服务器渗透测试实战
    查看>>
    Moment.js常见用法总结
    查看>>
    MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
    查看>>