categories | title |
---|---|
openbsd network vpn security ipsec | Howto IKED |
Documentation :
IKED est le démon utilisé sous OpenBSD pour mettre en place un VPN IPsec avec IKEv2.
On met en place un VPN entre 2 machines OpenBSD :
Sur GW1 :
Vérification de l'activation des paramètres sysctl :
# sysctl net.inet.esp.enable
net.inet.esp.enable=1
# sysctl net.inet.ah.enable
net.inet.ah.enable=1
# sysctl net.inet.ip.forwarding
net.inet.ip.forwarding=1
Activation de l'interface enc0 :
# ifconfig enc0 up
# echo up >/etc/hostname.enc0
Configuration de /etc/pf.conf :
set skip on {lo0 enc0}
pass in on $ext_if proto esp from $addr_gw2 to ($ext_if)
pass in on $ext_if proto udp from $addr_gw2 to ($ext_if) port {isakmp, ipsec-nat-t}
Et application des modifications :
# pfctl -nf /etc/pf.conf && pfctl -f /etc/pf.conf
Configuration de /etc/iked.conf :
local_ip="192.0.2.254"
local_network="203.0.113.0/25"
remote_ip="198.51.100.254"
remote_network="203.0.113.128/25"
ikev2 active esp \
from $local_network to $remote_network \
local $local_ip peer $remote_ip \
ikesa auth hmac-sha2-256 enc aes-256 prf hmac-sha2-256 group modp4096 \
childsa auth hmac-sha1 enc aes-256 group modp4096 \
ikelifetime 86400 lifetime 3600 \
psk "PSK-TO-CONFIGURE"
Les paramètres ikesa
et ikelifetime
correspondants à la phase 1, childsa
et lifetime
à la phase 2.
Test de la configuration :
# iked -nf /etc/iked.conf
configuration OK
Activation et démarrage de iked :
# rcctl enable iked
# rcctl start iked
Puis effectuer les mêmes actions sur l'autre passerelle.
Dans le cas où l'on veut atteindre plusieurs réseaux locaux distants, il suffit d'ajouter une ligne from $local_network to $remote_network_second \
, ce qui donne :
local_ip="192.0.2.254"
local_network="203.0.113.0/25"
remote_ip="198.51.100.254"
remote_network="203.0.113.128/26"
remote_network_second="203.0.113.192/26"
ikev2 active esp \
from $local_network to $remote_network \
from $local_network to $remote_network_second \
local $local_ip peer $remote_ip \
ikesa auth hmac-sha2-256 enc aes-256 prf hmac-sha2-256 group modp4096 \
childsa auth hmac-sha1 enc aes-256 group modp4096 \
ikelifetime 86400 lifetime 3600 \
psk "PSK-TO-CONFIGURE"
Note : Attention cependant, il y a visiblement des soucis avec OpenBSD lorsque l'on veut monter plusieurs sous-réseaux en IKEv2 : un seul sous-réseau est fonctionnel. Il vaut mieux pour ce cas passer à IKEv1
# ikectl reset all
# ikectl load /etc/iked.conf
# tail -f /var/log/daemon | grep iked
# ipsecctl -sa
Couper iked et le relancer :
# rcctl stop iked
# iked -dvvv -f /etc/iked.conf