网络层——IP协议,ARP协议,静态路由,浮动路由

news/2024/7/8 6:42:24

文章目录

  • 网络层
    • IP数据包的格式
    • ICMP协议
      • ICMP协议的封装
      • ping命令
    • ARP协议概述
      • 什么是ARP协议
      • windows系统中的ARP命令
    • 静态路由
      • 路由表的形成
      • 路由协议的分类
    • 实例
      • 配置静态路由
      • R1配置
      • R2配置
      • R3配置
      • 测试连通
    • 浮动路由
      • 实例
      • R1配置
      • R2配置
      • R3配置

网络层

网络层的功能:1、选择数据通过网络的最佳路径
2、实现不同网段的通讯

IP数据包的格式

协议字段
版本(4)首部长度(4)优先级与服务类型(8)总长度(16)
标识符(16—————————————————标志(3)段偏移量(13)
TTL(8)协议号(8)————————————首部校验和(16)
源地址(32)
目标地址(32)
可选项
数据

ICMP协议

ICMP是一个“错误侦测与回馈机制”

ICMP协议的封装

ICMP协议属于网络层的协议

ping命令

①ping:-t参数会一直不停的执行ping,测试故障或需进行持续连通性测试时应用
ctrl+c可以中断命令
②ping-a 参数可以显示主机名称
③ping-l 参数可以设定ping包的大小
单位为字节
可用于简单测试通信质量

ARP协议概述

局域网中主机的通信
IP地址与MAC地址

什么是ARP协议

Address Resolution Protocol,地址解析协议,将一个已知的IP地址解析成MAC地址

windows系统中的ARP命令

arp -a:查看ARP缓存表
arp -d:清除ARP缓存 清除所有主机
ARP绑定:arp-s IP地址,mac地址
ip config/all 查看PC1和PC2的MAC地址
路由器中清除:reset arp st

静态路由

路由:从源主机到目标主机的转发过程,选择最佳路径的设备——路由器
1 子网掩码长度最长
2、管理距离最小
DIRECT:0 OSPF:10 IS-IS:15 STATIC:60 RIP:100 OSPFASE:150 OSPFNSSA:150
IBGP:256 EBGP:256
3、相同路由协议的情况下,选取metric值最小的最优先匹配,每种协议metric值定义的都不同,静态路由和路由优先级有关,这个是认为指定的,RIP协议和跳数有关,跳数越小越优先,OSPF协议和带宽有关,带宽最大最优先。metric是用来判定链路质量优劣的
4、如果以上都没有路由可以匹配的上,就匹配默认路由
路由表:路由器中维护的路由条目的集合,路由器根据路由表做路径选择

路由表的形成

直连网段:配置IP地址,端口CUP状态,形成直连路由
非直连网段:手动添加

路由协议的分类

路由协议:静态路由——管理员手动配置路由
动态路由——路由器间自动学习路由
动态路由分为:①局域网内——IGP内部网关路由协议——RIPV1,RIPV2,EIGRP
②互联网——EGP外部网路由协议——BGPV4

实例

在这里插入图片描述

配置静态路由

1、配置IP
2、测试直连
3、配置静态路由
4、查看路由表
5、ping测试

R1配置

[R1]int LoopBack 0
[R1-LoopBack0]ip add 192.168.1.10 24
[R1-LoopBack0]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 10.1.1.2 24
[R1-GigabitEthernet0/0/0]un
[R1-GigabitEthernet0/0/0]undo sh
[R1-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]q
[R1]ip tou
[R1]ip rou
[R1]ip route-st
[R1]ip route-static 10.2.1.0 24 10.1.1.3
[R1]ip rou
[R1]ip route-st
[R1]ip route-static 172.16.1.10 24 10.1.1.3
Info: The destination address and mask of the configured static route mismatched
, and the static route 172.16.1.0/24 was generated.
在这里插入图片描述

R2配置

[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.1.1.3 24
[R2-GigabitEthernet0/0/0]un
[R2-GigabitEthernet0/0/0]undo sh
[R2-GigabitEthernet0/0/0]undo shutdown
[R2-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 10.2.1.3 24
[R2-GigabitEthernet0/0/1]un
[R2-GigabitEthernet0/0/1]undo sh
[R2-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]q
[R2]ip route-static 192.168.1.10 24 10.1.1.2
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
[R2]ip route-static 172.16.1.10 24 10.2.1.4
Info: The destination address and mask of the configured static route mismatched
, and the static route 172.16.1.0/24 was generated.
在这里插入图片描述

R3配置

[R3]int LoopBack 0
[R3-LoopBack0]ip add 172.16.1.10 24
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 10.2.1.4 24
[R3-GigabitEthernet0/0/0]un
[R3-GigabitEthernet0/0/0]undo sh
[R3-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]q
[R3]ip route-static 192.168.1.10 24 10.2.1.3
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
[R3]ip route-static 10.1.1.0 24 10.2.1.3
在这里插入图片描述

测试连通

在这里插入图片描述

浮动路由

指的是配置两条静态路由,默认选取链路质量优(带宽大的)作为主路径,当主路径出现故障时,由带宽较小的备份路由顶替,保持网络的不中断。

实例

在这里插入图片描述

R1配置

配置与静态路由一致,只需在备份路径上,将优先级调制比主电路低
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 10.1.1.1 24
[Huawei-GigabitEthernet0/0/0]u
[Huawei-GigabitEthernet0/0/0]un sh
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int e0/0/0
[Huawei-Ethernet0/0/0]ip add 20.1.1.1 24
[Huawei-Ethernet0/0/0]q
[Huawei]sys
[Huawei]sysname R1
[R1]ip rou
[R1]ip route-st
[R1]ip route-static 0.0.0.0 0 10.1.1.2
[R1]ip rou
[R1]ip route-st
[R1]ip route-static 0.0.0.0 0 20.1.1.2 pr
[R1]ip route-static 0.0.0.0 0 20.1.1.2 preference 61
在这里插入图片描述

R2配置

[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.1.1.2 24
[R2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]int e0/0/0
[R2-Ethernet0/0/0]ip add 20.1.1.2 24
[R2-Ethernet0/0/0]un sh
[R2-Ethernet0/0/0]un sh
Info: Interface Ethernet0/0/0 is not shutdown.
[R2-Ethernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 30.1.1.2 24
[R2-GigabitEthernet0/0/1]q
[R2]ip ro
[R2]ip route-st
[R2]ip route-static 1.1.1.1 32 10.1.1.1
[R2]ip route-static 1.1.1.1 32 20.1.1.1 pr
[R2]ip route-static 1.1.1.1 32 20.1.1.1 preference 61
[R2]ip route-static 3.3.3.3 32 30.1.1.3
在这里插入图片描述
在这里插入图片描述

R3配置

[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 30.1.1.3 24
[R3-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]int loop 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]q
[R3]ip ro
[R3]ip route-st
[R3]ip route-static 0.0.0.0 0 30.1.1.
在这里插入图片描述


http://www.niftyadmin.cn/n/3652646.html

相关文章

[原创] 推荐介绍几款小巧的Web Server程序

偶然看到几个小巧有趣的Web Server程序,觉得有必要拿来分享一下,让大家除了知道Apache、IIS之外,原来还有更多有趣的选择。主要介绍了:micro_httpd、mini_httpd、thttpd、lighttpd、shttpd 等无款小巧好用的httpd。【 micro_httpd…

动态路由——RIP

文章目录动态路由协议度量值收敛静态路由与动态路由的比较按照路由执行的算法分类割接:换协议RIPRIP的基本概念水平分割技术毒性逆转RIPV1和RIPV2RIPV实例R1配置R2配置R3配置查询R1换到RIPV2协议查询R1对比动态路由协议 RIPV:动态路由不需要手工写路由&…

[原创]MySQL中MyISAM引擎和Heap引擎执行速度性能测试

MySQL中MyISAM引擎和Heap引擎执行速度性能测试【测试环境】CPU: Intel Pentium4 2.66GHz Memory: 1GB Disk: 73GB/SCSI OS: FreeBSD 4.11 PHP: PHP 5.2.1MySQL: MySQL 4.1.23b【 前期工作 】[ my.cnf ]max_heap_table_size 128M[ 建表 ]usetest;----Store engine heap--C…

网络测试(除了动态路由)

文章目录测试图lsw1配置lsw2配置lsw3配置lsw4配置R1配置R2配置测试图 lsw1配置 [sw1]vlan bat 10 20 30 40 Info: This operation may take a few seconds. Please wait for a moment...done. [sw1]int e0/0/1 [sw1-Ethernet0/0/1]port link-type trunk [sw1-Ethernet0/0/1]p…

[转] 贴Snoopy.class.php代码学习参考

Snoopy.class.php 是一个关于HTTP协议访问操作的类库,主要是使用在 MagpieRSS 中用于远程文件的抓取,我原来转载的一篇文章大致有简单的介绍这个东西,今天无聊,把代码帖出来,大家参考学习。php/**********************…

传输层——TCP/IP协议,三次握手四次挥手

文章目录TCP和UDP协议TCP报文段三次握手四次挥手TCP端口UDP报文段UDP端口TCP和UDP协议 面向连接:指双方之间在通信之前要建立连接(如打电话) 无连接网络协议:指不需要先建立通信连接 TCP:传输控制协议 面向连接的&…

[原创]PHP4和PHP5性能测试和对比

PHP4和PHP5性能测试和对比作者:heiyeluren博客:http://blog.csdn.net/heiyeshuwu时间:2007年8月6日PHP 4到今年年底PHP Group将不再对其进行支持了,所以为了让大家更有信心的转移到PHP 5平台上,我特别做了这个测试&…

VRRP的作用与配置

文章目录VRRP的概述VRRP的作用VRRP术语抢占配置VRRP的概述 1.利用VRRP,一组路由器(同一个LAN中的接口),协同工作,但是只有一个处于Master状态,处于该状态的路由器(的接口)承担实际的数据流量转…