route 路由使用记录

news2024/9/20 10:46:17

一、路由的基本介绍

路由是计算机网络中的一个重要概念,它用于确定数据包从源地址到目的地址的路径。在网络中,路由器是负责转发数据包的设备。
下面是关于路由的基本知识和使用方法的介绍:
路由表:路由器通过路由表来确定数据包的下一跳。路由表中包含了目的网络的IP地址和对应的下一跳地址。当路由器接收到一个数据包时,它会查找路由表,找到与目的地址匹配的条目,并将数据包发送到相应的下一跳地址。
静态路由:静态路由是手动配置的路由,管理员需要手动添加路由表的条目。静态路由的优点是简单、可靠,适用于小型网络或者需要固定路由的场景。但是,静态路由不适用于大型网络或者网络拓扑经常变化的情况。
动态路由:动态路由是通过动态路由协议学习到的路由。动态路由协议有自己的路由算法,能够自动适应网络拓扑的变化。常见的动态路由协议有OSPF、IS-IS、BGP等。动态路由的优点是能够自动适应网络变化,减少管理员的配置工作量。但是,动态路由也需要一定的计算和通信开销。
路由选择:当到达同一目的地的多条路由具有相同的路由优先级时,路由开销最小的将成为当前的最优路由。路由开销可以根据不同的路由协议和网络条件进行计算,常见的开销指标包括带宽、延迟、可靠性等。
路由器配置:配置路由器的路由表可以使用命令行界面(CLI)或者图形用户界面(GUI)。管理员可以手动添加静态路由,也可以配置动态路由协议来学习路由。

二、路由指令-手动配置

1. 路由帮助

route --help

在这里插入图片描述
在这里插入图片描述

2. 路由查找

route -n

在这里插入图片描述

Destination     Gateway         Genmask         Flags 	Metric 		Ref   	 Use		 Iface
目标            下一跳/网关        子网掩码          标志  	跃点   		引用  	使用 	接口
OUTPUT
       The output of the kernel routing table is organized in the following columns

       Destination
              The destination network or destination host.

       Gateway
              The gateway address or '*' if none set.

       Genmask
              The netmask for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for the default route.

       Flags  Possible flags include
              U (route is up)
              H (target is a host)
              G (use gateway)
              R (reinstate route for dynamic routing)
              D (dynamically installed by daemon or redirect)
              M (modified from routing daemon or redirect)
              A (installed by addrconf)
              C (cache entry)
              !  (reject route)

       Metric The 'distance' to the target (usually counted in hops).

       Ref    Number of references to this route. (Not used in the Linux kernel.)

       Use    Count of lookups for the route.  Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C).

       Iface  Interface to which packets for this route will be sent.
       
       MSS    Default maximum segment size for TCP connections over this route.

       Window Default window size for TCP connections over this route.

       irtt   Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol parameters without waiting on (possibly slow) answers.

       HH (cached only)
              The number of ARP entries and cached routes that refer to the hardware header cache for the cached route. This will be -1 if a  hardware  address  is
              not needed for the interface of the cached route (e.g. lo).

       Arp (cached only)
              Whether or not the hardware address for the cached route is up to date.


3. 路由添加

route add
示例
route add -net 192.168.2.15 netmask 255.255.255.255 metric 1024 gw 192.168.2.1 dev eth1

4. 路由删除

route del
或
route delete

示例
route del -net 192.168.2.15 netmask 255.255.255.255 metric 1024 gw 192.168.2.1 dev eth1

4. 其它

-net 就是说你这条路由目标是一个网络地址,或者说是一个网段;
-host 说你这个路由目标是一个主机地址,是一个到主机的路由;
官方参数有介绍

三、官方参数介绍

OPTIONS
       -A family
              use the specified address family (eg `inet'). Use route --help for a full list. You can use -6 as an alias for --inet6 and -4 as an alias for -A inet

       -F     operate on the kernel's FIB (Forwarding Information Base) routing table.  This is the default.

       -C     operate on the kernel's routing cache.

       -v     select verbose operation.

       -n     show  numerical  addresses  instead  of  trying to determine symbolic host names. This is useful if you are trying to determine why the route to your
              nameserver has vanished.

       -e     use netstat(8)-format for displaying the routing table.  -ee will generate a very long line with all parameters from the routing table.

       del    delete a route.

       add    add a new route.

       target the destination network or host. You can provide an addresses or symbolic network or host name. Optionally you can use /prefixlen notation instead of
              using the netmask option.

       -net   the target is a network.

       -host  the target is a host.

       netmask NM
              when adding a network route, the netmask to be used.

       gw GW  route packets via a gateway.
              NOTE:  The  specified  gateway  must  be reachable first. This usually means that you have to set up a static route to the gateway beforehand. If you
              specify the address of one of your local interfaces, it will be used to decide about the interface to which the packets should be routed to. This  is
              a BSDism compatibility hack.
   metric M
              set  the metric field in the routing table (used by routing daemons) to M. If this option is not specified the metric for inet6 (IPv6) address family
              defaults to '1', for inet (IPv4) it defaults to '0'. You should always specify an explicit metric value to not rely on those  defaults  -  they  also
              differ from iproute2.

       mss M  sets MTU (Maximum Transmission Unit) of the route to M bytes.  Note that the current implementation of the route command does not allow the option to
              set the Maximum Segment Size (MSS).

       window W
              set the TCP window size for connections over this route to W bytes. This is typically only used on AX.25 networks and with drivers unable  to  handle
              back to back frames.

       irtt I set  the  initial  round  trip time (irtt) for TCP connections over this route to I milliseconds (1-12000). This is typically only used on AX.25 net‐
              works. If omitted the RFC 1122 default of 300ms is used.

       reject install a blocking route, which will force a route lookup to fail.  This is for example used to mask out networks before  using  the  default  route.
              This is NOT for firewalling.

       mod, dyn, reinstate
              install a dynamic or modified route. These flags are for diagnostic purposes, and are generally only set by routing daemons.

       dev If force  the route to be associated with the specified device, as the kernel will otherwise try to determine the device on its own (by checking already
              existing routes and device specifications, and where the route is added to). In most normal networks you won't need this.

              If dev If is the last option on the command line, the word dev may be omitted, as it's the default. Otherwise the order of the route modifiers  (met‐
              ric netmask gw dev) doesn't matter.


四、官方示例

EXAMPLES
       route add -net 127.0.0.0 netmask 255.0.0.0 metric 1024 dev lo
              adds  the  normal  loopback  entry, using netmask 255.0.0.0 and associated with the "lo" device (assuming this device was previously set up correctly
              with ifconfig(8)).

       route add -net 192.56.76.0 netmask 255.255.255.0 metric 1024 dev eth0
              adds a route to the local network 192.56.76.x via "eth0".  The word "dev" can be omitted here.

       route del default
              deletes the current default route, which is labeled "default" or 0.0.0.0 in the destination field of the current routing table.

       route del -net 192.56.76.0 netmask 255.255.255.0
              deletes the route. Since the Linux routing kernel uses classless addressing, you pretty much always have to specify the netmask that is  same  as  as
              seen in 'route -n' listing.

       route add default gw mango
              adds  a  default  route (which will be used if no other route matches).  All packets using this route will be gatewayed through the address of a node
              named "mango". The device which will actually be used for that route depends on how we can reach "mango" - "mango"  must  be  on  directly  reachable
              route.

       route add mango sl0
              Adds the route to the host named "mango" via the SLIP interface (assuming that "mango" is the SLIP host).

       route add -net 192.57.66.0 netmask 255.255.255.0 gw mango
              This command adds the net "192.57.66.x" to be gatewayed through the former route to the SLIP interface.

       route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
              This  is an obscure one documented so people know how to do it. This sets all of the class D (multicast) IP routes to go via "eth0". This is the cor‐
              rect normal configuration line with a multicasting kernel.

       route add -net 10.0.0.0 netmask 255.0.0.0 metric 1024 reject
              This installs a rejecting route for the private network "10.x.x.x."

       route -6 add 2001:0002::/48 metric 1 dev eth0
              This adds a IPv6 route with the specified metric to be directly reachable via eth0.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1326008.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

配置自定义RedisTemplate 解决redis序列化java8 LocalDateTime

目录 配置自定义RedisTemplate 引入依赖 配置连接redis 编写测试类 出现问题 配置序列化 解决redis序列化java8 LocalDateTime 问题背景 问题描述 问题分析 解决方案一(全局) 解决方案二(单个字段) 配置自定义RedisTe…

某电子文档安全管理系统存在任意用户登录漏洞

漏洞简介 某电子文档安全管理系统存在任意用户登录漏洞,攻击者可以通过用户名获取对应的cookie,登录后台。 资产测绘 Hunter语法:web.icon“9fd216c3e694850445607451fe3b3568” 漏洞复现 获取Cookie POST /CDGServer3/LinkFilterServi…

MySQL 8.0 InnoDB Tablespaces之File-per-table tablespaces(单独表空间)

文章目录 MySQL 8.0 InnoDB Tablespaces之File-per-table tablespaces(单独表空间)File-per-table tablespaces(单独表空间)相关变量:innodb_file_per_table使用TABLESPACE子句指定表空间变量innodb_file_per_table设置…

ESD静电的危害与失效类型及模式?|深圳比创达电子

一、ESD的危害 1、失效的电子设备有60%~75%都是由ESD造成的; 2、对于新兴技术行业,尤其是高科技微电子,半导体,电磁敏感类及光器件的应用,比例将上升到90%。 因静电原因造成的电子行业的损失每年都多达几百亿美元&am…

JavaWeb笔记之前端开发HTML

一、引言 1.1HTML概念 网页,是网站中的一个页面,通常是网页是构成网站的基本元素,是承载各种网站应用的平台。通俗的说,网站就是由网页组成的。通常我们看到的网页都是以htm或html后缀结尾的文件,俗称 HTML文件。 …

【SpringCloud】设计原则之CAP与EDA事件驱动

一、设计原则之CAP CAP 原则又称 CAP 定理,指的是在一个分布式系统中,Consistency(一致性)、Availability(可用性)和 Partition tolerance(分区容错性),三者不可兼得&…

美颜技术详解:深入了解视频美颜SDK的工作机制

本文将深入探讨视频美颜SDK的工作机制,揭示其背后的科技奥秘和算法原理。 1.引言 视频美颜SDK作为一种集成到应用程序中的技术工具,通过先进的算法和图像处理技术,为用户提供令人印象深刻的实时美颜效果。 2.视频美颜SDK的基本工作原理 首…

C#上位机与欧姆龙PLC的通信04---- 欧姆龙plc的存储区

1、存储区概念 欧姆龙PLC将整个数据存储器分为10个区:输入继电器区、输出继电器区、内部辅助继电器区、特殊继电器区、保持继电器区、暂存继电器区、定时/计数器区、数据存储区、辅助存储继电器区、链接继电器区。 输入输出继电器区 CP1E系列PLC输入继电器区有16…

Modbus-ASCII数据帧

Modbus-ASCIl传输模式中,每个字节均以ASCI编码,实际报文中1个字节会以两ASCIl字符发送,因此这种模式比Modbus-RTU模式效率要低。 例如报文数据 x5B "5""B" X35 X42 . 数据帧格式如下: 从ASCI报文帧可以看出&#xff0…

探索 Vue3 (四) keep-alive缓存组件

keep-alive 的作用 官网介绍:KeepAlive | Vue.js keep-alive为抽象组件,主要用于缓存内部组件数据状态。可以将组件缓存起来并在需要时重新使用,而不是每次重新创建。这可以提高应用的性能和用户体验,特别是在需要频繁切换组件时…

java实现回文数算法

判断一个数是否为回文数可以使用以下算法: 将数字转化为字符串;初始化左右两个指针,分别指向字符串的首尾;循环比较左右指针指向的字符,如果相等则继续比较,直到左右指针相遇或者发现不相等的字符为止&…

使用凌鲨辅助学习软件研发

对于新入门的软件研发人员来说,Git和研发环境的搭建确实是一个不小的挑战。Git是一个分布式版本控制系统,用于跟踪代码的更改和协作,而研发环境则是一个专门用于开发和测试应用程序的环境。 在Git方面,新入门的软件研发人员需要了…

升级ChatGPT4的方法

1. 主要流程:先申请一个美区apple id,然后往这个apple id充钱,用这个apple id的钱订阅chatgpt 2. 细节: (1)申请美区apple id: 其实这一步很简单(曾经以为比较复杂)&…

23年12月AI烟火识别系统应用案例-北京梅兰芳故居防火系统

AI烟火识别智能视频分析系统在文化遗产保护领域的应用,尤其是在梅兰芳故居防火系统的部署,是现代科技与传统文化保护结合的典范。这篇文章将详细介绍富维烟火识别系统的设计、实施及其在23年12月在北京梅兰芳故居中的应用。 背景介绍 ● 梅兰芳故居的重要…

php-使用wangeditor实现富文本(完成图片上传)-npm

官网参考连接:快速开始 | wangEditor 样式: 一、新建一个临时文件夹test1和一个文件夹wangeditor 临时文件夹test1:临时存放通过npm下载的文件文件夹wangeditor:用于存放在临时文件夹test1拷贝的css和js 二、安装 editor 在确保有…

mac电池最大充电限制 AlDente Pro中文 for Mac

热保护:在电池温度较高时为电池充电会导致电池老化更快。启用热保护后,当电池温度过高时,充电将自动停止。 航行模式:通常情况下,即使激活了最大电池充电,您的 MacBooks 电池也会始终稍微充电和放电以保持所…

【yolov8系列】 yolov8 目标检测的模型剪枝

前言 最近在实现yolov8的剪枝,所以有找相关的工作作为参考,用以完成该项工作。 先细读了 Torch-Pruning,个人简单记录了下 【剪枝】torch-pruning的基本使用,有框架完成的对网络所有结构都自适应剪枝是最佳的,但这里没…

快速从图中提取曲线坐标数据的在线工具WebPlotDigitizer

快速从图中提取曲线坐标数据的在线工具WebPlotDigitizer 1 介绍2 WebPlotDigitizer在线版的使用2.1 上传图像2.2 点击横纵坐标点:2.3 选择曲线 3 查看数据参考 1 介绍 写论文时要对比别人曲线图、点图、柱形图的数据,但是只有图没有原始数据怎么办&…

JVM调优小结

JVM常见工具介绍 jinfo(查看配置信息) 查看Java应用程序配置参数或者JVM系统属性&#xff0c;相关命令详情我们可以使用-help或者man命令查看&#xff0c;如下所示: [rootxxxxxtmp]# jinfo -help Usage:jinfo [option] <pid>(to connect to running process)jinfo [op…

《信息安全工程师教材》-蒋建春、信息安全完全参考手册-Mark Rhodes Ousley、CISSP官方学习指南第九版、ISO27002学习

文章目录 介绍关系学习顺序重复内容学习方法建议学习时间可能重合的部分更详细的学习计划 介绍 《信息安全工程师教材》- 蒋建春&#xff1a;这本教材可能是针对中国地区信息安全工程师的认证考试而编写的&#xff0c;它可能会涵盖信息安全的基本概念、技术和政策&#xff0c;特…