实验目标:

静态路由的有类和无类查找(实验)_有类

基本配置

R1

!
hostname R1
!
no ip domain lookup
!
interface Serial1/0
 ip address 12.1.1.1 255.255.255.0
!     
ip classless
!     
line con 0
 exec-timeout 0 0
 logging synchronous
!

R2

!
hostname R2
!
no ip domain lookup
!
interface Loopback0
 ip address 2.3.3.3 255.255.255.0 secondary
 ip address 3.3.3.3 255.255.255.0 secondary
 ip address 2.1.1.1 255.255.255.0 secondary
 ip address 2.2.2.2 255.255.255.0          
!     
interface Serial2/0
 ip address 12.1.1.2 255.255.255.0
!           
ip classless
!     
line con 0
 exec-timeout 0 0
 logging synchronous
!


如上配置,已经将基本的地址信息配置完成,下面将配置静态路由


R1(config)#ip route 0.0.0.0 0.0.0.0 s1/0 12.1.1.2 默认路由

R1(config)#ip route 2.2.2.0 255.255.255.0 s1/0 12.1.1.2

第一无类查找

批注:路由器接口默认是无类路由


ip classless (无类)

验证:

R1#show ip route

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 [1/0] via 12.1.1.2, Serial1/0

12.0.0.0/24 is subnetted, 1 subnets

C 12.1.1.0 is directly connected, Serial1/0

S* 0.0.0.0/0 [1/0] via 12.1.1.2, Serial1/0

R2#show ip route

2.0.0.0/24 is subnetted, 3 subnets

C 2.1.1.0 is directly connected, Loopback0

C 2.2.2.0 is directly connected, Loopback0

C 2.3.3.0 is directly connected, Loopback0

3.0.0.0/24 is subnetted,1subnets

C 3.3.3.0 is directly connected, Loopback0

12.0.0.0/24 is subnetted, 1 subnets

C 12.1.1.0 is directly connected, Serial1/1

R1#ping 2.2.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 2.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (0/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 2.3.3.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 3.3.3.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms

第二有类查找

批注:路由器接口默认是无类路由,所以应将路由器改为有类


no ip classless(有类)


R1(config)#no ip classless

R2(config)#no ip classless


验证:

R1#show ip route

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 [1/0] via 12.1.1.2, Serial1/0

12.0.0.0/24 is subnetted, 1 subnets

C 12.1.1.0 is directly connected, Serial1/0

S* 0.0.0.0/0 [1/0] via 12.1.1.2, Serial1/0

R2#show ip route

2.0.0.0/24 is subnetted, 3 subnets

C 2.1.1.0 is directly connected, Loopback0

C 2.2.2.0 is directly connected, Loopback0

C 2.3.3.0 is directly connected, Loopback0

3.0.0.0/24 is subnetted, 1 subnets

C 3.3.3.0 is directly connected, Loopback0

12.0.0.0/24 is subnetted, 1 subnets

C 12.1.1.0 is directly connected, Serial1/1

R1#ping 2.2.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 2.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

…..

Success rate is 100 percent (0/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 2.3.3.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

…..

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms

R1#ping 3.3.3.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/76 ms


按照无类路由的查找原则从R1 ,ping R2上环回口都应该是通的,反观有类路由,只有ping R2上的环回口2.2.2.2 和3.3.3.3是通的。因为按照有类路由的查找原则,首先看该路由是否有类路由,是有类路由,再去匹配主网位,不匹配,再去匹配默认路由,默认路由匹配转发,默认路由不匹配丢弃,反观如主网位匹配,再匹配子网位,子网位匹配转发,子网位不匹配丢弃。具体路径参照下图:

静态路由的有类和无类查找(实验)_有类_02