Routing dynamiczny - Wydział Elektryczny
Transkrypt
Routing dynamiczny - Wydział Elektryczny
Politechnika Warszawska – Wydział elektryczny LABORATORIUM SIECI KOMPUTEROWYCH ĆWICZENIE: „Routing dynamiczny” Autor: Michał Radzki Wstęp Celem ćwiczenia jest zapoznanie się z protokołami routingu dynamicznego – RIP v2, oraz OSPF. Teoria: Co to jest routing dynamiczny? W routingu statycznym administrator musiał wszystkie adresy w sieci wpisywać ręcznie. Przy dużej liczbie urządzeń sieciowych zadanie to zajmie wiele godzin... Dlatego wymyślono routing dynamiczny. Protokoły routingu dynamicznego są technologią, która umożliwia routerom: odkrywanie i utrzymywanie tras, połączeń, rozpoznawanie topologii sieci oraz parametrów połączeń, które wykorzystywane są do obliczenia i wyznaczenia tras i ich kosztów. W celu wymiany informacji pomiędzy routerami wykorzystywane są specjalne komunikaty przenoszące informacje o zmianach w sieci. Ich treść w zależności od sytuacji to całkowita zawartość tablicy routingu lub jej fragment. Podsumowując routery dzięki dynamicznym protokołom uczą się od siebie adresów sieci i przekazują sobie automatycznie zachodzące w niej zmiany. Wyróżniamy dwie podstawowe klasy routingu dynamicznego: distance vector (wektor odległości), oraz link-state (stanu łącza). Pierwszy typ jako metryki (metryka to kryterium wyboru drogi jaką pójdą pakiety) używa po prostu odległości i „kosztu przesyłu” (na podstawie parametrów łącza) – wysyła do sąsiadów informacje o dystansie do jakiejś sieci oraz wektorze – czyli sposobie jak się do niej dostać. Drugi typ charakteryzuje się tym, że każdy router ma pełną informację o stanie całej sieci, do wyznaczenia metryki używa specjalnego, skomplikowanego algorytmu, dzięki temu potrafi szybko reagować na zmiany w sieci i szybko wyznaczać najbardziej optymalną trasę dla pakietów. Przykładowa konfiguracja sieci Przykładowa sieć do nauki składa się z 4 routerów o nazwach: „Neptun”, „Mars”, „Pluton”, „Saturn” oraz 2 komputerów „N_Komp” oraz „P_Komp”. Wszystkie urządzenia w tej sieci stosują adresację opartą o adresy „192.168.x.x” (iksy oznaczają wartości, które się zmieniają w zależności od urządzenia) oraz maskę „255.255.255.0”. Poniższy obrazek prezentuje sieć wraz z adresacją i interfejsami: Poniżej znajduje się konfiguracja routerów. Najpierw zostanie przedstawiona konfiguracja routera „Neptun” – zostaną ustawione odpowiednie interfejsy i adresy na routerze: Neptun>enable Neptun#configure terminal Neptun(config)#interface serial 0 Neptun(config-if)#ip address 192.168.12.1 255.255.255.0 Neptun(config-if)#clock rate 5600 Neptun(config-if)#no shutdown Neptun(config-if)#exit Neptun(config)#interface serial 1 Neptun(config-if)#ip address 192.168.14.1 255.255.255.0 Neptun(config-if)#clock rate 5600 Neptun(config-if)#no shutdown Neptun(config-if)#exit Neptun(config)#interface ethernet 0 Neptun(config-if)#ip address 192.168.11.1 255.255.255.0 Neptun(config-if)#no shutdown Neptun(config-if)#exit Następnie te same czynności zostaną wykonane na routerze „Saturn”: Saturn>enable Saturn#configure terminal Saturn(config)#interface serial 0 Saturn(config-if)#ip address 192.168.14.2 255.255.255.0 Saturn(config-if)#no shutdown Saturn(config-if)#exit Saturn(config)#interface serial 1 Saturn(config-if)#ip address 192.168.34.1 255.255.255.0 Saturn(config-if)#clock rate 5600 Saturn(config-if)#no shutdown Saturn(config-if)#exit Teraz zostanie przedstawiona konfiguracja routera „Mars”: Mars>enable Mars#configure terminal Mars(config)#interface serial 1 Mars(config-if)#ip address 192.168.12.2 255.255.255.0 Mars(config-if)#no shutdown Mars(config-if)#exit Mars(config)#interface serial 0 Mars(config-if)#ip address 192.168.23.1 255.255.255.0 Mars(config-if)#clock rate 5600 Mars(config-if)#no shutdown Mars(config-if)#exit I na koniec router „Pluton”: Pluton>enable Pluton#configure terminal Pluton(config)#interface serial 0 Pluton(config-if)#ip a Pluton(config-if)#ip address 192.168.34.2 255.255.255.0 Pluton(config-if)#no shutdown Pluton(config-if)# Pluton(config-if)#exit Pluton(config)#interface serial 1 Pluton(config-if)#ip address 192.168.23.2 255.255.255.0 Pluton(config-if)#no shutdown Pluton(config-if)#exit Pluton(config)#interface ethernet 0 Pluton(config-if)#ip address 192.168.33.1 255.255.255.0 Pluton(config-if)#no shutdown Pluton(config-if)#exit Oczywiście odpowiednio zostały przygotowane również komputery. Należało nadać im właściwe numery IP. O szczegóły konfiguracji komputerów należy dowiedzieć się u prowadzącego (w różnych systemach konfiguracja odbywa się w różny sposób). Konfigurację została zakończona i sieć wygląda dokładnie tak jak na rysunku zamieszczonym wcześniej. RIP w wersji 2 Protokół ten jest przedstawicielem klasy distance vector. Jest to druga – udoskonalona wersja protokołu RIP. Czynnością jaką należy wykonać jest ustawienie routingu dynamicznego w przykładowej sieci, którą została skonfigurowana powyżej. Warto proces ten rozpocząć od obejrzenia zawartość tablicy routingu routera „Neptun” – w tym celu należy wykonać polecenie „show ip routing”: Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.12.0/24 192.168.12.0 is is is is is is subnetted, 1 subnets directly connected, Ethernet0 subnetted, 1 subnets directly connected, Serial1 subnetted, 1 subnets directly connected, Serial0 Stan odpowiada bieżącej konfiguracji routera - trzy sieci podłączone bezpośrednio do routera „Neptun” oraz brak wiedzy o pozostałych sieciach. Aby ustawić routing dynamiczny – RIP v2 na routerze „Neptun” należy wejść do menu konfiguracyjnego i wykonać następujące komendy: Neptun#configure terminal Neptun(config)#router rip Neptun(config-router)#version 2 Uruchomiono rozgłaszanie informacji. Należy podać adresy sieci podłączonych do routera „Neptun”, informacje te będą rozsyłane za pomocą RIP v2 do innych routerów, aby te nauczyły się innych sieci (oczywiście inne routery nie nauczą się innych sieci dopóki również na nich nie zostanie ustawiony RIP v2). Aby podać adresy sieci należy użyć komendy „network adres_sieci” i aby wyjść z menu - komendy „end“: Neptun(config-router)#network 192.168.12.0 Neptun(config-router)#network 192.168.14.0 Neptun(config-router)#network 192.168.11.0 Neptun(config-router)#end Aby pokazać, że inne routery niczego się nie nauczyły od routera „Neptun”, została pokazana tablica routingu routera „Mars”: Mars#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 is is is is subnetted, 1 subnets directly connected, Serial1 subnetted, 1 subnets directly connected, Serial0 Router „Mars” posiada informacje o sieciach podłączone bezpośrednio do niego, nie zdołał nauczyć się od routera „Neptun” ani sieci 192.168.11.0, ani 192.168.14.0. Aby router „Mars” mógł wymieniać z routerem „Neptun” informacje o sieciach należy uruchomić na nim RIP v2 – należy zrobić to analogicznie jak na routerze „Neptun” wpisując oczywiście inne adresy sieci. Na koniec zostanie pokazana również tablica routingu routrera „Mars”: Mars#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Mars(config)#rou Mars(config)#route Mars(config)#router rip Mars(config-router)#version 2 Mars(config-router)#network 192.168.12.0 Mars(config-router)#network 192.168.23.0 Mars(config-router)#end Mars# Mars#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C R R 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.12.1, 00:04:13, Serial1 is subnetted, 1 subnets [120/1] via 192.168.12.1, 00:01:43, Serial1 W tablicy routingu po uruchomieniu routingu dynamicznego (RIP v2) router „Mars” nauczył się adresów sieci od routera „Neptun” – adresy te oznaczone są literą „R”, co oznacza, że zostały dopisane przez protokół z rodziny RIP. Dzięki temu, że na routerze „Mars” został ustawiony RIP v2 również router „Neptun” może teraz uczyć się od niego: Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C R 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.12.2, 00:04:27, Serial0 Router „Neptun” dzięki RIP v2 nauczył się jednego adresu od routera „Mars”. Router„Pluton” – najpierw zostanie przedstawiona zawartość tablicy routingu, następnie zostanie ustawiony RIP v2. Na koniec zostanie przedstawiona ponownie tablica routera „Neptun” żeby można było porównać ją z tą, którą została pokazana na początku: Pluton#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C 192.168.34.0/24 192.168.34.0 192.168.23.0/24 192.168.23.0 192.168.33.0/24 192.168.33.0 is is is is is is subnetted, 1 subnets directly connected, Serial0 subnetted, 1 subnets directly connected, Serial1 subnetted, 1 subnets directly connected, Ethernet0 Pluton#configure terminal Enter configuration commands, Pluton(config)#router rip Pluton(config-router)#version Pluton(config-router)#network Pluton(config-router)#network Pluton(config-router)#network Pluton(config-router)#end one per line. End with CNTL/Z. 2 192.168.23.0 192.168.34.0 192.168.33.0 Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C R R R 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 192.168.34.0/24 192.168.34.0 192.168.33.0/24 192.168.33.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.12.2, 00:01:20, Serial0 is subnetted, 1 subnets [120/2] via 192.168.12.2, 00:07:18, Serial0 is subnetted, 1 subnets [120/2] via 192.168.12.2, 00:05:18, Serial0 Tablica routingu routera „Neptun” wzbogaciła się o sieci routera “Pluton”. Poniżej tablica routera „Mars” również dużo „mądrzejsza”: Mars#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C R R R R 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.34.0/24 192.168.34.0 192.168.33.0/24 192.168.33.0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.12.1, 00:02:32, is subnetted, 1 subnets [120/1] via 192.168.12.1, 00:09:27, is subnetted, 1 subnets [120/1] via 192.168.23.2, 00:09:36, is subnetted, 1 subnets [120/1] via 192.168.23.2, 00:08:40, Serial1 Serial1 Serial0 Serial0 Zostały pokazane tablice routingu. Teraz zostaną prześledzone ich zmiany na 3 routerach. Zostanie skonfigurowany router „Saturn” – będzie pokazana jego nie nauczona tablica routingu, po czym zostanie ustawiony RIP v2 i pokazana jego douczona tablica: Saturn#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C 192.168.14.0/24 192.168.14.0 192.168.34.0/24 192.168.34.0 is is is is subnetted, 1 subnets directly connected, Serial0 subnetted, 1 subnets directly connected, Serial1 Saturn#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C R R 192.168.14.0/24 192.168.14.0 192.168.34.0/24 192.168.34.0 192.168.11.0/24 192.168.11.0 192.168.12.0/24 192.168.12.0 192.168.23.0/24 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [120/1] via 192.168.14.1, 00:04:32, Serial0 is subnetted, 1 subnets [120/1] via 192.168.14.1, 00:09:39, Serial0 is subnetted, 1 subnets R R 192.168.23.0 [120/1] via 192.168.34.2, 00:05:23, Serial1 192.168.33.0/24 is subnetted, 1 subnets 192.168.33.0 [120/1] via 192.168.34.2, 00:04:29, Serial1 W celach diagnostycznych nastąpi próba wysłania z komputera „N_Komp” „ping’a” do komputera „P_Komp”, czyli na drugi koniec sieci: C:>ping 192.168.33.2 Pinging 192.168.33.2 with 32 bytes of data: Reply Reply Reply Reply Reply from from from from from 192.168.33.2: 192.168.33.2: 192.168.33.2: 192.168.33.2: 192.168.33.2: bytes=32 bytes=32 bytes=32 bytes=32 bytes=32 time=60ms time=60ms time=60ms time=60ms time=60ms TTL=241 TTL=241 TTL=241 TTL=241 TTL=241 Ping statistics for 192.168.33.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 50ms, Maximum = 60ms, Average = 55ms Pakiety dotarły we właściwe miejsce oznacza to, że routing dynamiczny działa. Na koniec z komputera „P_Komp” zostanie „spingowany” router „Neptun”, oraz wykonana komenda „traceroute” z routera „Neptun” do komputera „P_Komp” – czynności te potwierdzą właściwą konfigurację routingu dynamicznego: C:>ping 192.168.14.2 Pinging 192.168.14.2 with 32 bytes of data: Reply Reply Reply Reply Reply from from from from from 192.168.14.2: 192.168.14.2: 192.168.14.2: 192.168.14.2: 192.168.14.2: bytes=32 bytes=32 bytes=32 bytes=32 bytes=32 time=60ms time=60ms time=60ms time=60ms time=60ms TTL=241 TTL=241 TTL=241 TTL=241 TTL=241 Ping statistics for 192.168.14.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 50ms, Maximum = 60ms, Average = 55ms Neptun#traceroute 192.168.33.2 "Type escape sequence to abort." Tracing the route to 192.168.33.2 1 192.168.14.2 0 msec 16 msec 0 msec 2 192.168.34.2 20 msec 16 msec 16 msec 3 192.168.33.2 20 msec 16 msec * Kolejny przykład pokaże zachowanie sieci w momencie zerwania połączenia. Poniższy rysunek prezentuje przedstawianą dotąd sieć z zerwanym połączeniem pomiędzy routerami „Saturn” oraz „Neptun”. Zerwanie połączenia zostało w prosty sposób zasymulowane przy pomocy poniższych komend: Saturn#configure terminal Saturn(config)#interface serial 0 Saturn(config-if)#shutdown Saturn(config-if)#exit Po wykonaniu tych komend router „Saturn” wypisał następujące komentarze: %LINK-5-CHANGED: Interface Serial0, changed state to administratively down %LINK-3-UPDOWN: Interface Serial0, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down Oznaczają one, że interfejs routera „Saturn” został administracyjnie wyłączony. Efektem tej operacji jest automatyczne poinformowanie przez router „Saturn” pozostałych routerów o zerwaniu tego połączenia. Ponadto informacja ta powoduje usunięcie wpisu o tym połączeniu (brak wpisu 192.168.14.0) z tablic routingu wszystkich routerów. Prezentują to poniższe listingi: Saturn#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C R R R R 192.168.34.0/24 192.168.34.0 192.168.33.0/24 192.168.33.0 192.168.23.0/24 192.168.23.0 192.168.12.0/24 192.168.12.0 192.168.11.0/24 192.168.11.0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [120/1] via 192.168.34.2, 00:07:41, is subnetted, 1 subnets [120/1] via 192.168.34.2, 00:08:16, is subnetted, 1 subnets [120/2] via 192.168.34.2, 00:05:24, is subnetted, 1 subnets [120/3] via 192.168.34.2, 00:07:39, Serial1 Serial1 Serial1 Serial1 Mars#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C R R C R 192.168.23.0/24 192.168.23.0 192.168.33.0/24 192.168.33.0 192.168.34.0/24 192.168.34.0 192.168.12.0/24 192.168.12.0 192.168.11.0/24 192.168.11.0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.23.2, 00:07:43, Serial0 is subnetted, 1 subnets [120/1] via 192.168.23.2, 00:02:32, Serial0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [120/1] via 192.168.12.1, 00:08:15, Serial1 Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C R R R 192.168.11.0/24 192.168.11.0 192.168.12.0/24 192.168.12.0 192.168.23.0/24 192.168.23.0 192.168.33.0/24 192.168.33.0 192.168.34.0/24 192.168.34.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [120/1] via 192.168.12.2, 00:07:25, Serial0 is subnetted, 1 subnets [120/2] via 192.168.12.2, 00:07:29, Serial0 is subnetted, 1 subnets [120/2] via 192.168.12.2, 00:02:15, Serial0 Pluton#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C R R 192.168.33.0/24 192.168.33.0 192.168.34.0/24 192.168.34.0 192.168.23.0/24 192.168.23.0 192.168.12.0/24 192.168.12.0 192.168.11.0/24 192.168.11.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [120/1] via 192.168.23.1, 00:02:20, Serial1 is subnetted, 1 subnets [120/2] via 192.168.23.1, 00:09:33, Serial1 OSPF Protokół ten jest przedstawicielem klasy link-state. Aby przedstawić jego komendy i sposób działania zostanie użyta wstępnie zrobiona konfiguracja z początku instrukcji. To co jest charakterystyczne w OSPF to jest to dzielenie na obszary (area) w celu wydzielenia okręgów, w których routery będą wymieniać się informacjami o sieci – w tym przypadku będzie tylko jeden obszar autonomiczny. Należy rozpocząć od ustawienia OSPF na routerze „Saturn”. Najpierw należy wejść do menu konfiguracyjnego: Saturn#configure terminal Aby ustawić OSPF należy wykonać polecenie „router ospf numer_procesu”. Numer procesu jest dowolny z zakresu od 1 do 65535. W tym przykładzie będzie używany numer 100 dla porządku na każdym routerze: Saturn(config)#router ospf 100 Właśnie został uruchomiony OSPF. Teraz podobnie jak w RIP v2 trzeba podać sieci, o których router „Saturn” będzie informował inne routery, w tym celu używamy komendy „network adres_sieci wildcard_mask area numer_obszaru”. „Wildcard mask” powstaje przez inwersję zwykłej maski, np. jeśli zwykła maska to 255.255.255.0 to „Wildcard mask” będzie 0.0.0.255, inny przykład 255.255.255.252 da 0.0.0.3, jeśli chodzi o numer obszaru – będzie używany wszędzie „0”. Aby wyjść z menu należy użyć komendy „exit”: Saturn(config-router)#network 192.168.14.0 0.0.0.255 area 0 Saturn(config-router)#network 192.168.34.0 0.0.0.255 area 0 Saturn(config-router)#exit Saturn(config)#exit Na koniec warto podejrzeć jeszcze tablicę routingu. Jak widać router „Saturn” jeszcze nie nauczył się żadnych sieci, bo nie miał od kogo (pozostałe routery nie mają włączonego routingu dynamicznego): Saturn#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C 192.168.14.0/24 192.168.14.0 192.168.34.0/24 192.168.34.0 is is is is subnetted, 1 subnets directly connected, Serial0 subnetted, 1 subnets directly connected, Serial1 Podobne komendy zostaną wykonane na routerze „Neptun”: Neptun#configure terminal Neptun(config)#router ospf 100 Neptun(config-router)#network 192.168.14.0 0.0.0.255 area 0 Neptun(config-router)#network 192.168.12.0 0.0.0.255 area 0 Neptun(config-router)#network 192.168.11.0 0.0.0.255 area 0 Neptun(config-router)#exit Neptun(config)#exit Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C O 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.12.0/24 192.168.12.0 192.168.34.0/24 192.168.34.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets [110/64] via 192.168.14.2, 00:00:10, Ethernet0 Jak widać na listingu tablicy routingu router „Neptun” nauczył się sieci 192.168.34.0 od routera „Saturn”. Sieci nauczone przy pomocy OSPF oznaczane są literą „O”. Podobnie należy skonfigurować router „Mars”. Na koniec zostanie przedstawiona jego tablica routingu: Mars#configure terminal Mars(config)#rou Mars(config)#router ospf 100 Mars(config-router)#network 192.168.12.0 0.0.0.255 area 0 Mars(config-router)#network 192.168.23.0 0.0.0.255 area 0 Mars(config-router)#exit Mars(config)#exit Mars#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C O O 192.168.23.0/24 192.168.23.0 192.168.12.0/24 192.168.12.0 192.168.14.0/24 192.168.14.0 192.168.11.0/24 192.168.11.0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [110/128] via 192.168.12.1, 00:00:12, Serial1 is subnetted, 1 subnets [110/64] via 192.168.12.1, 00:00:12, Serial1 Router „Mars” nauczył się od razu 2-ch sieci. Podobne komendy zostaną wykonane na routerze „Pluton”: Pluton#configure terminal Pluton(config)#router ospf 100 Pluton(config-router)#network 192.168.34.0 0.0.0.255 area 0 Pluton(config-router)#network 192.168.33.0 0.0.0.255 area 0 Pluton(config-router)#network 192.168.23.0 0.0.0.255 area 0 Pluton(config-router)#exit Pluton(config)#exit Pluton#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C O O O C C 192.168.33.0/24 192.168.33.0 192.168.12.0/24 192.168.12.0 192.168.14.0/24 192.168.14.0 192.168.11.0/24 192.168.11.0 192.168.34.0/24 192.168.34.0 192.168.23.0/24 192.168.23.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets [110/64] via 192.168.12.2, 00:07:19, Ethernet0 is subnetted, 1 subnets [110/64] via 192.168.34.1, 00:07:19, Ethernet0 is subnetted, 1 subnets [110/192] via 192.168.23.1, 00:07:19, Ethernet0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets is directly connected, Serial1 Listing routera „Pluton” pokazuje, że jego tablica routingu ma już informacje o wszystkich sieciach w swoim obszarze. Aby pokazać, że routing działa zostanie wykonana komenda „ping” z komputera „P_Komp” do komputera „N_Komp”: C:#ping 192.168.11.2 Pinging 192.168.11.2 with 32 bytes of data: Reply Reply Reply Reply Reply from from from from from 192.168.11.2: 192.168.11.2: 192.168.11.2: 192.168.11.2: 192.168.11.2: bytes=32 bytes=32 bytes=32 bytes=32 bytes=32 time=60ms time=60ms time=60ms time=60ms time=60ms TTL=241 TTL=241 TTL=241 TTL=241 TTL=241 Ping statistics for 192.168.11.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 50ms, Maximum = 60ms, Average = 55ms Wszystkie pakiety dotarły z jednego końca sieci na drugi – oznacza to, że routing dynamiczny działa prawidłowo. Następnie zostanie wykonana komenda „ping” z routera „Saturn” do routera „Mars”: Saturn#ping 192.168.23.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.23.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms Ponownie wszystkie pakiety dotarły na miejsce. Na koniec zostanie pokazana jeszcze tablica routingu routera „Saturn”: Saturn#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C O O O O 192.168.14.0/24 192.168.14.0 192.168.34.0/24 192.168.34.0 192.168.12.0/24 192.168.12.0 192.168.11.0/24 192.168.11.0 192.168.23.0/24 192.168.23.0 192.168.33.0/24 192.168.33.0 is subnetted, 1 subnets is directly connected, Serial0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets [110/64] via 192.168.14.1, 00:04:06, Serial1 is subnetted, 1 subnets [110/64] via 192.168.11.1, 00:04:06, Serial1 is subnetted, 1 subnets [110/192] via 192.168.14.1, 00:04:06, Serial1 is subnetted, 1 subnets [110/64] via 192.168.33.1, 00:04:06, Serial1 Widać podobną sytuację jak na innych routerach – pełną wiedzę o sieciach w danym obszarze. Teraz zostanie pokazane działanie komendy „show ip protocol”: Neptun#show ip protocol Routing Protocol is "ospf 100" Sending updates every 90 seconds, next due in 10 seconds Invalid after 30 seconds, hold down 0, flushed after 60 Outgoing update filter list for all interfaces is Incoming update filter list for all interfaces is Redistributing: ospf 100 Routing for Networks: 192.168.14.0 0.0.0.255 area 0 192.168.12.0 0.0.0.255 area 0 192.168.11.0 0.0.0.255 area 0 Routing Information Sources: Gateway Distance Last Update 192.168.12.1 110 00:00:03 192.168.14.1 110 00:00:03 192.168.14.1 110 00:00:03 Distance: (default is 110) Komenda ta wyświetla informację o protokole routującym, informacje o sieciach, obszarach, metrykach, czy czasach ostatniej aktualizacji. Kolejną komendą, która zostanie pokazana jest „show ip ospf interface”: Neptun#show ip ospf interface Serial0 is up, line protocol is up Internet Address 192.168.12.1/24 , Area 0 Process ID 100, Router ID 192.168.14.1, Network Type , Cost: 64 Transmit Delay is 1 sec, State , Priority 1 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:02 Neighbor Count is 1, Adjacent neighbor count is 1 Adjacent with neighbor 192.168.12.2 Suppress hello for 0 neighbor(s) Serial1 is up, line protocol is up Internet Address 192.168.14.1/24 , Area 0 Process ID 100, Router ID 192.168.14.1, Network Type , Cost: 64 Transmit Delay is 1 sec, State , Priority 1 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:02 Neighbor Count is 1, Adjacent neighbor count is 1 Adjacent with neighbor 192.168.14.2 Suppress hello for 0 neighbor(s) Ethernet0 is up, line protocol is up Internet Address 192.168.11.1/24 , Area 0 Process ID 100, Router ID 192.168.14.1, Network Type , Cost: 100 Transmit Delay is 1 sec, State , Priority 1 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:02 Neighbor Count is 0, Adjacent neighbor count is 0 Suppress hello for 0 neighbor(s) Polecenie to weryfikuje, czy interfejs został właściwie ustawiony – czy działa. Informuje o adresie na interfejsie (internet address) oraz obszarze w którym znajduje się interfejs (area). Ponadto informacja o numerze procesu OSPF (Process ID), numerze identyfikacyjnym Routera (Router ID – jest wybierany zawsze jako „największy” adres z interfejsów routera), „koszcie łącza” (cost), czy priorytecie interfejsu (priority). Ponadto zawiera informacje o czasach ustawionych dla pakietów typu: hello, dead, wait, retransmit. Kolejnym krokiem, który dobrze jest wykonać w przypadku routingu OSPF, jest postawienie na każdym routerze interfejsu „loopback”. Jedyną rolą tego interfejsu jest to, że gdy inne interfejsy z jakichś powodów przestaną działać podtrzymuje on działanie procesu OSPF. Poza tym adres interfejsu „loopback” bez względu na wielkość tej liczby staje się identyfikatorem routera (router id). Maską jaką należy podać jest 255.255.255.255 – określa to sieć jednohostową. Teraz konfiguracja: Neptun(config)#interface loopback 0 Neptun(config-if)#ip address 192.168.15.1 255.255.255.255 Neptun(config-if)#exit Aby zmienić z kolei priorytet interfejsu (priority – jak było widać na wcześniejszym listingu standardowo jest ustawiana wartość 1), należy wykonać poniższe komendy ( w tym przypadku zmieniamy priorytet dla interfejsu serial 1 na „Alabamie”): Neptun(config)#interface serial 1 Neptun(config-if)#ip ospf priority 50 Neptun(config-if)#end Zmiana priorytetów jest przydatna przy wyborze DR (designated router) w sieciach wielodostępowych – w przypadku przykładowej sieci nic tak na prawdę się nie zmieni (zmieni się tylko parametr „priority”). Poniższy listing przedstawia tablicę routingu po wprowadzeniu interfejsu „loopback”: Neptun#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route Gateway of last resort is not set C C C C O O O 192.168.11.0/24 192.168.11.0 192.168.14.0/24 192.168.14.0 192.168.12.0/24 192.168.12.0 192.168.15.1 is 192.168.34.0/24 192.168.34.0 192.168.23.0/24 192.168.23.0 192.168.33.0/24 192.168.33.0 is subnetted, 1 subnets is directly connected, Ethernet0 is subnetted, 1 subnets is directly connected, Serial1 is subnetted, 1 subnets is directly connected, Serial0 directly connected, Loopback0 is subnetted, 1 subnets [110/64] via 192.168.34.1, 00:00:01, Loopback0 is subnetted, 1 subnets [110/64] via 192.168.12.2, 00:00:01, Loopback0 is subnetted, 1 subnets [110/192] via 192.168.14.2, 00:00:01, Loopback0 Kolejną komendą z cyklu pokazujących informacje o sieci jest “show ip ospf database”: Mars#show ip ospf database OSPF Router with ID (192.168.23.1) (Process ID 100) Router Link States (Area 0) Link ID 192.168.12.1 192.168.14.1 192.168.34.2 192.168.23.2 192.168.33.1 192.168.11.1 ADV Router 192.168.12.1 192.168.14.1 192.168.23.2 192.168.23.2 192.168.33.1 192.168.11.1 Age 0 0 0 0 0 0 Seq# 0x80000009 0x80000003 0x80000003 0x80000003 0x80000009 0x80000006 Checksum Link count 0x1923 0x8877 0x8687 0x6978 0x7014 0x5531 Komenda ta pokazuje zawartość bazy topologii sieci jaką posiada „Mars”, pokazuje identyfikator routera i procesu oraz sieci w obszarze 0. Z kolei komenda „show ip ospf neighbour detail” pokazuje sąsiadów „Plutona”: Pluton#show ip ospf neighbor detail Neighbor 192.168.34.1, interface address 192.168.34.1 In the area 100 via interface Serial0 Neighbor priority is 1, State is FULL, 6 state changes DR is 0.0.0.0 BDR is 0.0.0.0 Options 2 Dead timer due in Neighbor 192.168.23.1, interface address 192.168.23.1 In the area 100 via interface Serial1 Neighbor priority is 1, State is FULL, 6 state changes DR is 0.0.0.0 BDR is 0.0.0.0 Options 2 Dead timer due in Jak widać z tej komendy w sieci nie ma wybranego DR ani BDR (backup DR). Jeśli jest potrzeba ustawienia w sieci dostępu na zewnątrz (np. do internetu) należy na routerze, który ma wyjście na zewnątrz wykonać komendy: Router(config)#ip route 0.0.0.0 0.0.0.0 [interface | next-hop address ] Następnie trzeba “default route” rozpropagować w OSPF: Router(config)#router ospf 100 Router(config-router)#default-information originate ĆWICZENIE: Zaplanuj numerację sieci przedstawionej na poniższym rysunku. Przy pomocy odpowiednich komend wykonaj konfigurację oraz przeprowadź proces diagnostyczny sieci.