Cele:
Adresy IP routerów:
R1
Interfejs |
IP |
FastEthernet 0/0 |
172.0.12.1/24 |
Loopback 0 |
1.1.0.1/32 |
Loopback 1 |
1.1.1.1/32 |
Loopback 2 |
1.1.2.1/32 |
Loopback 3 |
1.1.3.1/32 |
R2
Interfejs |
IP |
FastEthernet 0/0 |
172.0.12.2/24 |
FastEthernet 1/0 |
172.234.23.2/24 |
FastEthernet 2/0 |
172.234.24.2/24 |
Loopback 0 |
2.2.2.2/32 |
R3
Interfejs |
IP |
FastEthernet 0/0 |
172.234.23.3/24 |
FastEthernet 1/0 |
172.234.34.3/24 |
Loopback 0 |
3.3.3.3/32 |
R4
Interfejs |
IP |
FastEthernet 0/0 |
172.234.24.4/24 |
FastEthernet 1/0 |
172.234.34.4/24 |
Loopback 0 |
4.4.4.4/32 |
Schemat sieci:

Router: 3640
IOS: c3640-jk9o3s-mz.124-16a.bin
Rozwiązanie
Skonfiguruj OSPF według schematu sieci.
Krok pierwszy to standardowa konfiguracja OSPF. Mamy 4 routery i 2 różne obszary. Router R2 pełni rolę routera ABR łącząc ze sobą obszary 0 i 234.
R1(config-router)#router-id 1.1.1.1 |
R1(config-router)#network 172.0.12.0 0.0.0.255 area 0 |
R1(config-router)#network 1.1.0.0 0.0.255.255 area 0 |
R2(config-router)#router-id 2.2.2.2 |
R2(config-router)#network 172.0.12.0 0.0.0.255 area 0 |
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0 |
R2(config-router)#network 172.234.23.0 0.0.0.255 area 234 |
R2(config-router)#network 172.234.24.0 0.0.0.255 area 234 |
R3(config-router)#router-id 3.3.3.3 |
R3(config-router)#network 172.234.23.0 0.0.0.255 area 234 |
R3(config-router)#network 172.234.34.0 0.0.0.255 area 234 |
R3(config-router)#network 3.3.3.3 0.0.0.0 area 234 |
R4(config-router)#router-id 4.4.4.4 |
R4(config-router)#network 172.234.24.0 0.0.0.255 area 234 |
R4(config-router)#network 172.234.34.0 0.0.0.255 area 234 |
R4(config-router)#network 4.4.4.4 0.0.0.0 area 234 |
Interfejs Loopback od R2 przypisaliśmy do obszaru zerowego. Po chwili nawiązana zostanie relacja sąsiedztwa a w tablicach routingu powinny pojawić się nowe trasy:
2.0.0.0/32 is subnetted, 1 subnets |
O 2.2.2.2 [110/2] via 172.0.12.2, 01:29:15, FastEthernet0/0 |
3.0.0.0/32 is subnetted, 1 subnets |
O IA 3.3.3.3 [110/3] via 172.0.12.2, 01:12:27, FastEthernet0/0 |
4.0.0.0/32 is subnetted, 1 subnets |
O IA 4.4.4.4 [110/3] via 172.0.12.2, 01:11:40, FastEthernet0/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O IA 172.234.23.0 [110/2] via 172.0.12.2, 01:29:04, FastEthernet0/0 |
O IA 172.234.24.0 [110/2] via 172.0.12.2, 01:29:04, FastEthernet0/0 |
O IA 172.234.34.0 [110/3] via 172.0.12.2, 01:12:37, FastEthernet0/0 |
1.0.0.0/32 is subnetted, 4 subnets |
O IA 1.1.1.1 [110/3] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
O IA 1.1.0.1 [110/3] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
O IA 1.1.3.1 [110/3] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
O IA 1.1.2.1 [110/3] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/2] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
3.0.0.0/32 is subnetted, 1 subnets |
O 3.3.3.3 [110/2] via 172.234.34.3, 01:12:02, FastEthernet1/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.23.0 [110/2] via 172.234.34.3, 01:12:02, FastEthernet1/0 |
[110/2] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.24.2, 01:12:02, FastEthernet0/0 |
Wszystko wygląda dobrze.
Włącz filtrowanie tras OSPF na R4. W jego tablicy routingu powinny być tylko trasy do 172.0.12.0/24 i 1.1.2.1/32. Użyj distribute-list wraz z listą kontroli dostępu (access-list).
Każdy router w OSPF należący do danego obszaru przechowuje tzw. bazę topologii (topology database). Następnie na podstawie informacji zawartych w tej bazie router przelicza i wybiera najbardziej optymalną ścieżkę do danej sieci, czego rezultat widzimy już w tablicy routingu. Wszystkie routery w tym samym obszarze muszą mieć taką samą bazę, w przeciwnym razie algorytm Dijkstry (najkrótszej ścieżki – Shortest Path First) mógłby wygenerować trasy zawierające pętle routingu lub czarne dziury routingu (routing black holes). Bazę topologii wyświetlamy poleceniem show ip ospf database
:
OSPF Router with ID (4.4.4.4) (Process ID 1) |
Router Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum Link count |
2.2.2.2 2.2.2.2 907 0x80000007 0x00B88E 2 |
3.3.3.3 3.3.3.3 853 0x80000008 0x00D03A 3 |
4.4.4.4 4.4.4.4 873 0x80000006 0x0031CB 3 |
Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
172.234.23.2 2.2.2.2 1905 0x80000004 0x005E0C |
172.234.24.2 2.2.2.2 907 0x80000004 0x0085DF |
172.234.34.3 3.3.3.3 853 0x80000004 0x001141 |
Summary Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
1.1.0.1 2.2.2.2 1905 0x80000004 0x0038F4 |
1.1.1.1 2.2.2.2 1905 0x80000004 0x002DFE |
1.1.2.1 2.2.2.2 1905 0x80000004 0x002209 |
1.1.3.1 2.2.2.2 1905 0x80000004 0x001713 |
2.2.2.2 2.2.2.2 1907 0x80000004 0x00F434 |
172.0.12.0 2.2.2.2 1907 0x80000004 0x000870 |
Naszym celem jest teraz odrzucenie wszystkich tras oprócz 172.0.12.0/24 i 1.1.2.1/32 na routerze R4. Do tego celu stworzymy listę kontroli dostępu i połączymy ją następnie z listą dystrybucji. Pytanie, czy po tej operacji zmieni się tablica topologii routera R4?
Zanim zaczniemy zobaczmy jeszcze raz tablice routingu na R4:
1.0.0.0/32 is subnetted, 4 subnets |
O IA 1.1.1.1 [110/3] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
O IA 1.1.0.1 [110/3] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
O IA 1.1.3.1 [110/3] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
O IA 1.1.2.1 [110/3] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/2] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
3.0.0.0/32 is subnetted, 1 subnets |
O 3.3.3.3 [110/2] via 172.234.34.3, 02:04:59, FastEthernet1/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.23.0 [110/2] via 172.234.34.3, 02:04:59, FastEthernet1/0 |
[110/2] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.24.2, 02:04:59, FastEthernet0/0 |
Tworzymy standardową listę dostępu, później distribute-list w trybie konfiguracji OSPF:
R4(config)#access-list 10 permit 172.0.12.0 0.0.0.255 |
R4(config)#access-list 10 permit 1.1.2.1 |
R4(config-router)#distribute-list 10 in |
Czas na tablice routingu:
1.0.0.0/32 is subnetted, 1 subnets |
O IA 1.1.2.1 [110/3] via 172.234.24.2, 00:09:33, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.24.2, 00:09:33, FastEthernet0/0 |
Wygląda dobrze, tylko 2 trasy OSPF w tablicy routingu, reszta została odrzucona. A jak wygląda baza topologii?
OSPF Router with ID (4.4.4.4) (Process ID 1) |
Router Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum Link count |
2.2.2.2 2.2.2.2 348 0x80000008 0x00B68F 2 |
3.3.3.3 3.3.3.3 312 0x80000009 0x00CE3B 3 |
4.4.4.4 4.4.4.4 347 0x80000007 0x002FCC 3 |
Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
172.234.23.2 2.2.2.2 1368 0x80000005 0x005C0D |
172.234.24.2 2.2.2.2 348 0x80000005 0x0083E0 |
172.234.34.3 3.3.3.3 312 0x80000005 0x000F42 |
Summary Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
1.1.0.1 2.2.2.2 1368 0x80000005 0x0036F5 |
1.1.1.1 2.2.2.2 1368 0x80000005 0x002BFF |
1.1.2.1 2.2.2.2 1368 0x80000005 0x00200A |
1.1.3.1 2.2.2.2 1368 0x80000005 0x001514 |
2.2.2.2 2.2.2.2 1370 0x80000005 0x00F235 |
172.0.12.0 2.2.2.2 1370 0x80000005 0x000671 |
Bez zmian, czyli prawidłowo. Lista dystrybucyjna ma wpływ tylko na trasy w tablicy routingu, nie filtruje niczego w bazie topologi.
R3 – wyłącz interfejs FastEthernet 0/0. Czy ma on wciąż pełną łączność z sieciami w obszarze zerowym?
No właśnie, a co się stanie jeśli usuniemy link pomiędzy R2 i R3? Czy router R3 będzie w stanie nawiązać łączność z interfejsami Loopback od routera R1? Cały ruch będzie kierowany przez R4, a w jego tablicy routingu nie mamy wszystkich wpisów. Przekonajmy się:
Tablica routingu R3:
1.0.0.0/32 is subnetted, 4 subnets |
O IA 1.1.1.1 [110/4] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
O IA 1.1.0.1 [110/4] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
O IA 1.1.3.1 [110/4] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
O IA 1.1.2.1 [110/4] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/3] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
4.0.0.0/32 is subnetted, 1 subnets |
O 4.4.4.4 [110/2] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.23.0 [110/3] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
O 172.234.24.0 [110/2] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/3] via 172.234.34.4, 00:00:17, FastEthernet1/0 |
Tablica routingu wygląda „dobrze”. Trasy prowadzą teraz przez router R4. Spróbujmy pingować adres 1.1.1.1:
Type escape sequence to abort. |
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: |
Success rate is 0 percent (0/5) |
No i mamy problem. Adres jest nieosiągalny, mamy czarną dziurę w routingu. Przypomnijmy, że filtrując trasy na R4 nie zmieniła się baza topologii w obszarze 234. Pozostałe routery (R2 i R3) nic nie wiedzą o tych zmianach, dlatego zakładają że R4 ma pełną łączność z R1.
Na koniec uruchomimy ponownie link pomiędzy R2 i R3:
R3(config-if)#no shutdown |
R3 – zablokuj trasy 1.1.0.1 i 1.1.1.1 przy pomocy prefix-list.
W tym przykładzie użyjemy listy dystrybucyjnej w połączeniu z listą prefiksową. Musimy zablokować tylko 2 trasy na routerze R3. Zaczniemy od prefix-list:
R3(config)#ip prefix-list DENY_L0 seq 1 deny 1.1.0.0/23 le 32 |
R3(config)#ip prefix-list DENY_L0 seq 10 permit 0.0.0.0/0 le 32 |
Utworzyliśmy listę o nazwie DENY_L0. Następnie blokujemy wszystkie adresy, które mieszczą się w zakresie 1.1.0.0/23 (czyli od 1.1.0.0 do 1.1.1.255). Do tego maska podsieci musi być mniejsza lub równa 32 (pamiętajmy, że R1 rozgłasza interfejsy Loopback z maską 32). W drugiej linii dopuszczamy wszystkie możliwe sieci. Teraz w trybie konfiguracji OSPF:
R3(config-router)#distribute-list prefix DENY_L0 in |
Zobaczmy teraz tablice routingu od R3:
1.0.0.0/32 is subnetted, 2 subnets |
O IA 1.1.3.1 [110/3] via 172.234.23.2, 00:06:20, FastEthernet0/0 |
O IA 1.1.2.1 [110/3] via 172.234.23.2, 00:06:20, FastEthernet0/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/2] via 172.234.23.2, 00:06:20, FastEthernet0/0 |
4.0.0.0/32 is subnetted, 1 subnets |
O 4.4.4.4 [110/2] via 172.234.34.4, 00:06:20, FastEthernet1/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.24.0 [110/2] via 172.234.34.4, 00:06:20, FastEthernet1/0 |
[110/2] via 172.234.23.2, 00:06:20, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.23.2, 00:06:20, FastEthernet0/0 |
Mamy wszystkie trasy OSPF oprócz 1.1.0.1/32 i 1.1.1.1/32.
R3 – zablokuj trasy 1.1.2.1 i 1.1.3.1 przy pomocy route-map.
Route-map to kolejna opcja przy pomocy której możemy wpłynąć na tablice routingu. Zablokujemy 2 kolejne sieci rozgłaszane przez R1. Ponownie utworzymy listę prefiksów, następnie route-map i połączymy wszystko w jedną całość przy pomocy distribute-list.
R3(config)#ip prefix-list DENY_L0_V2 seq 1 deny 1.1.2.0/23 le 32 |
R3(config)#ip prefix-list DENY_L0_V2 seq 10 permit 0.0.0.0/0 le 32 |
Lista podobna do poprzedniej. Zmieniliśmy nazwę na DENY_L0_v2 i blokujemy zaczynając od 1.1.2.0. Teraz utworzymy route-map. Dają one większe pole do popisu, ponieważ możemy dopasować pakiety na podstawie kilku opcji:
- match interface
- match ip address
- match ip next-hop
- match ip route-source
- match ipv6 address
- match ipv6 next-hop
- match ipv6 route-source
- match metric
- match route-type
- match source-protocol
- match tag
My wybieramy opcję match ip address, która możemy połączyć z access-list lub prefix-list
R3(config)#route-map BLOCK_L0 permit 10 |
R3(config-route-map)#match ip address prefix-list DENY_L0_V2 |
Zanim utworzymy distribute-list musimy usunąć poprzednią (distribute-list prefix DENY_L0 in):
R3(config-router)#distribute-list route-map BLOCK_L0 in |
% Prefix-list filter exists, de-config first |
R3(config-router)#no distribute-list prefix DENY_L0 in |
R3(config-router)#distribute-list route-map BLOCK_L0 in |
Teraz tablica routingu:
1.0.0.0/32 is subnetted, 2 subnets |
O IA 1.1.1.1 [110/3] via 172.234.23.2, 00:00:24, FastEthernet0/0 |
O IA 1.1.0.1 [110/3] via 172.234.23.2, 00:00:24, FastEthernet0/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/2] via 172.234.23.2, 00:00:24, FastEthernet0/0 |
4.0.0.0/32 is subnetted, 1 subnets |
O 4.4.4.4 [110/2] via 172.234.34.4, 00:00:24, FastEthernet1/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.24.0 [110/2] via 172.234.34.4, 00:00:24, FastEthernet1/0 |
[110/2] via 172.234.23.2, 00:00:24, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.23.2, 00:00:24, FastEthernet0/0 |
Wpisy 1.1.0.1 i 1.1.1.1 są znów widocznie, natomiast 1.1.2.1 i 1.1.3.1 zostały zablokowane. Tak więc route-map spełniła swoje zadanie. A jak wygląda baza OSPF na R3?
OSPF Router with ID (3.3.3.3) (Process ID 1) |
Router Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum Link count |
2.2.2.2 2.2.2.2 1040 0x8000000C 0x00AE93 2 |
3.3.3.3 3.3.3.3 1030 0x8000000E 0x00C440 3 |
4.4.4.4 4.4.4.4 543 0x8000000A 0x0029CF 3 |
Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
172.234.23.2 2.2.2.2 1040 0x80000003 0x00600B |
172.234.24.2 2.2.2.2 537 0x80000008 0x007DE3 |
172.234.34.3 3.3.3.3 533 0x80000008 0x000945 |
Summary Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
1.1.0.1 2.2.2.2 1558 0x80000008 0x0030F8 |
1.1.1.1 2.2.2.2 1558 0x80000008 0x002503 |
1.1.2.1 2.2.2.2 1558 0x80000008 0x001A0D |
1.1.3.1 2.2.2.2 1558 0x80000008 0x000F17 |
2.2.2.2 2.2.2.2 1560 0x80000008 0x00EC38 |
172.0.12.0 2.2.2.2 1560 0x80000008 0x00FF74 |
Tak jak poprzednio bez zmian. Użycie distribute-list w połączeniu z route-map nie ma wpływu na wpisy w bazie topologii.
R3 – zablokuj trasę do 4.4.4.4 zmieniając odległość administracyjną.
Trasy w tablicy routingu można też filtrować poprzez zmianę odległości administracyjnej (AD). Domyślna wartość AD dla protokołu OSPF to 110. Kiedy ustawimy ją na 255 dla wybranej trasy, wtedy zostanie ona usunięta z tablicy routingu, ponieważ wartość ta oznacza że trasa jest nieważna.
Na R3 tworzymy standardową listę, która złapie tylko adres 4.4.4.4:
R3(config)#access-list 15 permit 4.4.4.4 |
W trybie konfiguracji OSPF wpisujemy:
R3(config-router)#distance 255 0.0.0.0 255.255.255.255 15 |
Dla jakiejkolwiek sieci, która pasuje do naszej listy dostępu (numer 15) dystans administracyjny zostanie ustawiony na wartość 255 (a więc zostanie ona odrzucona). Zobaczmy wpisy w tablicy routingu:
1.0.0.0/32 is subnetted, 2 subnets |
O IA 1.1.1.1 [110/3] via 172.234.23.2, 00:02:24, FastEthernet0/0 |
O IA 1.1.0.1 [110/3] via 172.234.23.2, 00:02:24, FastEthernet0/0 |
2.0.0.0/32 is subnetted, 1 subnets |
O IA 2.2.2.2 [110/2] via 172.234.23.2, 00:02:24, FastEthernet0/0 |
172.234.0.0/24 is subnetted, 3 subnets |
O 172.234.24.0 [110/2] via 172.234.34.4, 00:02:24, FastEthernet1/0 |
[110/2] via 172.234.23.2, 00:02:24, FastEthernet0/0 |
172.0.0.0/24 is subnetted, 1 subnets |
O IA 172.0.12.0 [110/2] via 172.234.23.2, 00:02:24, FastEthernet0/0 |
Zgadza się, brakuje wpisu 4.4.4.4/32. Zmiany te podobnie jak poprzednio, nie mają wpływu na bazę topologii:
OSPF Router with ID (3.3.3.3) (Process ID 1) |
Router Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum Link count |
2.2.2.2 2.2.2.2 819 0x8000000E 0x00AA95 2 |
3.3.3.3 3.3.3.3 833 0x80000010 0x00C042 3 |
4.4.4.4 4.4.4.4 494 0x8000000C 0x0025D1 3 |
Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
172.234.23.2 2.2.2.2 819 0x80000005 0x005C0D |
172.234.24.2 2.2.2.2 315 0x8000000A 0x0079E5 |
172.234.34.3 3.3.3.3 319 0x8000000A 0x000547 |
Summary Net Link States (Area 234) |
Link ID ADV Router Age Seq# Checksum |
1.1.0.1 2.2.2.2 1328 0x8000000A 0x002CFA |
1.1.1.1 2.2.2.2 1328 0x8000000A 0x002105 |
1.1.2.1 2.2.2.2 1328 0x8000000A 0x00160F |
1.1.3.1 2.2.2.2 1328 0x8000000A 0x000B19 |
2.2.2.2 2.2.2.2 1329 0x8000000A 0x00E83A |
172.0.12.0 2.2.2.2 1329 0x8000000A 0x00FB76 |
0 Komentarze.