RIP – distribute-list (filtrowanie)

Cele:

Adresy IP routerów:

R1

Interfejs IP
FastEthernet 0/0 172.16.13.1/24
Loopback 0 1.1.1.1/24

R2

Interfejs IP
FastEthernet 0/0 172.16.23.2/24
Loopback 0 2.2.2.1/28
Loopback 1 2.2.2.17/28
Loopback 2 2.2.2.33/28
Loopback 3 2.2.2.49/28
Loopback 4 2.2.2.65/28
Loopback 5 2.2.2.81/28
Loopback 6 2.2.2.97/28
Loopback 7 2.2.2.113/28

R3

Interfejs IP
FastEthernet 0/0 172.16.13.3/24
FastEthernet 1/0 172.16.23.3/24
Loopback 0 3.3.0.1/24
Loopback 1 3.3.1.1/24
Loopback 2 3.3.2.1/24
Loopback 3 3.3.3.1/24

Schemat sieci:

rip distribute list (filtrowanie)

Router: 3640
IOS: c3640-jk9o3s-mz.124-16a.bin

Rozwiązanie

Skonfiguruj RIP version 2 na wszystkich routerach. Rozgłoś interfejsy Loopback routerów R1, R2, R3.

Włączymy obsługę RIPv2 na wszystkich routerach oraz rozgłosimy wszystkie podłączone sieci:

R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 0.0.0.0
R2(config)#router rip
R2(config-router)#version 2
R1(config-router)#no auto-summary
R2(config-router)#network 0.0.0.0
R3(config)#router rip
R3(config-router)#version 2
R1(config-router)#no auto-summary
R3(config-router)#network 0.0.0.0

Wpis network 0.0.0.0 oznacza, że chcemy rozgłosić wszystkie sieci do RIP, dzięki czemu nie musimy wpisywać każdej z osobna. Dodatkowo każda nowo dodana sieć/interfejs będzie też automatycznie rozgłaszana w RIP. Sprawdźmy łączność pingując z R1 routery R2 i R3:

R1#ping 2.2.2.1 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.1, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/38/48 ms
R1#ping 2.2.2.17 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.17, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/38/44 ms
R1#ping 2.2.2.113 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.113, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/39/44 ms
R1#ping 3.3.0.1 source loopback 0  

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.0.1, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/18/24 ms
R1#ping 3.3.3.1 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.1, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/17/24 ms

Tablica routingu dla R1:

R1#show ip route  rip 
     2.0.0.0/28 is subnetted, 8 subnets
R       2.2.2.0 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.16 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.32 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.48 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.64 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.80 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.96 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       2.2.2.112 [120/2] via 172.16.13.3, 00:00:08, FastEthernet0/0
     3.0.0.0/24 is subnetted, 4 subnets
R       3.3.0.0 [120/1] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       3.3.1.0 [120/1] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       3.3.2.0 [120/1] via 172.16.13.3, 00:00:08, FastEthernet0/0
R       3.3.3.0 [120/1] via 172.16.13.3, 00:00:08, FastEthernet0/0
     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.23.0 [120/1] via 172.16.13.3, 00:00:08, FastEthernet0/0

Router R1 może nauczyć się przez RIP tylko sieci od 2.2.2.64/28 do 2.2.2.112/28 oraz 172.16.23.0/24. W tym celu skonfiguruj prefix-list na R1.

Router R1 nauczył się 13 różnych sieci przez protokół RIP. Chcemy teraz, aby w jego tablicy routingu znalazły się tylko sieci od 2.2.2.64/28 do 2.2.2.112/28 oraz 17.16.23.0/24. W tym celu użyjemy polecenia distribute-list w trybie konfiguracji RIP oraz zdefiniujemy listę prefiksów (prefix-lis). W prefix-list zdefiniujemy, które sieci router R1 ma dodać do swojej tablicy routingu.

R1(config)#ip prefix-list FROM_R2 seq 1 permit 2.2.2.64/26 le 28
R1(config)#ip prefix-list FROM_R2 seq 2 permit 172.16.23.0/24

W pierwszej linii router R1 dopasuje prefiksy dla sieci zaczynających się od 2.2.2.64 oraz masce długości 26 bitów. Taka maska daje nam właśnie zakres sieci od 2.2.2.64 do 2.2.2.123. Dodatkowo sprawdzamy czy prefiks sieci jest mniejszy lub równy od 28 (le 28). Warunek ten jest niezbędny, ponieważ R2 rozgłasza swoje sieci z prefiksem /28 a nie /26. W kolejnej linii dopuszczamy dokładnie sieć 172.16.23.0/24. Pamiętajmy też, że podobnie jak w listach kontroli dostępu (access-list) na samym końcu prefix-list dodawana jest domyślna linia deny any.
Naszą listę łączymy z poleceniem distribute-list dla ruchu przychodzącego w trybie konfiguracji RIP:

R1(config)#router rip
R1(config-router)#distribute-list prefix FROM_R2 in

Po około 3 minutach niektóre z tras oznaczone są jako possibly down w tablicy routingu:

R1#show ip route rip 
     2.0.0.0/28 is subnetted, 8 subnets
R       2.2.2.0/28 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       2.2.2.16/28 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       2.2.2.32/28 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       2.2.2.48/28 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       2.2.2.64 [120/2] via 172.16.13.3, 00:00:19, FastEthernet0/0
R       2.2.2.80 [120/2] via 172.16.13.3, 00:00:19, FastEthernet0/0
R       2.2.2.96 [120/2] via 172.16.13.3, 00:00:19, FastEthernet0/0
R       2.2.2.112 [120/2] via 172.16.13.3, 00:00:19, FastEthernet0/0
     3.0.0.0/24 is subnetted, 4 subnets
R       3.3.0.0/24 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       3.3.1.0/24 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       3.3.2.0/24 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
R       3.3.3.0/24 is possibly down,
          routing via 172.16.13.3, FastEthernet0/0
     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.23.0 [120/1] via 172.16.13.3, 00:00:21, FastEthernet0/0

, a minutę później zostają usunięte:

R1#show ip route rip 
     2.0.0.0/28 is subnetted, 4 subnets
R       2.2.2.64 [120/2] via 172.16.13.3, 00:00:21, FastEthernet0/0
R       2.2.2.80 [120/2] via 172.16.13.3, 00:00:21, FastEthernet0/0
R       2.2.2.96 [120/2] via 172.16.13.3, 00:00:21, FastEthernet0/0
R       2.2.2.112 [120/2] via 172.16.13.3, 00:00:21, FastEthernet0/0
     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.23.0 [120/1] via 172.16.13.3, 00:00:21, FastEthernet0/0

Router R2 nie może zawierać sieci 3.3.0.0/24 oraz 3.3.2.0/24 w tablicy routingu. Użyj list kontroli dostępu (access-list).

W poprzednim punkcie użyliśmy prefix-list w celu kontroli, które z sieci zostaną dodane do tablicy routingu. Teraz do tego samego celu użyjemy access-list. Router R3 nauczył się 6 sieci przez RIP:

R2#show ip route  rip
     1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/2] via 172.16.23.3, 00:00:04, FastEthernet0/0
     3.0.0.0/24 is subnetted, 4 subnets
R       3.3.0.0 [120/1] via 172.16.23.3, 00:00:04, FastEthernet0/0
R       3.3.1.0 [120/1] via 172.16.23.3, 00:00:04, FastEthernet0/0
R       3.3.2.0 [120/1] via 172.16.23.3, 00:00:04, FastEthernet0/0
R       3.3.3.0 [120/1] via 172.16.23.3, 00:00:04, FastEthernet0/0
     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.13.0 [120/1] via 172.16.23.3, 00:00:04, FastEthernet0/0

Naszym celem jest usunięcie sieci 3.3.0.0/24 oraz 3.3.2.0/24. W pierwszym kroku dodamy standardową listę dostępu:

R2(config)#ip access-list standard 1  
R2(config-std-nacl)#10 deny 3.3.0.0 0.0.0.255 
R2(config-std-nacl)#11 deny 3.3.2.0 0.0.0.255 
R2(config-std-nacl)#permit any
R2#show ip access-lists 
Standard IP access list 1
    10 deny   3.3.0.0, wildcard bits 0.0.0.255
    11 deny   3.3.2.0, wildcard bits 0.0.0.255
    21 permit any

Każdy wpis dotyczący sieci 3.3.0.0/24 oraz 3.3.2.0/24 zostanie odrzucony. Na końcu musimy dodać wpis permit any, ponieważ do każdej listy dostępu na samym końcu dodawana jest linia deny any. W trybie konfiguracji RIP przypisujemy naszą listę do distribute-list dla ruchu przychodzącego:

R2(config)#router rip 
R2(config-router)#distribute-list 1 in

A po pewnyn czasie tablica routingu na R3 wygląda tak:

R2#show ip route rip 
     1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/2] via 172.16.23.3, 00:00:16, FastEthernet0/0
     3.0.0.0/24 is subnetted, 2 subnets
R       3.3.1.0 [120/1] via 172.16.23.3, 00:00:16, FastEthernet0/0
R       3.3.3.0 [120/1] via 172.16.23.3, 00:00:16, FastEthernet0/0
     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.13.0 [120/1] via 172.16.23.3, 00:00:16, FastEthernet0/0

(jeżeli nie chcemy czekać prawie 4 minut aż zmiany zostaną zapisane w tablicy routingu, można użyć polecenia clear ip route).

Zostaw komentarz


Podpowiedź - możesz użyć tych HTML tagów i atrybutów:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Obraz CAPTCHY

*