当前位置:网站首页>学习日记——(路由与交换技术)动态路由(rip协议)和静态路由
学习日记——(路由与交换技术)动态路由(rip协议)和静态路由
2022-07-23 05:46:00 【賺钱娶甜甜】
一、相关知识点
1、动态路由
- 动态路由是网络中的路由器之间相互通信,传递路由信息,利用收到的路由信息计算路由并更新路由表的过程。
- 实时地适应网络结构变化
- 适用于网络规模大、网络拓扑结构复杂的网络
- 有多个网络协议,常见的有RIP、OSPF、EIGRP等
- 灵活,但开销大
- 自动交换路由信息,无需管理员配置
2、RIP路由协议
- RIP是一种距离矢量路由协议,内部网关协议,应用于自治系统内。
- RIP使用跳数作为路径选择的唯一度量。
- 跳数最多不能超过15。
- 每30s广播一次消息工作过程。
二、相关例子
1、拓扑结构
此处省略主机的IP地址配置图,读者根据自己的需要自己配置,像我 网关都是设置192.168.1/2/3.254

2、相关代码:
路由表中R代表RIP S代表静态
Route 1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R1
R1(config)#int g
R1(config)#int gigabitEthernet 0/0
R1(config-if)#ip add
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#int gigabitEthernet 0/1
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#int gigabitEthernet 0/2
R1(config-if)#ip address 192.168.13.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up
R1(config)#route rip 这段是配置RIP协议,注意:RIP配置的网段是与该路由器的直连网段。
R1(config-router)#net
R1(config-router)#network 192.168.1.0
R1(config-router)#network 192.168.12.0
R1(config-router)#network 192.168.13.0
R1(config-router)#ver
R1(config-router)#version 2(版本号)
R1(config-router)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.254/32 is directly connected, GigabitEthernet0/0
R 192.168.2.0/24 [120/1] via 192.168.12.2, 00:00:09, GigabitEthernet0/1 (R代表的是RIP协议)
R 192.168.3.0/24 [120/1] via 192.168.13.2, 00:00:13, GigabitEthernet0/2 ([120/1],120代表管理距离,1代表开销)
192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.12.0/24 is directly connected, GigabitEthernet0/1
L 192.168.12.1/32 is directly connected, GigabitEthernet0/1
192.168.13.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.13.0/24 is directly connected, GigabitEthernet0/2
L 192.168.13.1/32 is directly connected, GigabitEthernet0/2
R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:09, GigabitEthernet0/1
[120/1] via 192.168.13.2, 00:00:13, GigabitEthernet0/2
Route 2:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R2
R2(config)#int g
R2(config)#int gigabitEthernet 0/0
R2(config-if)#ip add
R2(config-if)#ip address 192.168.2.254 255.255.255.0
R2(config-if)#no shu
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R2(config-if)#e
R2(config-if)#exit
R2(config)#int gigabitEthernet 0/1
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R2(config-if)#e
R2(config-if)#exit
R2(config)#int gigabitEthernet 0/2
R2(config-if)#ip address 192.168.23.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up
R2(config-if)#e
R2(config-if)#exit
R2(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up
R2(config)#route rip 这段是配置RIP协议,注意:RIP配置的网段是与该路由器的直连网段。
R2(config-router)#net
R2(config-router)#network 192.168.2.0
R2(config-router)#network 192.168.12.0
R2(config-router)#network 192.168.23.0
R2(config-router)#ver
R2(config-router)#version 2
Route 3:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R3
R3(config)#int g
R3(config)#int gigabitEthernet 0/0
R3(config-if)#ip add
R3(config-if)#ip address 192.168.3.254 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
R3(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R3(config-if)#e
R3(config-if)#exit
R3(config)#int gigabitEthernet 0/1
R3(config-if)#ip address 192.168.13.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R3(config-if)#
R3(config-if)#exit
R3(config)#int gigabitEthernet 0/2
R3(config-if)#ip address 192.168.23.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up
R3(config-if)#e
R3(config-if)#exit
R3(config)#route rip 这段是配置RIP协议,注意:RIP配置的网段是与该路由器的直连网段。
R3(config-router)#net
R3(config-router)#network 192.168.3.0
R3(config-router)#network 192.168.13.0
R3(config-router)#network 192.168.23.0
R3(config-router)#ver
R3(config-router)#version 2
R3(config-router)#
R3(config-router)#end
R3#
%SYS-5-CONFIG_I: Configured from console by console
R3#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
R 192.168.1.0/24 [120/1] via 192.168.13.1, 00:00:05, GigabitEthernet0/1
R 192.168.2.0/24 [120/1] via 192.168.23.1, 00:00:11, GigabitEthernet0/2
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/0
L 192.168.3.254/32 is directly connected, GigabitEthernet0/0
R 192.168.12.0/24 [120/1] via 192.168.23.1, 00:00:11, GigabitEthernet0/2
[120/1] via 192.168.13.1, 00:00:05, GigabitEthernet0/1
192.168.13.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.13.0/24 is directly connected, GigabitEthernet0/1
L 192.168.13.2/32 is directly connected, GigabitEthernet0/1
192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.23.0/24 is directly connected, GigabitEthernet0/2
--More--
结果:
PC1 ping PC2

RIP与静态的对比
Route 1:
en
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.12.2
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.13.2
R1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.254/32 is directly connected, GigabitEthernet0/0
S 192.168.2.0/24 [1/0] via 192.168.12.2
S 192.168.3.0/24 [1/0] via 192.168.13.2
192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.12.0/24 is directly connected, GigabitEthernet0/1
L 192.168.12.1/32 is directly connected, GigabitEthernet0/1
192.168.13.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.13.0/24 is directly connected, GigabitEthernet0/2
L 192.168.13.1/32 is directly connected, GigabitEthernet0/2
S 192.168.23.0/24 [1/0] via 192.168.12.2
Route 2:
R2>en
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1
R2(config)#ip route 192.168.13.0 255.255.255.0 192.168.12.1
R2(config)#ip route 192.168.3.0 255.255.255.0 192.168.23.2
R2(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.12.1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/0
L 192.168.2.254/32 is directly connected, GigabitEthernet0/0
S 192.168.3.0/24 [1/0] via 192.168.23.2
192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.12.0/24 is directly connected, GigabitEthernet0/1
L 192.168.12.2/32 is directly connected, GigabitEthernet0/1
S 192.168.13.0/24 [1/0] via 192.168.12.1
192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.23.0/24 is directly connected, GigabitEthernet0/2
L 192.168.23.1/32 is directly connected, GigabitEthernet0/2
Route 3:
R3>en
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.13.1
R3(config)#ip route 192.168.12.0 255.255.255.0 192.168.13.1
R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.23.1
R3(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.13.1
S 192.168.2.0/24 [1/0] via 192.168.23.1
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/0
L 192.168.3.254/32 is directly connected, GigabitEthernet0/0
S 192.168.12.0/24 [1/0] via 192.168.13.1
192.168.13.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.13.0/24 is directly connected, GigabitEthernet0/1
L 192.168.13.2/32 is directly connected, GigabitEthernet0/1
192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.23.0/24 is directly connected, GigabitEthernet0/2
L 192.168.23.2/32 is directly connected, GigabitEthernet0/2
总结:当网络中配有RIP路由协议和静态路由,网络会启用静态路由,为什么呢?
因为优先级,静态路由的管理距离比RIP(120)的小,所以会用静态路由。
路由表中R代表RIP S代表静态
这篇文章到这里就写完啦,加油!!
边栏推荐
- Unity3d:UGUI,UI与特效粒子层级,2018.2以上版本BakeMesh,粒子在两个Image之间且在ScrollView
- Explain various network protocols in detail
- 冒泡排序,快速排序
- Prometheus Operator使用指南笔记
- 牛客面试必考真题【算法篇】高频Top200 题目汇总
- Unity3d:ugui, UI and special effect particle level, bakemesh above 2018.2, particles between two images and in Scrollview
- 剖析Redis集群
- Unity3D+moba+技能指示器(一)
- 以go语言为例类比侦探推理来讲解【性能分析】
- 《Kubernetes in Action》第二章笔记
猜你喜欢

How to write a web page with a common text editor

C #: TOPK: take the largest 100 before 10000 numbers, and sort the heap

LSM-tree(Log Structured-Merge Tree)的理解

HCIP---BGP相关配置

OSPF综合实验
![[AUTOSAR DCM 1. module introduction (DSL, DSD, DSP)]](/img/99/55b3162ad061fbd00145d0b6810592.png)
[AUTOSAR DCM 1. module introduction (DSL, DSD, DSP)]

@Requiredargsconstructor annotation use

C# 自定义栈(Stack)

如何用普通的文本编辑器写Web页面

HCIP --- HDLC和PPP协议
随机推荐
读《凤凰架构》- RPC的历史与知识
Explain the establishment of TCP connection in detail
[memory understand the difference and function between ram flash and EEPROM memory]
围棋能力概念与软件开发能力概念的对应
0回溯/动态规划中等 LeetCode526. 优美的排列
C# 自定义Queue队列集合
Explanation of websocket protocol
Unity3d+GameFramework:资源分析,资源依赖,循环依赖检测
简洁描述raft与paxos在设计上的共同点和不同点
HCIP---MGRE环境下的OSPF综合实验
URL查询参数编码问题(golang)
Unity在URP管线下使用TriLib插件加载模型材质不正确的问题
C # custom stack
以go语言为例类比侦探推理来讲解【性能分析】
浅析互联网协议(一)
unity3d:Assetbundle模拟加载,同步加载,异步加载,依赖包加载,自动标签,AB浏览器,增量打包
Analyze sentinel mode in redis
Unity3d:UGUI,UI与特效粒子层级,2018.2以上版本BakeMesh,粒子在两个Image之间且在ScrollView
HCIP---OSPF细节讲解
LSM-tree(Log Structured-Merge Tree)的理解