1. Подготовка CA на Linux

Для начала создадим простую структуру CA и выпустим корневой сертификат.

  1. Создаем ключи CA:
openssl genrsa -out ca.key
openssl req -x509 -key ca.key  -out ca.crt
  1. Выпускаем сертификаты для роутеров (Hub и Spoke):
openssl genrsa -out private/hub.key
openssl req -new -key private/hub.key -out newcerts/hub.req
openssl x509 -req -in newcerts/hub.req -CA ca.crt -CAkey ca.key -CAcreateserial -out certs/hub.crt
 
openssl genrsa -out private/spoke.key
openssl req -new -key private/spoke.key -out newcerts/spoke.req
openssl x509 -req -in newcerts/spoke.req -CA ca.crt -CAkey ca.key -CAcreateserial -out certs/spoke.crt
 
 
# Надо пароль поставит
openssl pkcs12 -export -legacy -out vpn/hub.p12 -inkey private/hub.key -in certs/hub.crt -certfile ca.crt
openssl pkcs12 -export -legacy -out vpn/spoke.p12 -inkey private/spoke.key -in certs/spoke.crt -certfile ca.crt
 

2. Импорт сертификатов на Cisco (Hub/Spoke) через http

Теперь нужно перенести файлы .p12 на роутеры (через TFTP/SCP) и импортировать их.

Фрагмент кода

! Копирование сертификатов
copy http://192.168.10.2/hub.p12 flash:

crypto pki import MY_CA pkcs12 flash:hub.p12 password <ваш_пароль>

3. Настройка ikev и IPsec профиля с сертификатами

Вместо привычного pre-shared-key мы указываем использование RSA-сигнатур.

# --- 1. Настройка параметров IKEv2 (Proposal и Policy) ---
crypto ikev2 proposal DMVPN_PROP 
 encryption aes-cbc-256
 integrity sha256
 group 14

crypto ikev2 policy DMVPN_POLICY 
 proposal DMVPN_PROP

# --- 2. Профиль IKEv2: связываем сертификаты с туннелем ---
crypto ikev2 profile IKEV2_PROF
 match identity remote address 0.0.0.0
 identity local address 192.168.0.1 # 192.168.0.1 - ip у внешнего устройства 
 authentication local rsa-sig
 authentication remote rsa-sig
 pki trustpoint MY_CA
 exit
 
crypto pki trustpo MY_CA 
 revocation-check none 

# --- 3. Настройка IPsec (Шифрование данных) ---
crypto ipsec transform-set TRANS esp-aes 256 esp-sha256-hmac 
 mode transport

crypto ipsec profile DMVPN
 set transform-set TRANS
 set ikev2-profile IKEV2_PROF


4. Настройка интерфейса тунеля


 # Hub
 interface Tunnel0
 ip address 10.0.0.1 255.255.255.0
 tunnel source g0/0
 tunnel mode gre ip 
 tunnel key 999
 tunnel destination 192.168.0.1
 tunnel protection ipsec profile DMVPN
 
 # Spoke
 interface Tunnel0
 ip address 10.0.0.2 255.255.255.0
 tunnel source g0/0
 tunnel mode gre ip 
 tunnel key 999
 tunnel destination 192.168.0.2
 tunnel protection ipsec profile DMVPN