route 路由使用记录

一、路由的基本介绍

路由是计算机网络中的一个重要概念,它用于确定数据包从源地址到目的地址的路径。在网络中,路由器是负责转发数据包的设备。
下面是关于路由的基本知识和使用方法的介绍:
路由表:路由器通过路由表来确定数据包的下一跳。路由表中包含了目的网络的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.mfbz.cn/a/261267.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Excel 理解IF({1,0}...结构啥意思

背景知识: IF(条件,是则结果,否则结果) 逻辑真除了用True以外,还可以用不为0的数值,常用的是1;逻辑假除了用Fasle以外,还可以用数值0 理解公式 IF({1,0},B2:B8&C2:C8,D2:D8)就是构造一个二维数组,把…

Unity中Shader平移矩阵

文章目录 前言方式一:对顶点本地空间下的坐标进行相加平移1、在属性面板定义一个四维变量记录在 xyz 上平移多少。2、在常量缓冲区进行申明3、在顶点着色器中,在进行其他坐标转化之前,对模型顶点本地空间下的坐标进行转化4、我们来看看效果 方…

Linux宝塔面板本地部署Discuz论坛发布到公网访问【无需公网IP】

文章目录 前言1.安装基础环境2.一键部署Discuz3.安装cpolar工具4.配置域名访问Discuz5.固定域名公网地址6.配置Discuz论坛 前言 Crossday Discuz! Board(以下简称 Discuz!)是一套通用的社区论坛软件系统,用户可以在不需要任何编程的基础上&a…

产品需求分析师的职责内容(合集)

产品需求分析师的职责内容1 职责: 1、根据公司战略规划,负责妇产科相关平台产品的中长期规划; 2、组织需求调研、收集、分析、整理、提炼、用户的需求,分析形成可行性研究报告; 3、深入挖掘产品需求,管理用户及公司内部业务需求&a…

20V升26V 600mA升压型LED驱动芯片,PWM调光芯片-AH1160

AH1160是一个功能强大的升压型LED驱动芯片,专为需要精确控制LED亮度的PWM调光应用而设计。它可将20V输入电压升压至26V,同时提供稳定的600mA电流输出,适用于各种LED照明设备。 芯片特点: 1. 输入电压范围:AH1160可在…

6个免费设计资源站,设计师们赶紧收藏!

本期给大家分享5个免费的设计资源站,设计师必备的设计设计神奇,绝对能帮助你在工作中事半功倍,赶紧收藏吧~ 1、菜鸟图库 https://www.sucai999.com/?vNTYwNDUx 菜鸟图库是我推荐过很多次的网站,主要是站内素材多,像…

Java:获取当前线程的线程组

代码示例: package com.thb;public class Demo4 {public static void main(String[] args) {ThreadGroup threadGroup Thread.currentThread().getThreadGroup();System.out.println(threadGroup.getName());} }运行输出:

详解数据科学自动化与机器学习自动化

过去十年里,人工智能(AI)构建自动化发展迅速并取得了多项成就。在关于AI未来的讨论中,您可能会经常听到人们交替使用数据科学自动化与机器学习自动化这两个术语。事实上,这些术语有着不同的定义:如今的自动…

excel统计分析——偏度、峰度

参考链接: 偏度与峰度的正态性分布判断 - 知乎 描述统计学 - 知乎 样本偏度(skewness)与随机变量的偏度及三阶统计量之间的关系和计算估计-CSDN博客 数据分析中如何衡量数据的分布 - 知乎 KURT 函数 - Microsoft 支持 SKEW 函数 - Microsoft 支持 Standard e…

Python中的函数

创建和使用 创建函数的语法如下: def 函数名(参数):代码块(函数体) 函数的参数 形参:在定义函数的时候传递的参数 实参:在调用函数时传递的参数 无参:没有任何参数 位置参数 实参的位置和形参一一对应,不能多也不…

PowerDesigner画模型工具下载安装及基本操作

进行大型项目代码开发之前,一般会进行模型设计,画概念模型(CDM)、逻辑模型(LDM)、物理模型(PDM)。下面说一下PowerDesigner画模型工具下载安装及基本操作 一、下载与安装&#xff1…

如何解决苹果应用商城审核拒绝的Guideline 2.3.1 - Performance问题

当您的应用程序在苹果应用商城审核过程中被拒绝时,苹果会向您发送一封邮件,其中提供了关于拒绝原因的详细信息。本文将深入探讨如何正确处理Guideline 2.3.1 - Performance问题,并提供解决方案和优化建议,以确保您的应用程序能够通…

LeetCode刷题--- 括号生成

个人主页:元清加油_【C】,【C语言】,【数据结构与算法】-CSDN博客 个人专栏 力扣递归算法题 http://t.csdnimg.cn/yUl2I 【C】 http://t.csdnimg.cn/6AbpV 数据结构与算法 http://t.csdnimg.cn/hKh2l 前言:这个专栏主要讲述递归递归、搜…

韩语中的一次多用-柯桥基础韩语学习

1.动词,写 일기를 쓰다 写日记 2.动词,戴(帽子,眼镜,口罩) 안경을 쓰다 戴眼镜 3.动词,使用(材料,道具,手段) 세제를 쓰다 使用洗剂 4.动词&am…

【openwrt学习笔记】IPV6 ND协议学习和socket编程

目录 一、参考链接二、学习目标三、代码解析3.1 仅解析NA报文保存设备mac和ipv6地址信息3.1.1 open_ns_socket3.1.2 recv_ns_pack 3.2 解析NA和NS报文中DAD报文保存设备mac和ipv6地址信息3.2.1 open_ns_na_socket3.2.2 recv_ns_na_pack 四、代码优化4.1 BPF参考学习资料4.2 代码…

软件工程--设计工程--学习笔记(软件设计原则、软件质量属性设计、架构风格......)

软件设计在软件工程中处于技术核心,其目的是把需求分析模型转变为设计模型,以知道软件的实现,本章讲解软件设计的基本原则和基本实践 本文参考教材:沈备军老师的《软件工程原理》 软件设计概述 软件设计分为两个阶段&#xff0…

SpringBoot之IOCDI的详细解析

3.3.2 IOC详解 通过IOC和DI的入门程序呢,我们已经基本了解了IOC和DI的基础操作。接下来呢,我们学习下IOC控制反转和DI依赖注入的细节。 3.3.2.1 bean的声明 前面我们提到IOC控制反转,就是将对象的控制权交给Spring的IOC容器,由…

计算机网络实验速成

目录 网络实验速成 自动连接类型: 指示灯状态说明: 显示接口: 放置注释信息: 配置计算机: 同理,配置服务器: 配置路由器: router0 配置: router1 配置&…

2024年建立电子商务知识库的终极指南

Insider Intelligence报告称,2020年全球电子商务购物市场规模达到了近4万亿美元,并且没有放缓增长的迹象。 随着亚马逊通过一流的产品、快速的配送、无忧的退款等优势主导数字领域,电子商务行业的竞争变得越来越激烈。随着每年有越来越多的公…

第五节TypeScript 运算符

一、描述 运算符用于执行程序代码运算。 二、运算符主要包括: 算术运算符逻辑运算符关系运算符按位运算符赋值运算符三元/条件运算符字符串运算符类型运算符 1、算术运算符 y5,对下面算术运算符进行解释: 运算符 描述 例子 x 运算结果…
最新文章