使用有类路由:路由器首先匹配主网络号,如果主网络号存在,就继续匹配子网号,且不考虑缺省路由,如果子网无法匹配,丢弃数据包(在分类路由下,路由器认为知道所有主网络下的全部子网),并使用ICMP返回一个不可达回应。如果主网络号不存在,使用缺省路由(缺省路由存在前提)。

  上述情况出现在某些早期IOS版本里(12.0以前版本),这些早期版本默认没有打开ip classless.

  打开ip classless以后将改变路由器的路由行为,此时路由器将进行最长最精确匹配或使用默认路由进行匹配

  使用无类路由,如果没有找到最具体的匹配,就使用缺省路由。

  ip classless命令的作用主要是改变有类路由协议的查找路由表的行为。

  例1:某路由器上运行的路由协议为RIP(有类的路由协议),路由表如下:

  R 10.1.0.0/16 via 1.1.1.1

  R 10.2.0.0/26 via 1.1.1.2

  R* 0.0.0.0/0 via 1.1.1.3

  现在假设有3个IP报文,报文A的目标IP是10.1.1.1、报文B的目标IP是10.3.1.1、报文C的目标IP是11.11.1.1

  有类路由协议查找路由表的行为如下:

  首先查找目标IP所在的主网络,若路由表中有该主网络的任何一个子网路由的话,就必须精确匹配其中的子网路由;如果没有找到精确匹配的子网路由,它不会选择最后的缺省路由,而是丢弃报文。若路由表中不存在该主网络的任何一个子网路由,则最终选择缺省路由。

  报文A:目标IP为10.1.1.1,所在的主网络为10.0.0.0,目前的路由表中存在10.0.0.0的子网路由,此时路由器要进一步查找子网路由,是否能够精确匹配,我们看到10.1.0.0/16可以匹配我们的目标地址,所以报文A根据这条路由进行转发。

  报文B:目标IP为10.3.1.1,所在的主网络为10.0.0.0,目前的路由表中存在10.0.0.0的子网路由,此时路由器要进一步查找子网路由,是否能够精确匹配,我们看到路由表中的两条子网路由10.1.0.0/16和10.2.0.0/16均不能匹配我们的目标地址,根据有类路由协议的原则,它不会选择缺省路由,所以报文B被路由器丢弃。

  报文C:目标IP为11.1.1.1,所在的主网络为11.0.0.0,目前的路由表中不存在11.0.0.0的子网路由,此时路由器直接采用缺省路由,所以路由器采用缺省路由对报文C进行转发。

  上面的结果是有类路由协议查找路由的行为,而配置ip classless的目的就是改变它的这种行为,配置完该命令后查找路由的行为是根据最长匹配的原则,那上例中的报文B就可以通过缺省路由进行转发了。

  注意:该命令对于一个无类路由协议来说没有任何意义,因为无类路由协议查找路由的方式就是最长匹配的原则

原文出自【比特网】,转载请保留原文链接:http://network.chinabyte.com/318/8620818.shtml

note:

1) what will be in the Route Table?

To understand the kind of information that exists in the route table, it is useful to begin with an examination of what happens when a framed packet arrives at one of a router's interfaces. The data-link identifier in the frame's destination address field is examined. If it contains either the identifier of the router's interface or a broadcast identifier, the router strips off the frame and passes the enclosed packet to the network layer. At the network layer, the destination address of the packet is examined. If the destination address is either the IP address of the router's interface or an all-hosts broadcast address, the protocol field of the packet is examined and the enclosed data is sent to the appropriate internal process. [1]

[1] There is also the special case of a multicast address, which is destined for a group of devices, but not for all devices. An example of a multicast address is the class D address 224.0.0.5, reserved for all OSPF-speaking routers.

Any other destination address calls for routing. The address may be for a host on another network to which the router is attached (including the router interface attached to that network) or for a host on a network not directly connected to the router. The address may also be a directed broadcast, in which there is a distinct network or subnet address, and the remaining host bits are all ones. These addresses are also routable.

If the packet is to be routed, the router will do a route table lookup to acquire the correct route. At a minimum, each route entry in the database must contain two items:

  • A destination address. This is the address of the network the router can reach. As this chapter explains, the router may have more than one route to the same address and/or a group of subnets of the same or of varying lengths grouped under the same major IP network address.

  • A pointer to the destination. This pointer either will indicate that the destination network is directly connected to the router or it will indicate the address of another router on a directly connected network. That router, which will be one router hop closer to the destination, is a next-hop router.

The router will match the most specific address it can.[2] In descending order of specificity, the address may be one of the following:

[2] There are two basic procedures for finding the best match, depending upon whether the router is behaving classfully or classlessly. Classful table lookups are explained in more detail in Chapter 5, "Routing Information Protocol (RIP),"and classless table lookups are explained in Chapter 7, "Routing Information Protocol Version 2."

  • A host address (a host route)

  • A subnet

  • A group of subnets (a summary route)

  • A major network number

  • A group of major network numbers (a supernet)

  • A default address

This chapter provides examples of the first four types. Supernets are covered in Chapter 7, "Routing Information Protocol Version 2." A default address is considered a least-specific address and is matched only if no other match can be found. Default addressing is the topic ofChapter 12, "Default Routes and On-Demand Routing."

If the destination address of the packet cannot be matched to any route table entry, the packet is dropped and a Destination Unreachable ICMP message is sent to the source address.

2)Extracted from "Operation of RIP" in the Chapter 5 of Routing TCP/IP

There is no provision for RIP to advertise a subnet mask along with each route entry. (i.e. RIP message format has no subnet mask)

First, the network portion of the destination address is read and the routing table is consulted for a match. It is this first step of reading the major class A, B, or C network number that defines a classful routing table lookup. If there is no match for the major network, the packet is dropped and an ICMP Destination Unreachable message is sent to the packet's source. If there is a match for the network portion, the subnets listed for that network are examined. If a match can be found, the packet is routed. If a match cannot be made, the packet is dropped and a Destination Unreachable message is sent.

The router's only recourse is to assume that the mask configured on one of its interfaces attached to 172.25.0.0 is used consistently throughout the internetwork. It will use its own mask for 172.25.0.0 to derive the subnet of the destination address. As the routing tables throughout this chapter illustrate, a router that is directly connected to a network will list the network in a heading along with the subnet mask of the connecting interface and will then list all the known subnets of the network. If the network is not directly connected, there is a listing only for the major-class network and no associated mask.

Because the destination addresses of packets being routed by a classful routing protocol are interpreted according to the subnet masks locally configured on the router's interfaces, all subnet masks within a major, class-level network must be consistent

Classful Routing: Summary

The defining characteristic of a classful routing protocol is that it does not advertise an address mask along with the advertised destination address. Therefore, a classful routing protocol must first match the major class A, B, or C network portion of a destination address. For every packet passing through the router:

  1. If the destination address is a member of a directly connected major network, the subnet mask configured on the interface attached to that network will be used to determine the subnet of the destination address. Therefore, the same subnet mask must be used consistently throughout that major network.

  2. If the destination address is not a member of a directly connected major network, the router will try to match only the major class A, B, or C portion of the destination address.

3)

有类路由 汇总以后 地址是标准的A B C类地址掩码 即 255.0.0.0 255.255.0.0 255.255.255.0
无类路由 汇总以后 地址是无类的 比如 172.16.12.0/16 - 172.16.15.0/16 汇总以后的地址是172.16.12.0/20 子码 不属于 A B C 3个类别

转载于:https://www.cnblogs.com/xiaoerlang/p/3323650.html

有类与无类路由下的路由匹配原则(转载)相关推荐

  1. 有类和无类路由下的路由匹配原则

    有类和无类路由下的路由匹配原则 使用有类路由:路由器首先匹配主网络号,如果主网络号存在,就继续匹配子网号,且不考虑缺省路由,如果子网 无法匹配,丢弃数据包(在分类路由下,路由器认为知道所有主网络下的全 ...

  2. 路由协议有类和无类的区别

    最近看到RIP和OSPF方面了.这两个协议在NA里面被划分为距离矢量路由协议和链路状态路由协议.但是在NP里面划分路由又有种方法是基于有类的路由协议和无类的路由协议.   RIP正是基于有类的路由协议 ...

  3. ipv6寻址_有类和无类寻址:IPV4寻址| 计算机网络

    ipv6寻址 1)分类寻址 (1) Classful Addressing) IPv4 addressing used the concept of classes. This architectur ...

  4. 关于有类路由协议和无类路由协议

    有类路由协议: RIPv1,IGRP 无类路由协议:RIPv2,EIGRP,OSPF,IS-IS,BGP 有类路由协议在主类边界路由器上自动汇总:(抛开接口谈网络都是扯淡) (1) 对于相同主类网络的 ...

  5. 如何实现两个路由下的电脑互相访问

    如何实现两个路由下的电脑互相访问 转载于:https://blog.51cto.com/10471763/1716901

  6. 有类路由和无类路由的深入理解

    1.1 有类路由的特点 1.2 有类路由协议发送规则 1.3 有类路由协议更新接收规则  1.4 有类路由协议的特性 2.1 无类路由协议特点 2.2 无类路由协议的特性 3.1 总结与案例理解 1. ...

  7. 路由有类查找和无类查找方式

    有类路由器查找方式   第一步:首先查看路由表或FIB表,是否有对应的ABC类主网路由条目, 有对应主网路由条目,则继续判断该主网是否有对应子网,如果没有匹配的 子网路由,则报文丢弃.即使有缺省路由也 ...

  8. 有类路由与无类路由的区别

    最近看到RIP和OSPF方面了.这两个协议在NA里面被划分为距离矢量路由协议和链路状态路由协议.但是在NP里面划分路由又有种方法是基于有类的路由协议和无类的路由协议. RIP正是基于有类的路由协议,O ...

  9. php自动加载类与路由,PHP实现路由和类自动加载

    这次给大家带来PHP实现路由和类自动加载,PHP实现路由和类自动加载的注意事项有哪些,下面就是实战案例,一起来看一下. 项目目录如下 入口文件index.php<?php define('WEB ...

  10. Linux内核TC工具链路带宽设计--无类队列规定

    Linux 内核的 TC(traffic control)工具可以用来对网络带宽做一定的设计和管理,这里将对这一工具的使用做一定的介绍,在正式开始介绍TC 之前,先对一些基本的单位做一个说明.为了避免 ...

最新文章

  1. java.lang.RuntimeException: Handler (com.***.behavior.BEvent$1) {421bca80} sending message to a Hand
  2. linux定时任务的设置
  3. Java stackoverflowerror异常与outofmemoryerror异常区别
  4. python opencv图片放大 缩小_Python OpenCV之图片缩放的实现(cv2.resize)
  5. Linux进阶之路————用户管理
  6. live555 linux编译静态库,【Live555】liveMedia下载、配置、编译、安装、基本概念
  7. 性能测试学习09_场景设计(一)
  8. STM32定时器输出pwm波
  9. 电视端Android TV应用移植开发常见问题QA-Android TV 应用开发
  10. UE4学习笔记----点光源属性
  11. Hexo+Github免费搭建个人博客+美化详细教程
  12. openGL基础光照“ADS”( Phone光照模型)(一)
  13. 物理层-计算机网络知识汇总(二)|Zam9036博客
  14. 2018个人年度总结:我是如何从嵌入式开发到服务器开发对接天猫精灵、小爱智能音箱服务器!懵懂 | 奋斗 | 进阶 | 信心
  15. 【开发经验】md自动上传图片
  16. 爱普生Epson LQ-680K 打印机驱动
  17. 全国大学生软件测试大赛指南
  18. 利用Python进行市场购物篮分析——入门篇
  19. oracle数据库资源高,~Oracle后台进程占用资源过高可能会是什么原因?
  20. 基于微信小程序的在线考试系统源码

热门文章

  1. 苹果手机换电池对手机有影响吗_网上预约手机上门换电池可靠吗?官方回应:售后也这么换!...
  2. 苹果6更换电池注意事项
  3. php yaf twig,GitHub - cheerego/happy_yaf: 搭建一个可用的Yaf,包括Laravel的Eloquent ORM、Twig、脚手架、Whoops和使用用例...
  4. 30天自制操作系统 第2天
  5. Copy ‘xxx‘ to effectively final temp variable 问题解决
  6. final 和effectively final区别
  7. Windows11 21H2 专业版 64位 v2022 【全新装机】
  8. 废弃军舰回收站、废铁回炉重造
  9. 百度SEO站群WeLive免费在线客服系统 v5
  10. RAITE Hypervisor介绍