常见的网络协议

静态路由

  • 特点
  • 需要手动配置
  • 只适合应用于小型网络中
  • 无法根据拓扑的变化进行动态的响应(各厂商开发了扩展特性,以便弥补静态路由在这点上的不足)
R1(config)# ip route network-address subnet-mask {ip-add | exit-interface} 
#实列
R1(config)# ip route 192.168.45.0 255.255.255.0  192.168.12.2

缺省路由

R1(config)# ip route 0.0.0.0 0.0.0.0 出口地址或接口

动态路由协议

  • 通过在路由器上运行动态路由协议,使得路由器之间能够交互“用于路由计算的信息”,从而路由器动态的“学习”到网络中的路由

管理距离

  • 不同的路由协议会有不同的管理距离
  • 值越小的管理距离优先级越高
  • 当路由器从不同的协议里学习到相同的路由的时候,优先选择优先级高的路由

常见的管理距离

image.png

环回接口

  • Loopback接口,也叫环回口,是一个逻辑的、虚拟的接口;
  • 使用全局配置命令interface loopback 加上接口编号可创建一个Loopback接口,创建完成后即可

为接口配置IP地址;
Loopback接口在手工创建后,除非人为shutdown,否则不会DOWN掉;
Loopback接口常用于:
模拟路由器的直连网段,可用于测试;

  • 可用于设备管理(Loopback接口比较稳定);
  • 供其他协议使用,例如OSPF、BGP、MPLS等;SNMPTraps消息的源地址;

动态路由协议,RIP

  • RIP最大跳数16跳
  • 管理距离在思科上为120
  • RIP是基于UDP的,使用端口号520
  • RIP是一种距离矢量路由协议,属于IGP协议。

距离矢量路由协议

  • 使用距离矢量路由协议的路由器并不了解网络的拓扑。该路由器只知道:自身与目的网络之间的距离
  • 应该往哪个方向或使用哪个接口转发数据包
  • 路由器收敛完成
  • 当所有路由表包含相同网络可达性信息
  • 网络(路由)进入一个稳态,路由器继续交换路由信息
  • 当无新路由信息被更新时收敛结束
  • 网络在达到收敛前无法完全正常工作

image.png

RIP解决路由慢收敛和毒性路由问题机制

  • 水平分割,从一个网口发出的路由信息,不在从其他网口发出,避免路由洪范问题
  • 规定最大跳数如果超过最大跳数,则认为不可达,将从路由条目中删除,提高路由聚敛
  • 触发更新,当路由拓扑发生更新时,不必等到下一个更新周期,就会更新路由条目
  • 保持信息,当某个路由条目不可达时,就会一直保持他不可达的状态,提高慢收件敛

RIP配置

Router(config)# router rip
Router(config-router)# version 1/2
Router(config-router)# network network-number

image.png

  • 结果

image.png

RIP路由汇总

R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary # 关闭rip的自动路由汇总
R1(config-if)# add 172.16.10.10 255.255.255.0
R1(config-if)#int lo20
R1(config-if)# add 172.16.10.20 255.255.255.0
R1(config-if)#int lo30
R1(config-if)# add 172.16.10.30 255.255.255.0
R1(config-router)#int e0/0
R1(config-if)#ip summary-address rip 172.16.0.0 255.255.255.0 # 手动
  • rip路由汇总,尽量位数从不一样的地方精准匹配,避免负载均衡现象

链路状态协议

最短短路径优先协议ospf

  • ospf拓扑

![Q7A%GQ93{BV4{5$QIN~TK5.png](https://img-blog.csdnimg.cn/img_convert/e0107b56dfeaaa548e945acd1dedc069.png#averageHue=#7fd569&clientId=u2fbd5c93-c872-4&from=paste&height=253&id=u3bee3a9e&name=Q7A%GQ93{BV4{5$QIN~TK5.png&originHeight=379&originWidth=1204&originalType=binary&ratio=1&rotation=0&showTitle=false&size=45351&status=done&style=none&taskId=uffe71d59-0fd7-4ff2-a163-ad1e5530919&title=&width=802.6666666666666)

配置命令

# 配置ip地址,必须配环回接口#配置ospf
方式一
R1(config)#router ospf 1
R1(config-router)#network 1.0.0.0 0.0.0.255 area 0
建议,方式二
R2(config)#int range e0/0-1,lo0
R2(config-if-range)#ip ospf 1 area 0

路由重发概念

  • 将不同的两个自治系统之间的路由信息,进行交换,使得相互能学习到不同的路由信息

配置命令

做双向重发步
R4(config-if-range)#router rip
R4(config-router)#ver 2
R4(config-router)#redistribute ospf 1 metric 5
R4(config-router)#router ospf 1
R4(config-router)#redistribute rip subnets


OSPF三张表

  • 邻居表记录了邻居的状态,死亡倒计时,接口信息等
  • 路由表记录了路由条目,子网掩码,网络号,接口信息,下一跳地址,管理距离,度量值等
  • 链路状态数据库:列出网络中其他路由器的信息,由此显示了全网的网络拓扑
R2#sh ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:00:32    192.168.23.3    Ethernet0/1
1.1.1.1           1   FULL/BDR        00:00:39    192.168.12.1    Ethernet0/0

  • Neighbor ID:邻居ID,通常由route-id决定,选取环回接口大的地址作为route-id,不建议手动改route-id
  • pri:优先级
  • state:邻居的状态
    • DR:DR的作用:多路访问中为了减少邻接关系(N平方的问题)和LSA的洪泛,采用DR机制,BDR提供了备份
    • MA网络上的所有路由器均与DR、BDR建立邻居关系
    • BDR:DR的备份
  • 选举规则
    • 接口优先级数字越大越优先(优先级为0不能参与DR的选举)
    • Router ID越大越好
    • 稳定压倒一切(非抢占)
    • 通过控制接口优先级是控制DR选举的好办法
    • DR的选举是基于接口的,如果说某个路由器是DR,这种说法是错误的

  • OSPF COST
    • OSPF接口COST=参考带宽(10的8次方,单位为b)/ 接口带宽
    • 接口带宽为接口逻辑带宽,可以使用bandwith命令调整(这里默认单位为kb),主要用于路由计算,而不是接口物理带宽,但一般情况:接口逻辑带宽=接口物理带宽。
  • 修改cost值
R1(config)#int e0/0
R1(config-if)#ip ospf cost 100
R1(config-if)#R1(config-if)#bandwidth 100  #单位kb
  • 修改之前

image.png

  • 修改之后

image.png


常用的命令

R1(config-if)#do sh ip route * 
R1(config)#do clear ip ospf process
R1(config)#R1(config)#do show ip interface brief 
R1(config)#do sh ip route   ospf 
R1(config)#do sh ip arp 
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.12.1            -   aabb.cc00.1000  ARPA   Ethernet0/0
Internet  192.168.12.2           79   aabb.cc00.2000  ARPA   Ethernet0/0

多区域基本拓扑

![UKaTeX parse error: Expected 'EOF', got '#' at position 104: …5c7abd46d0a.png#̲averageHue=#83d…X6HYL7N7L`EUS6IK9I@AR.png&originHeight=599&originWidth=976&originalType=binary&ratio=1&rotation=0&showTitle=false&size=79751&status=done&style=none&taskId=ucece0483-1a9e-4685-b52b-53cfb535efd&title=&width=650.6666666666666)

区域配置

  • 当非骨干区域没有和骨干区域直接相连,无法学习到其他区域的路由,如何解决这个问题
  • 第一种方式是使用虚链路,相当于R3和R4建立了邻居
R3(config)#router ospf 1
R3(config-router)#area 2 virtual-link 4.4.4.4
R4(config)#router ospf 1
R4(config-router)#area 2 virtual-link 3.3.3.3

R4#sh ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/  -           -        192.168.34.3    OSPF_VL0
3.3.3.3           1   FULL/BDR        00:00:34    192.168.34.3    Ethernet0/0
6.6.6.6           1   FULL/DR         00:00:33    192.168.46.6    Ethernet0/1
  • 第二种是通过隧道的方式
1(config-if)#int Tunnel 0                      
R1(config-if)#ip add 192.168.100.1 255.255.255.0
R1(config-if)#ip ospf 1 area 0
R1(config-if)#tunnel source e0/0
R1(config-if)#tunnel mod ipip 
R1(config-if)#tunnel destination 192.168.12.2


R2(config-if)#int Tunnel 0 
R2(config-if)#ip add 192.168.100.2 255.255.255.0
R2(config-if)#ip ospf 1 area 0
R2(config-if)#tunnel source e0/1
R2(config-if)#tunnel mode ipip
R2(config-if)#tunnel destination 192.168.12.1

R2#sh ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           0   FULL/  -        00:00:34    192.168.100.1   Tunnel0
3.3.3.3           1   FULL/BDR        00:00:34    192.168.23.3    Ethernet0/0
1.1.1.1           1   FULL/BDR        00:00:38    192.168.12.1    Ethernet0/1
R2#

LSA类型

实验拓扑
![TCAS3_R}VEILM3QU5%ORFN.png

  • LSA1
    • 只在区域内洪范,不会在本区域外洪范
    • 每个路由器都会产生
    • 通知的内容是本地链路状态信息
R4#sh ip ospf database

            OSPF Router with ID (4.4.4.4) (Process ID 1)

		Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
3.3.3.3         3.3.3.3         10          0x80000003 0x00498C 2
4.4.4.4         4.4.4.4         0           0x80000003 0x00398F 2

  • LSA2
    • 只在区域内洪范
    • 由DR产生
    • 通知多条网络信息
		Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.34.4    4.4.4.4         13          0x80000001 0x00F489
R3#sh ip ospf database network 

            OSPF Router with ID (3.3.3.3) (Process ID 1)

		Net Link States (Area 0)

  LS age: 30
  Options: (No TOS-capability, DC)
  LS Type: Network Links
  Link State ID: 192.168.34.4 (address of Designated Router)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0xF489
  Length: 32
  Network Mask: /24
	Attached Router: 4.4.4.4
	Attached Router: 3.3.3.3
	Net Link States (Area 2)

  LS age: 884
  Options: (No TOS-capability, DC)
  LS Type: Network Links
  Link State ID: 192.168.45.4 (address of Designated Router)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0xDF8B
  Length: 32
  Network Mask: /24
        Attached Router: 4.4.4.4
        Attached Router: 5.5.5.5
          
  LS age: 824
  Options: (No TOS-capability, DC)
  LS Type: Network Links
  Link State ID: 192.168.46.4 (address of Designated Router)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0x75F
  Length: 32
  Network Mask: /24
        Attached Router: 4.4.4.4
        Attached Router: 6.6.6.6

  • LSA3
    • 由ABR产生
    • 可以通告其他区域中
    • 区域内LSA1和LSA2的汇总
		Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
3.3.3.3         3.3.3.3         13          0x80000003 0x00AA77
4.4.4.4         3.3.3.3         13          0x80000003 0x00E033
5.5.5.5         3.3.3.3         1555        0x80000001 0x001BEC
6.6.6.6         3.3.3.3         1495        0x80000001 0x00EC17
192.168.34.0    3.3.3.3         13          0x80000003 0x006633
192.168.45.0    3.3.3.3         1791        0x80000001 0x005531
192.168.46.0    3.3.3.3         1791        0x80000001 0x004A3B

  • LSA4
    • 由ABR产生
    • 可以跨边界进行洪范
    • 到达的ASBR信息
              Summary ASB Link States (Area 2)
          
Link ID         ADV Router      Age         Seq#       Checksum
1.1.1.1         4.4.4.4         528         0x80000001 0x009D76
          


R6#sh ip ospf database asbr-summary 

            OSPF Router with ID (6.6.6.6) (Process ID 1)

		Summary ASB Link States (Area 2)

  LS age: 694
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 1.1.1.1 (AS Boundary Router address)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0x9D76
  Length: 28
  Network Mask: /0
	MTID: 0 	Metric: 20 

  • LSA5
    • 由ASBR产生
    • 可以跨区洪范
    • 描述外部路由的链路状态
                Type-5 AS External Link States
          
Link ID         ADV Router      Age         Seq#       Checksum Tag
172.16.10.0     1.1.1.1         715         0x80000002 0x00D301 0

R6#sh ip ospf database external 

            OSPF Router with ID (6.6.6.6) (Process ID 1)

		Type-5 AS External Link States

  LS age: 850
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 172.16.10.0 (External Network Number )
  Advertising Router: 1.1.1.1
  LS Seq Number: 80000002
  Checksum: 0xD301
  Length: 36
  Network Mask: /24
	Metric Type: 2 (Larger than any link state path)
	MTID: 0 
	Metric: 20 
	Forward Address: 0.0.0.0
	External Route Tag: 0

特殊区域

stub area

  • 随着大量的5类LSA进入ospf区域,OSPF Database会变得庞大,同时路由表的外部地址也会增

大。这会占用路由器大量的资源。

  • 解决这个问题的办法是:让Area内部的路由器不记录任何AS外部的地址,而使用ABR作为默认网

关,有一条指向ABR的默认路由。

router ospf 1
area 2 stub

配置前的路由条目
image.png

  • 配置后精简了许多

image.png

totally stub area

  • 以连ospf的其他区域的路由也不学习
  • 只学习本区域的路由,以及有一条指向ABR的默认路由
  • area 2 stub no-summary

image.png

NSSA area

  • 当我们把区域配置成末梢区域时,有时候有特例想要加入一些外部路由,这个时候nssa允许存在ASBR通过7类LSA的方式将外部路由引入本区域,不会自动注入默认路由
  • 不会学习外部路由
  • 会学习其他区域路由
  • 可以学习ASBR注入的外部路由
  • 没有注入默认路由
  • 配置
  • 在区域内所有路由器配置以下命令
    • router ospf 1
    • area 1 nssa

配置NSSA后的路由表,配置之前学习不到100.100.100.100
image.png

Totally NSSA area

  • 不会学习外部路由
  • 不会学习其他区域路由
  • 可以学习ASBR注入的外部路由
  • 会自动注入默认路由

配置:与nssa不同的是在ABR上配置以下命令

router ospf 1
area 1 nssa no-summary

image.png

点对点配置

R4(config-router)#int e0/0
R4(config-if)#ip ospf network point-to-point

默认路由

  • 由出口路由统一下发网关
  • 配置
router ospf 1
default-information originate always metric-type [宣告类型] metric [度量值]
  • 类型1是会累加ospf内部开销,类型2不会累加内部开销
R7(config)#route 0.0.0.0 0.0.0.0 192.168.136.2
R7(config)#int range e0/0-1
R7(config-if-range)#ip nat inside 
Nov 30 05:03:00.655: %LINEPROTO-5-UPDOWN: Line protocol on Interface NVI0, changed state to up
R7(config-if-range)#int e0/2
R7(config-if)#ip nat outside 
R7(config)#access-list 1 permit ?
  Hostname or A.B.C.D  Address to match
  any                  Any source host
  host                 A single host address

R7(config)#access-list 1 permit 0.0.0.0 0.0.0.0
R7(config)#ip nat source list 1 interface e0/2 overload 

路由汇总

针对OSPF区域内进行汇总

image.png

  • R2 R3在区域0, R4在区域1
  • R4 上有三个环回接口地址为10.1.x.1/24, 并且将他们加入到ospf当中
R4(config-router)#int range lo10,lo20,lo30
R4(config-if-range)#ip ospf 1 area 1   
  • 汇总命令在ABR
R3(config)# router ospf 1  
R3(config-router)# area 1 range 10.1.0.0 255.255.0.0  

针对外部区域进行汇总

  • 在R1上有三个环回接口地址为172.16.x.x/24,并且通过重发布的方式引入外部路由
  • 汇总命令在ASBR上配置

配置
router ospf 1
summary-address 172.16.0.0 255.255.0.0
image.png

抑制区域内部路由明细

  • 有时候内部的一些隐私的服务器或者设备并不希望被其他区域学习到,则可以使用抑制路由明细的方式
  • 配置在ABR上
R3(config-if)#router ospf 1
R3(config-router)#area 1 range 40.40.40.40 255.255.255.255  not-advertise

抑制外部区域路由明细

  • 在外部路由上配置
router ospf 1
summary-address 50.50.50.0 255.255.255.0 not-advertise 

安全认证

  • 因为接口是暴露在外部的,当他人和接口建立邻居的时候,就能进行下发默认网关等危险的操作
  • 因此,该接口可以配置为不允许建立邻居状态
router ospf 1
passive-interface 接口

身份验证

接口认证

  • 需要进行身份验证的接口彼此都需要配置了相同的身份验证才可以通过
如果只配好了一边的接口,另一边接口没有配置,则没有办法成功建立邻居
R1(config)#int e0/0
R1(config-if)#ip ospf authentication message-digest
R1(config-if)#ip ospf message-digest-key 1 md5 cisco

R2(config)#int e0/0
R2(config-if)#ip ospf authentication message-digest
R2(config-if)#ip ospf message-digest-key 1 md5 cisco

区域认证

  • 区域内所有接口都需要配置接口认证,没有配置的接口不能通过身份验证
  • 配置
R3(config)#router ospf 1
R3(config-router)#area 1 authentication message-digest
R3(config-router)#int e0/1
R3(config-if)#ip ospf message-digest-key 2 md5 cisco

R4(config)#router ospf 1
R4(config-router)#area 1 authentication message-digest
R4(config-router)#int e0/0
R4(config-if)#ip ospf message-digest-key 2 md5 cisco

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值