OSPF – wybór DR (designated router) oraz BDR (backup designated router)

Cele:

Adresy IP routerów:

R1

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

R2

Interfejs IP
FastEthernet 0/0 172.16.0.2/24
Loopback 0 2.2.2.2/24

R3

Interfejs IP
FastEthernet 0/0 172.16.0.3/24
Loopback 0 3.3.3.3/24

R4

Interfejs IP
FastEthernet 0/0 172.16.0.4/24
Loopback 0 4.4.4.4/24

Schemat sieci:

ospf - wybór designated router i backup designated router

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

Rozwiązanie

Skonfiguruj OSPF (AREA 0) na wszystkich routerach i rozgłoś wszystkie podłączone podsieci. Upewnij się, że możesz pingować interfejsy Loopback0 z wszystkich routerów.

Na każdym z routerów uruchamiamy proces OSPF (Process ID = 1) i rozgłosimy wszystkie podłączone podsieci używając polecenia network 0.0.0.0 255.255.255.255 area 0. Wszystkie routery podłączone są do tej samej podsieci (172.16.0.0/24):

R1(config)#router ospf 1
R1(config-router)#network 0.0.0.0 255.255.255.255 area 0
R1(config-router)#exit
R2(config)#router ospf 1
R2(config-router)#network 0.0.0.0 255.255.255.255 area 0
R2(config-router)#exit
R3(config)#router ospf 1
R3(config-router)#network 0.0.0.0 255.255.255.255 area 0
R3(config-router)#exit
R4(config)#router ospf 1
R4(config-router)#network 0.0.0.0 255.255.255.255 area 0
R4(config-router)#exit

Po krótkiej chwili relacja sąsiedztwa zostaje nawiązana a w tablicy routingu pojawią się sieci z interfejsów Loopback:

R1#show ip route ospf 
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 172.16.0.2, 00:02:28, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/2] via 172.16.0.3, 00:02:28, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/2] via 172.16.0.4, 00:02:28, FastEthernet0/0

Spróbujemy polecenia ping do routerów R2, R3 i R4:

R1#ping 2.2.2.2 source l0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, 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 = 20/44/104 ms
R1#ping 3.3.3.3 source l0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, 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 = 16/28/60 ms
R1#ping 4.4.4.4 source l0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, 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 = 16/20/24 ms

Który z routerów został wybrany jako Designated router a który jako Backup designated router. Dlaczego?

W celu zmniejszenia ilości wysyłanych informacji na temat routingu, routery w OSPF wybierają tzw. router desygnowany DR (designated router) oraz zapasowy BDR (backup designated router). To one właśnie wymieniają informacje o stanie łączy z pozostałymi routerami. Router DR komunikuje się z pozostałymi korzystając z adresu 224.0.0.5. Routery DR i BDR nie występują w sieciach typu point-to-point.
Routerem DR zostaje router o najwyższym priorytecie w danej strefie. Jeżeli wszystkie routery mają ten sam priorytet, wtedy kolejnym kryterium wyboru jest router id (RID). Wyższy RID wygrywa. Wartości te możemy poznać korzystając z polecenia show ip ospf interface

R1#show  ip ospf interface       
Loopback0 is up, line protocol is up 
  Internet Address 1.1.1.1/24, Area 0 
  Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
FastEthernet0/0 is up, line protocol is up 
  Internet Address 172.16.0.1/24, Area 0 
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 1

Wartość RID dla R1 to 1.1.1.1 a priorytet równa się 1. Dla routerów R2, R3 i R3 priorytet też wynosi 1, natomiast wartość RID jest taka sama jak adres IP interfejsu Loopback. Powodem tego jest to, że wartość RID jest taka jak najwyższy adres IP na dowolnym interfejsie w momencie startu procesu OSPF. Z tym, że interfejsy logiczne mają zawsze większy priorytet niż fizyczne, dlatego dla routera R3 RID wynosi 3.3.3.3 a nie 172.16.0.3.
Tak więc w naszym przykładzie routerem DR zostanie R4, a BDR router R3:

R4#show ip ospf interface 
Loopback0 is up, line protocol is up 
  Internet Address 4.4.4.4/24, Area 0 
  Process ID 1, Router ID 4.4.4.4, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
FastEthernet0/0 is up, line protocol is up 
  Internet Address 172.16.0.4/24, Area 0 
  Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DR, Priority 1

Potwierdzenie mamy w ostatniej linii powyżej (State DR, Priority 1). Można też skorzystać z polecenia show ip ospf neighbor np. na routerze R2:

R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   2WAY/DROTHER    00:00:36    172.16.0.1      FastEthernet0/0
3.3.3.3           1   FULL/BDR        00:00:38    172.16.0.3      FastEthernet0/0
4.4.4.4           1   FULL/DR         00:00:32    172.16.0.4      FastEthernet0/0

Natomiast wynik tego samego polecenia na routerze R3:

R3#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DROTHER    00:00:32    172.16.0.1      FastEthernet0/0
2.2.2.2           1   FULL/DROTHER    00:00:33    172.16.0.2      FastEthernet0/0
4.4.4.4           1   FULL/DR         00:00:38    172.16.0.4      FastEthernet0/0

Tutaj oczywiście nie ma wpisu o routerze 3.3.3.3 ponieważ to na nim wpisaliśmy polecenie. Ale w przypadku kiedy brakuje nam informacji o BDR (lub DR) możemy wnioskować, że to właśnie router na którym wykonaliśmy polecenie jest routerem BDR (lub DR).


Router R2 ma zostać nowym BDR. Zrób to zmieniając adres IP routera R3.

Chcemy, żeby to router R2 został nowym BDR. Router ID od R3 wynosi 3.3.3.3, a dla R2 2.2.2.2. Ponieważ zmienić możemy tylko konfigurację na R3, musimy zmniejszyć jego RID poniżej wartości 2.2.2.2. Tak jak wspomnieliśmy wyżej, wartość RID określona została na podstawie adresu IP interfejsu Loopback. Zmienimy zatem adres na 2.2.0.3 na routerze R3:

R3(config)#int
R3(config)#interface l0
R3(config-if)#ip address 2.2.0.3 255.255.255.0
R3#show ip ospf interface 
Loopback0 is up, line protocol is up 
  Internet Address 2.2.0.3/24, Area 0 
  Process ID 1, Router ID 3.3.3.3, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
FastEthernet0/0 is up, line protocol is up 
  Internet Address 172.16.0.3/24, Area 0

Musimy też zresetować proces OSPF na R3, ponieważ wartość RID określana jest podczas startu OSPF:

R3#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R3#
*Mar  1 00:44:35.299: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from 2WAY to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:44:35.303: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:44:35.311: %OSPF-5-ADJCHG: Process 1, Nbr 4.4.4.4 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
R3#show ip ospf interface 
Loopback0 is up, line protocol is up 
  Internet Address 2.2.0.3/24, Area 0 
  Process ID 1, Router ID 2.2.0.3, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
FastEthernet0/0 is up, line protocol is up 
  Internet Address 172.16.0.3/24, Area 0 
  Process ID 1, Router ID 2.2.0.3, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 1

Po restarcie identyfikator routera ma już nową wartość oraz dodatkowo R3 nie jest już dłużej BDR (State DROTHER, Priority 1). Zobaczmy czy R2 został nowym BDR:

R3#show ip ospf neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   2WAY/DROTHER    00:00:38    172.16.0.1      FastEthernet0/0
2.2.2.2           1   FULL/BDR        00:00:39    172.16.0.2      FastEthernet0/0
4.4.4.4           1   FULL/DR         00:00:34    172.16.0.4      FastEthernet0/0

Wszystko się zgadza, R4 wciąż jest routerem desygnowany, natomiast R2 jest teraz BDR.


Router R1 ma zostać nowym DR. Zrób to zmieniając parametr priority.

Zgodnie z zasadami routerem DR zostanie ten, który ma najwyższy priorytet. Domyślnie wartość ta ustawiona jest na 1. W trybie konfiguracji interfejsu routera R1 zwiększamy ją na 10:

R1(config)#int f0/0
R1(config-if)#ip ospf priority 10

Zmiana priorytetu jest widoczna od razu przez inne routery, jednak wciąż R4 jest routerem DR:

R3#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1          10   2WAY/DROTHER    00:00:38    172.16.0.1      FastEthernet0/0
2.2.2.2           1   FULL/BDR        00:00:39    172.16.0.2      FastEthernet0/0
4.4.4.4           1   FULL/DR         00:00:34    172.16.0.4      FastEthernet0/0

Restartujemy proces OSPF na wszystkich routerach:

R1#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R2#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R3#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R4#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes

Wyświetlamy teraz listę sąsiadów routera R2:

R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1          10   FULL/DR         00:00:33    172.16.0.1      FastEthernet0/0
2.2.0.3           1   2WAY/DROTHER    00:00:32    172.16.0.3      FastEthernet0/0
4.4.4.4           1   FULL/BDR        00:00:36    172.16.0.4      FastEthernet0/0

R1 został nowym DR, natomiast R4 jest nowym BDR (ma taki sam priorytet jak R2, ale wyższy adres IP).


R2: zmień jego identyfikator na 22.22.22.22.

Zmieniając identyfikator routera (RID) możemy też wpłynąć na to, który z routerów zostanie wybrany jako DR i BDR. Zmian dokonujemy w trybie konfiguracji OSPF poleceniem router-id 22.22.22.22:

R2(config)#router  ospf 1
R2(config-router)#router-id 22.22.22.22 
Reload or use "clear ip ospf process" command, for this to take effect

Musimy zrestartować proces OSPF (dla pewności na wszystkich routerach):

R1#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R2#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R3#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes
R4#clear ip ospf process 
Reset ALL OSPF processes? [no]: yes

Router R1 posiada najwyższy priorytet (10), więc wciąż pozostaje DR. Natomiast R2 został wybrany jako BDR (State BDR, Priority 1):

R2#show ip ospf interface
Loopback0 is up, line protocol is up 
  Internet Address 2.2.2.2/24, Area 0 
  Process ID 1, Router ID 22.22.22.22, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
FastEthernet0/0 is up, line protocol is up 
  Internet Address 172.16.0.2/24, Area 0 
  Process ID 1, Router ID 22.22.22.22, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State BDR, Priority 1 
  Designated Router (ID) 1.1.1.1, Interface address 172.16.0.1
  Backup Designated router (ID) 22.22.22.22, Interface address 172.16.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:06
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 3
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 3, Adjacent neighbor count is 3 
    Adjacent with neighbor 1.1.1.1  (Designated Router)
    Adjacent with neighbor 2.2.0.3
    Adjacent with neighbor 4.4.4.4
  Suppress hello for 0 neighbor(s)

i lista sąsiadów z R4:

R4#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1          10   FULL/DR         00:00:35    172.16.0.1      FastEthernet0/0
2.2.0.3           1   2WAY/DROTHER    00:00:34    172.16.0.3      FastEthernet0/0
22.22.22.22       1   FULL/BDR        00:00:39    172.16.0.2      FastEthernet0/0

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

*