Strongswan IPSEC Linux SWANCTL PSK VTI - Security und Firewall Labor
Zur Navigation springen
Zur Suche springen
Installation
- apt update
- apt install strongswan strongswan-swanctl libstrongswan-extra-plugins
Voraussetzungen
- Beide Systeme: Linux mit strongSwan und swanctl
- Es wird ausschließlich VICI (swanctl) verwendet, keine ipsec.conf
- XX eigene Seite, gegenüberliegende Seite YY
Szenario
| Einstellung | fw.it2XX.int | fw.it2YY.int |
|---|---|---|
| IP Address | 192.168.hs.2XX | 192.168.hs.2YY |
| Internes Netz | 172.26.2XX.0/24, 10.2XX.1.0/24 | 172.26.2YY.0/24, 10.2YY.1.0/24 |
| Tunnel-IP (vti0) | 169.254.100.1 | 169.254.100.2 |
| Pre-Shared Key (PSK) | 123Start$ | |
| Phase 1 | AES256 – SHA256 – DH16 | |
| Phase 2 | AES256 – SHA256 – DH16 | |
VICI aktivieren
- vim /etc/strongswan.d/charon/vici.conf
load = yes
Damit Verbindungen beim Start geladen werden
- vim /etc/strongswan.conf
charon {
load_modular = yes
plugins {
include strongswan.d/charon/*.conf
}
start-scripts {
load-all = /usr/sbin/swanctl --load-all
}
}
include strongswan.d/*.conf
VTI-Modul laden und rebootfähig machen
- modprobe -v ip_vti
- echo "ip_vti" >> /etc/modules
Konfiguration
- Diese Datei ist auf beiden Seiten identisch aufgebaut – nur die Adressen unterscheiden sich.
- vim /etc/swanctl/swanctl.conf
connections {
vti {
local_addrs = 192.168.hs.2XX
remote_addrs = 192.168.hs.2YY
local {
auth = psk
id = 192.168.hs.2XX
}
remote {
auth = psk
id = 192.168.hs.2YY
}
children {
vti-child {
local_ts = 0.0.0.0/0
remote_ts = 0.0.0.0/0
mode = tunnel
start_action = trap
esp_proposals = aes256-sha256-modp4096
reqid = 10
dpd_action = clear
policies = no
vti {
interface_id = 10
mark_in = 10
mark_out = 10
}
}
}
version = 2
proposals = aes256-sha256-modp4096
}
}
secrets {
ike-psk {
id-1 = 192.168.hs.2XX
id-2 = 192.168.hs.2YY
secret = "123Start$"
}
}
VTI-Interface erstellen
Manuell zum Testen
- ip tunnel add vti0 mode vti local 192.168.hs.2XX remote 192.168.hs.2YY key 10
- ip link set vti0 up
- ip addr add 169.254.100.1/30 dev vti0
- ip route add 172.26.2YY.0/24 dev vti0
- ip route add 10.2YY.1.0/24 dev vti0
Statisch und rebootfähig
- vim /etc/network/interfaces
auto vti0 iface vti0 inet static address 169.254.100.1/30 pre-up ip tunnel add vti0 mode vti local 192.168.hs.2XX remote 192.168.hs.2YY key 10 up ip link set vti0 up post-up ip route add 172.26.2YY.0/24 dev vti0 post-up ip route add 10.2YY.1.0/24 dev vti0 post-down ip tunnel del vti0
Dienst starten
- systemctl enable strongswan-swanctl
- systemctl start strongswan-swanctl
- swanctl --load-all
Verbindung prüfen
- Listet alle geladenen Verbindungen aus swanctl.conf
- swanctl -L
- Zeigt aktive IKE- und CHILD-SAs, wenn der Tunnel aufgebaut ist
- swanctl -l
- Journalctl zur Fehlerdiagnose
- journalctl -u strongswan-swanctl
Fehlerbehandlung
Falls beim Initiieren der Verbindung folgende Meldung erscheint:
not establishing CHILD_SA ... due to existing duplicate
→ Tunnel ist bereits aktiv. Prüfung mit:
- swanctl --list-sas
Neuaufbau erzwingen mit:
- swanctl --terminate --child vti-child
- swanctl --initiate --child vti-child