当前位置:网站首页>这几个默认路由、静态路由的配置部署都不会,还算什么网工!
这几个默认路由、静态路由的配置部署都不会,还算什么网工!
2022-06-24 12:50:00 【51CTO】
今天我带着大家了解路由器的寻址转发以及学习默认路由、静态路由的配置部署。
首先给大家简单普及一下最基础的知识,路由器的路由就是去往一个目的网络的路径信息。那么路由器是如何转发的呢?简单来说,转发过程分为三步。
第一步,首先路由器收到数据帧,去除帧头帧尾,查看3层报头;
第二步,根据3层报头的目的地址来查路由表转发;
第三步,因为数据包不能直接转发,所以需要根据出接口连接网络类型来查看对应的二层表项来确定出接口的数据封装信息。
接下来我们就从控制层面和数据层面来详细说说路由器的转发。
(1)控制层面是路由器通过直连接口、静态路由、动态路由选择协议,形成路由表,包含各路由条目,而路由条目又包含了前缀、掩码、出接口、下一跳、优先级(管理距离)、开销(度量值)。
既然说到了路由表,那么就顺便说一下路由加表原则:思科设备中路由度量值为255,则不加表,华为设备255加表但信用度较低。度量值为1-254,若该路由条目为新学到的路由则加表;该路由若已经通过其它路由协议已加表,则查看该管理距离(优先级),优先级小,则加表。优先级一样,则根据系统偏好进行加表。该路由通过相同路由协议已加表,则查看度量值(开销),开销小,则加表。开销一样,则同时加表,实现负载均衡。
(2)数据层面:首先查看该数据帧是不是发送给自己的是则解封装查看三层报头,不是则丢弃该数据帧。该3层报头目的ip地址,逐个与路由条目中掩码做与运算,得到网路号能命中则按照该路由条目转发,未命中则丢弃。当同时命中多个路由条目时,根据最长匹配原则,选择掩码较长的路由条目进行数据转发。
说完了路由器的转发原理,下面就说说默认路由、静态路由。首先,静态路由是由管理员在路由器中手动配置的固定路由。静态路由优势有:管理员可以完全控制网络中数据的走向、设备开销很小、家庭网络出口。
而默认路由是一种特殊的静态路由,是当路由表中与数据包的目的地址之间没有匹配的IP时路由器做出的选择。如果没有默认路由,那么目的地址在路由表没有匹配IP时数据将被丢弃。默认路由会大大简化路由器的配置,减轻管理员的的工作负担。
下面介绍一下静态路由和默认路由的配置方法:
配置静态路由的命令:
思科:ip route+目标网段+目标网段掩码+出接口/下一跳地址
华为:ip route-static+目标网段+目标网段掩码+出接口/下一跳地址。
配置默认路由的命令:
思科:ip route 0.0.0.0 0.0.0.0+下一跳地址
华为:ip route-static 0.0.0.0 0.0.0.0+下一跳地址
最后我们就来做一下静态路由、默认路由的部署小实验,网络拓扑如下(此实验使用的是华为ensp模拟器,因为命令行差异不大,这里只以一个厂商为例)。
实验要求很简单,只使用静态路由,使得路由器之间可以ping通对方的环回口。配置如下:
AR1:
interface GigabitEthernet0/0/0
ip address 12.1.1.1 24
interface LoopBack0
ip address 1.1.1.1 32
ip route-static 23.1.1.0 255.255.255.0 12.1.1.2
ip route-static 2.2.2.2 255.255.255.255 12.1.1.2
ip route-static 3.3.3.3 255.255.255.255 12.1.1.2
AR2:
interface GigabitEthernet0/0/0
ip address 12.1.1.2 24
interface GigabitEthernet0/0/1
ip address 23.1.1.2 24
interface LoopBack0
ip address 2.2.2.2 32
ip route-static 1.1.1.1 255.255.255.255 12.1.1.1
ip route-static 3.3.3.3 255.255.255.255 23.1.1.3
AR3:
interface GigabitEthernet0/0/0
ip address 23.1.1.3 24
interface LoopBack0
ip address 3.3.3.3 32
ip route-static 12.1.1.0 255.255.255.0 23.1.1.2
ip route-static 1.1.1.1 255.255.255.255 23.1.1.2
ip route-static 2.2.2.2 255.255.255.255 23.1.1.2
实验结果如图:
拓展:上面使用华为模拟器做了静态路由的实验,那么如果要求使用静态加默认路由呢,该怎么解决呢?下面我们就用思科的EVEng来使得路由器之间可以ping通对方的环回口。如下拓扑:
R1:
interface e0/0
ip address 12.1.1.1 255.255.255.0
no shutdown
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
ip route 0.0.0.0 0.0.0.0 12.1.1.2
R2:
interface e0/0
ip address 12.1.1.2 255.255.255.0
no shutdown
interface e0/1
ip address 23.1.1.2 255.255.255.0
no shutdown
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
ip route-static 1.1.1.1 255.255.255.255 12.1.1.1
ip route-static 3.3.3.3 255.255.255.255 23.1.1.3
R3:
interface e0/0
ip address 23.1.1.3 255.255.255.0
no shutdown
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
ip route 0.0.0.0 0.0.0.0 23.1.1.2
实验结果如图:
拓展实验配置部署到这里就结束啦!
对我最大的支持,就是点赞评论+转发啦!
边栏推荐
- 系统测试主要步骤
- How stupid of me to hire a bunch of programmers who can only "Google"!
- Creation and use of unified links in Huawei applinking
- 使用 Abp.Zero 搭建第三方登录模块(一):原理篇
- Implement Domain Driven Design - use ABP framework - update operational entities
- Integrate API interface parameter Dictionary of accounts of multiple local distribution companies - Express 100
- 8 lines of code to teach you how to build an intelligent robot platform
- IIS WCF 808 port service access exception
- Quickly understand the commonly used message summarization algorithms, and no longer have to worry about the thorough inquiry of the interviewer
- 1. Snake game design
猜你喜欢

LVGL库入门教程 - 颜色和图像

CVPR 2022 | interprétation de certains documents de l'équipe technique de meituan

openGauss内核:简单查询的执行

One article explains R & D efficiency! Your concerns are

Detailed explanation of abstractqueuedsynchronizer, the cornerstone of thread synchronization

面试官:MySQL 数据库查询慢,除了索引问题还可能是什么原因?

go Cobra命令行工具入门

How stupid of me to hire a bunch of programmers who can only "Google"!

系统测试主要步骤
![[data mining] final review (sample questions + a few knowledge points)](/img/90/a7b1cc2063784fb53bb89b29ede5de.png)
[data mining] final review (sample questions + a few knowledge points)
随机推荐
Are you still working hard to select *? Then put away these skills
The data value reported by DTU cannot be filled into Tencent cloud database through Tencent cloud rule engine
Introduction to reptile to give up 01: Hello, reptile!
Boss direct employment IPO: both the end and the beginning
go Cobra命令行工具入门
16 safety suggestions from metamask project to solid programmers
Main steps of system test
Appium installation
开发者调查:Rust/PostgreSQL 最受喜爱,PHP 薪水偏低
Implement Domain Driven Design - use ABP framework - create entities
8 lines of code to teach you how to build an intelligent robot platform
Kubernetes集群部署
Configure Yum proxy
Comparator 排序函数式接口
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
C语言中常量的定义和使用
Quickly understand the commonly used message summarization algorithms, and no longer have to worry about the thorough inquiry of the interviewer
SAP QM qac1 transaction code cannot modify the quantity in the inspection lot containing Hu
CVPR 2022 | 美团技术团队精选论文解读
System status identifier 'hum' for SAP QM inspection lot