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

网络层

网络层的功能: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.
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值