В данной статье мы рассмотрим пример конфигурирования аутентификации для протокола OSPFv2.
Оборудование ME поддерживает следующие алгоритмы шифрования для OSPFv2:
simple password; md5; hmacsha1; hmacsha256; hmacsha384; hmacsha512; key-chain;
Cхема демонстрационного стенда:
Для дальнейшей диагностики мы включим debug ospfv2 и вывод сообщений отладки в терминал командами:
debug ospfv2 all; logging monitor debug;
Для всех тестов данной статьи : authentication-key eltex == authentication-key encrypted 99B81768A8.
Применим конфигурацию на R2, а на R1 оставим без аутентификации:
0/ME5200:R1# show running-config router ospfv2 ! Configuration version 3.5.0.563R router ospfv2 CORE area 0.0.0.0 interface tengigabitethernet 0/0/23 network point-to-point exit exit exit
0/ME5200:R2# show running-config router ospfv2 ! Configuration version 3.5.0.563R router ospfv2 CORE area 0.0.0.0 interface tengigabitethernet 0/0/31 authentication-key encrypted 99B81768A8 <----- Конфигурация пароля шифрования authentication-type simple-password <----- Конфигурация алгоритма шифрования network point-to-point exit exit exit
%OSPF_V2-D-NM: OSPF 4 Packet received with unexpected authentication type 1. Expected authentication type = 0. Packet data = 45C00040 38A30000 01592B6E B9A8BAE6 E0000005 0201002C B9A8BADA 00000000
Соответственно, соседство не поднимется:
0/ME5200:R1# show ospfv2 neighbors Tue Jun 23 13:32:03 2023 Routing Process: CORE, ID 1.1.1.1 Router is not an area border router
Если же добавить конфигурацию аутентификации authentication-key и authentication-type simple-password то соседство ожидаемо поднимется:
0/ME5200:R1# show running-config router ospfv2 router ospfv2 CORE area 0.0.0.0 interface tengigabitethernet 0/0/23 authentication-key encrypted 99B81768A8 authentication-type simple-password network point-to-point exit exit exit
%OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to INIT %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to TWO WAY %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to LOADING %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to FULL
Что касаемо типов AuthType, которые вы можете встретить в сообщениях отладки:
AuthType=0 (no Authentication) AuthType=1 (simple password) AuthType=2 (CryptoAuth) AuthType=3 (это локальное значение для маршрутизатора - CryptoAuth + HMAC SHA1, в пакет устанавливается значение AuthType=2) AuthType=4 (это локальное значение для маршрутизатора - CryptoAuth + HMAC SHA256, в пакет устанавливается значение AuthType=2) AuthType=5 (это локальное значение для маршрутизатора - CryptoAuth + HMAC SHA384, в пакет устанавливается значение AuthType=2) AuthType=6 (это локальное значение для маршрутизатора - CryptoAuth + HMAC SHA512, в пакет устанавливается значение AuthType=2)
Настройка других алгоритмов шифрования аналогична, меняется только конфигурация authentication-type, поэтому их пример конфигурации не приводится.
С целью обеспечения совместимости с некоторыми реализациями OSPFv2 сторонних производителей, на маршрутизаторах ME реализована возможность задания поля authentication key id в пакетах OSPFv2 вручную.
При использовании криптографических методов аутентификации пакетов OSPFv2 (Auth Type =2), ME по умолчанию устанавливают значение authentication key id =1, к примеру, Juniper выставляет 0.
0/ME5200:R1# show running-config router ospfv2 ! Configuration version 3.5.0.563R router ospfv2 1 area 0.0.0.0 interface tengigabitethernet 0/0/23 authentication-id 5 authentication-key encrypted 99B81768A8 authentication-type hmacsha256 exit exit exit
0/ME5200:R2# show running-config router ospfv2 ! Configuration version 3.5.0.563R router ospfv2 1 area 0.0.0.0 interface tengigabitethernet 0/0/31 authentication-id 255 authentication-key encrypted 99B81768A8 authentication-type hmacsha256 exit exit exit
2023-06-22T09:30:31.481101+00:00 %OSPF_V2-D-NM: OSPF 1 Packet cannot be authenticated. Diagnostic information for support: Packet data = 0201002C 05050505 00000000 00000002 0000 >FF< 20 00006559 FFFFFFFC 000A0201 00000028 01000002 00000000 Error code (from A0AUTH_GET_KEY) = 3 Данный байт отвечает за поле authentication-id (FF = 255)
%OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to INIT %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to TWO WAY %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to LOADING %OSPF_V2-W-ADJCHANGE: Router 0.0.0.0: Nbr 5.5.5.5 at 1.0.0.2, interface te0/0/23 changed state to FULL
Далее разберем с вами особенности конфигурирования аутентификации посредством Key-chain.
В качестве примера приведем пример, когда key-chain содержит 2 ключа.
Cхема демонстрационного стенда:
0/ME5200:R1# show running-config key-chain Fri Jun 23 10:42:14 2023 ! Configuration version 3.5.0.563R key-chain 1 <----- Конфигурационный блок key-chain key 2 accept-lifetime <----- Конфигурация времени жизни ключа duration 315576000 start-time 2020.01.01-00:00:00 exit authentication-key encrypted 99B81768A8 authentication-type hmacsha256 send-lifetime <----- Конфигурация времени отправки ключа duration 315576000 <----- Конфигурация продолжительность отправки ключа start-time 2020.01.01-00:00:00 exit exit key 3 accept-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit authentication-key encrypted 99B81768A8 authentication-type hmacsha384 send-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit exit exit 0/ME5200:R1# show running-config router ospfv2 Fri Jun 23 10:47:52 2023 ! Configuration version 3.5.0.563R router ospfv2 1 area 0.0.0.0 interface tengigabitethernet 0/0/23 authentication-key-chain 1 <----- Конфигурация алгоритма шифрования network point-to-point exit interface tengigabitethernet 0/0/31 authentication-key-chain 1 network point-to-point exit exit exit
0/ME5200:R2# show running-config key-chain Fri Jun 23 10:38:49 2023 ! Configuration version 3.5.0.563R key-chain 1 key 3 accept-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit authentication-key encrypted 99B81768A8 authentication-type hmacsha384 send-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit exit exit 0/ME5200:R2# show running-config router ospfv2 Fri Jun 23 10:43:46 2023 ! Configuration version 3.5.0.563R router ospfv2 1 area 0.0.0.0 interface tengigabitethernet 0/0/31 authentication-key-chain 1 network point-to-point exit exit exit
0/ME5200:R3# show running-config key-chain Fri Jun 23 10:38:49 2023 ! Configuration version 3.5.0.563R key-chain 1 key 2 accept-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit authentication-key encrypted 99B81768A8 authentication-type hmacsha384 send-lifetime duration 315576000 start-time 2020.01.01-00:00:00 exit exit exit 0/ME5200:R3# show running-config router ospfv2 Fri Jun 23 10:43:46 2023 ! Configuration version 3.5.0.563R router ospfv2 1 area 0.0.0.0 interface tengigabitethernet 0/0/32 authentication-key-chain 1 network point-to-point exit exit exit
Среди ключей, чье время send-lifetime и start-time уже наступило, для расчета хэша отправляемых сообщений выбирается ключ с наиболее длинным временем жизни.
Если длительность времени жизни равна, то выбирается ключ с наибольшим Key ID.
В данном случае маршрутизатор R1 имеет 2 линка до R2 и R3. До R2 используется key3, а до R3 key2, но так как key3 имеет больший key id, то соседство поднимется с R2.
0/ME5200:R1# show ospfv2 neighbors 2023-06-23T07:42:40.585381+00:00 %KLISH-I-COMMAND: From klish terminal [user='admin' host='0.0.0.0' terminal='console' vrf='default'] command: 'show ospfv2 neighbors' Fri Jun 23 07:42:40 2023 Routing Process: 1, ID 1.1.1.1 Router is not an area border router Neighbor ID Area ID Pri State BFD Dead Time Last state change Address Interface ---------------- ---------------- ---- ------------------- ------------- ---------- ------------------ ---------------- ---------- 2.2.2.2 0.0.0.0 1 full not-required 00:00:35 00h00m14s 1.0.0.2 te0/0/23 3.3.3.3 0.0.0.0 1 init not-required 00:00:38 00h00m11s 2.0.0.2 te0/0/31