Sokáig nem volt számomra egyértelmű a címben szereplő parancs – soha nem használtam, miért is jó?
Feldobtam GNS3-ba az alábbi topológiát:
Teljesen egyszerű, egy OSPF Area, de a parancs elmagyarázására tökéletes!
R1#sh run Building configuration... Current configuration : 1041 bytes ! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model memory-size iomem 5 ip cef ! ! ! ! no ip domain lookup ! multilink bundle-name authenticated ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! archive log config hidekeys ! ! ! ! ! ! ! ! interface Loopback1 ip address 1.1.1.1 255.255.255.0 ip ospf network point-to-point ! interface FastEthernet0/0 no ip address shutdown duplex auto speed auto ! interface Serial0/0 ip address 10.0.12.1 255.255.255.0 clock rate 2000000 ! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto ! interface Serial0/1 no ip address shutdown clock rate 2000000 ! router ospf 1 log-adjacency-changes network 10.0.12.0 0.0.0.255 area 0 network 1.1.1.1 0.0.0.0 area 0 ! ip forward-protocol nd ! ! no ip http server no ip http secure-server ! ! ! ! ! ! ! control-plane ! ! ! ! ! ! ! ! ! ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 ! ! end
R2#sh run Building configuration... Current configuration : 1225 bytes ! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model memory-size iomem 5 ip cef ! ! ! ! no ip domain lookup ! multilink bundle-name authenticated ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! archive log config hidekeys ! ! ! ! ! ! ! ! interface Loopback0 ip address 2.2.2.2 255.255.255.0 ip ospf network point-to-point ! interface Loopback1 ip address 2.2.3.2 255.255.255.0 ip ospf network point-to-point ! interface FastEthernet0/0 no ip address shutdown duplex auto speed auto ! interface Serial0/0 ip address 10.0.12.2 255.255.255.0 clock rate 2000000 ! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto ! interface Serial0/1 no ip address shutdown clock rate 2000000 ! router ospf 1 log-adjacency-changes network 2.2.2.2 0.0.0.0 area 0 network 2.2.2.3 0.0.0.0 area 0 network 2.2.3.2 0.0.0.0 area 0 network 10.0.12.0 0.0.0.255 area 0 ! ip forward-protocol nd ! ! no ip http server no ip http secure-server ! ! ! ! ! ! ! control-plane ! ! ! ! ! ! ! ! ! ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 ! ! end
Nézzük összeállt -e a neighborship, és minden szükséges interface-n engedélyezve vannak-e az OSPF Hello-k:
R1#sh ip ospf int b Interface PID Area IP Address/Mask Cost State Nbrs F/C Lo1 1 0 1.1.1.1/24 1 P2P 0/0 Se0/0 1 0 10.0.12.1/24 64 P2P 1/1 R1#sh ip ospf int b Interface PID Area IP Address/Mask Cost State Nbrs F/C Lo1 1 0 1.1.1.1/24 1 P2P 0/0 Se0/0 1 0 10.0.12.1/24 64 P2P 1/1 R1#sh ip ospf ne Neighbor ID Pri State Dead Time Address Interface 2.2.3.2 0 FULL/ - 00:00:32 10.0.12.2 Serial0/0 R2#sh ip ospf ne Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 0 FULL/ - 00:00:32 10.0.12.1 Serial0/0 R2#sh ip ospf int b Interface PID Area IP Address/Mask Cost State Nbrs F/C Lo1 1 0 2.2.3.2/24 1 P2P 0/0 Lo0 1 0 2.2.2.2/24 1 P2P 0/0 Se0/0 1 0 10.0.12.2/24 64 P2P 1/1
És akkor most jöjjön a címben szereplő parancs.
A megértéshez fontos, hogy az IP cím és a subnet mask között logikai ÉS van, ebből lesz ugyebár a subnet number (CCENT-ben volt téma). A show ip route parancsnál is AND művelet van, ezért kapjuk ezt a kimenetet:
R1#show ip route 2.2.0.0 255.255.0.0 % Subnet not in table
A 2.2.0.0/16 nincs a route táblában. Nézzük longer-prefix-szel:
R1#show ip route 2.2.0.0 255.255.0.0 longer-pref Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set 2.0.0.0/24 is subnetted, 2 subnets O 2.2.2.0 [110/65] via 10.0.12.2, 00:05:56, Serial0/0 O 2.2.3.0 [110/65] via 10.0.12.2, 00:05:01, Serial0/0
A longer prefix jelentése tehát: minden olyan route-t listáz, amely 2.2.0.0/16 és annál “nagyobb” (subnet mask nagyobb). Ez a parancs hasznos lehet például route summarization-nél és TSHOOT-nál.