ip classless和no ip classless的对待默认路由的区别

转载:http://blog.163.com/s_u/blog/static/1330836720106162505948/
例子:
R3(config)#no ip classless

R3#show ip route

<cut>
Gateway of last resort is 168.13.1.101 to network 0.0.0.0
168.13.0.0/24 is subnetted, 4 subnets
168.13.1.0 [120/1] via 168.13.100.1, 00:00:13, Serial0/1
168.13.3.0 is directly connected, Ethernet0
168.13.2.0 [120/1] via 168.13.100.2, 00:00:06, Serial0/1
168.13.100.0 is directly connected, Serial0.1
S*  0.0.0.0/0 [1/0] via 168.13.1.101

先来:ping 10.1.1.1
R3#ping  10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 84/89/114 ms

R3#

再来:ping 168.13.200.1

R3#ping  168.13.200.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 168.13.200.1, timeout is 2 seconds:
...
Success rate is 0 percent (0/5)


相反:

R3(config)# ip classless
R3#ping  10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 84/89/114 ms

R3#

再来:ping 168.13.200.1
R3#ping  168.13.200.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 168.13.200.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 80/88/112ms


这是为什么呢?
原因如下:ip classless开启无类别路由,当ip classless命令关闭时, 路由器在查询路由时只看路由表中的主类条目。
Cisco早期的IOS是缺省关闭该命令的,这也是为什么cisco路由器的路由表中一直会有诸如以下条目出现的原因
1.0.0.0/32 is subnetted, 1 subnets
1.1.1.1 is directly connected, Loopback0
172.30.0.0/24 is subnetted, 1 subnets
172.30.1.0 is directly connected, Ethernet0

其实不管是否开启ip classless,Cisco路由表一直会有类似于“172.30.0.0/24 is subnetted, 1 subnets”的主类条目,它显示该 网络被24位的掩码进行子网划分(然后再列出具体的子网),这是因为Cisco软件早期是将IPv4子网分类别对待的。(那个时候,查询路由只看主类号,不看具体子网号)。所以在ping 168.13.200.1的时候,路由器发现它是b类网络的,属于168.13.0.0网段,接着,到此网段范围之内去查找路由,最后发现找不到匹配的。然后就丢弃!所以ping不通。然而,在ping  10.1.1.1的时候,路由器发现它是属于A类网络的,然后查找路由表,没有找到A类网络的条目,于是就把它交给默认路由处理!
后来开启ip classless,cisco路由器才将IPv4视为无类别的,在查找路由时,会比较子网号。往下找,若找不到,就会使用默认路由。

即关闭ip classless后,首先找的自己隶属的标准ABC类网段,有两种情况:

1。若找到自己隶属的标准网段的话,然后就局限于此标准网段,看里边是否有符合自己的,符合则成功,不符则抛弃。不会再往下找了,也不会用默认路由。
2。找不到自己隶属的标准网段,就会去使用默认路由。(当然,假设默认路由是存在的)

IE试题:

Refer to the exhibit. This exhibit shows the NAT configuration for Router A and the output for a ping issued from device 171.68.200.48 and destined to 172.16.47.142. Based on this information, what change must be made to Router A in order for the ping to work?

ip classless和no ip classless的对待默认路由的区别 - suy - Suy的博客

A. reload the router

B. clear the route cache

C. add a static route

D. configure IP as classless

E. load a newer IOS image

解:看图中路由设置,因为关掉了ip classless ,所以路由器做数据转发的时候会只查找主网络,没有找到也不会按照默认路由来走,另外一点观察最后的debug信息,会看到出去的数据包提示unroutabal

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值