doc:appunti:linux:sa:ipsec_strongswan
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:linux:sa:ipsec_strongswan [2021/02/05 16:16] – [Servizi systemd] niccolo | doc:appunti:linux:sa:ipsec_strongswan [2023/11/14 11:27] (current) – [File di configurazione] niccolo | ||
---|---|---|---|
Line 10: | Line 10: | ||
In alternativa al pacchetto **strongswan** è possibile installare **[[# | In alternativa al pacchetto **strongswan** è possibile installare **[[# | ||
+ | |||
+ | ===== File di configurazione ===== | ||
+ | |||
+ | Qesti gli indirizzi IP coinvolti: | ||
+ | |||
+ | * **Lato Left (host locale)** | ||
+ | * IP pubblico: **132.82.168.98** | ||
+ | * Classe IP privata: **172.17.48.96/ | ||
+ | * **Lato Right (host remoto)** | ||
+ | * IP pubblico: **134.191.21.5** | ||
+ | * Classe IP privata: **172.17.48.80/ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | config setup | ||
+ | # strictcrlpolicy=yes | ||
+ | # uniqueids = no | ||
+ | charondebug=" | ||
+ | # More control on Charon debug. Default level is 1 " | ||
+ | # level 2 is " | ||
+ | # | ||
+ | uniqueids = yes | ||
+ | |||
+ | include / | ||
+ | </ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | include / | ||
+ | </ | ||
+ | |||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | conn office1-office2 | ||
+ | type=tunnel | ||
+ | auto=start | ||
+ | keyexchange=ikev2 | ||
+ | authby=secret | ||
+ | left=132.82.168.98 | ||
+ | leftsubnet=172.17.48.97/ | ||
+ | right=134.191.21.5 | ||
+ | rightsubnet=172.17.48.81/ | ||
+ | ike=aes256-sha256-modp1536 | ||
+ | esp=aes256-sha256-modp1536 | ||
+ | aggressive=no | ||
+ | keyingtries=%forever | ||
+ | ikelifetime=86400s | ||
+ | lifetime=28800s | ||
+ | dpddelay=30s | ||
+ | dpdtimeout=120s | ||
+ | dpdaction=restart | ||
+ | closeaction=restart | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | charon: 07[IKE] received DELETE for IKE_SA office1-office2[5] | ||
+ | charon: 07[IKE] deleting IKE_SA office1-office2[5] | ||
+ | between 132.82.168.98[213.182.68.98]...134.191.21.5[134.191.21.5] | ||
+ | ipsec[30830]: | ||
+ | ipsec[30830]: | ||
+ | between 132.82.168.98[213.182.68.98]...134.191.21.5[134.191.21.5] | ||
+ | </ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | # ------- Site 1 Gateway (office1-office2) ------- | ||
+ | 132.82.168.98 134.191.21.5 : PSK " | ||
+ | |||
+ | # ------- Site 2 Gateway (office2-office1) ------- | ||
+ | 134.191.21.5 132.82.168.98 : PSK " | ||
+ | </ | ||
+ | |||
+ | ===== Configurazione Shorewall ===== | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | ACCEPT | ||
+ | ACCEPT | ||
+ | ACCEPT | ||
+ | </ | ||
+ | |||
+ | **ATTENZIONE**: | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | ipsec net 134.191.21.5 | ||
+ | </ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | sec ipv4 | ||
+ | </ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | sec eth0: | ||
+ | </ | ||
===== Abilitare e avviare il servizio ===== | ===== Abilitare e avviare il servizio ===== | ||
Line 22: | Line 130: | ||
===== Verifica ===== | ===== Verifica ===== | ||
+ | |||
+ | ==== Avvio della connessione ==== | ||
+ | |||
+ | Per avviare la VPN si può utilizzare il comando **ipsec start** (attenzione, | ||
+ | |||
+ | < | ||
+ | ipsec start | ||
+ | Starting strongSwan 5.7.2 IPsec [starter]... | ||
+ | </ | ||
+ | |||
+ | In **syslog** si trovano le seguenti righe: | ||
+ | |||
+ | < | ||
+ | charon: 00[DMN] Starting IKE charon daemon (strongSwan 5.7.2, Linux 4.19.0-12-amd64, | ||
+ | charon: 07[IKE] initiating IKE_SA office1-office2[1] to 134.191.21.5 | ||
+ | charon: 07[NET] sending packet: from 132.82.168.98[500] to 134.191.21.5[500] (932 bytes) | ||
+ | charon: 09[NET] received packet: from 134.191.21.5[500] to 132.82.168.98[500] (360 bytes) | ||
+ | charon: 09[IKE] authentication of ' | ||
+ | charon: 09[IKE] establishing CHILD_SA office1-office2{1} | ||
+ | charon: 10[IKE] CHILD_SA office1-office2{1} established with SPIs cdd18e01_i ... | ||
+ | </ | ||
+ | |||
+ | In Debian 10, che utilizza systemd, è opportuno utilizzare **systemctl** invece di invocare direttamente **ipsec** (che supporta gli eventuali parametri '' | ||
+ | |||
+ | ==== Tracciato tcpdump ==== | ||
+ | |||
+ | Con tcpdump è possibile vedere l' | ||
+ | |||
+ | < | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | 18: | ||
+ | </ | ||
+ | ==== Verifica stato della connessione ==== | ||
Per verificare lo stato della VPN si utilizza il comando **ipsec statusall**, | Per verificare lo stato della VPN si utilizza il comando **ipsec statusall**, | ||
Line 39: | Line 186: | ||
office1-office2: | office1-office2: | ||
office1-office2: | office1-office2: | ||
- | office1-office2: | + | office1-office2: |
Security Associations (1 up, 0 connecting): | Security Associations (1 up, 0 connecting): | ||
office1-office2[1]: | office1-office2[1]: | ||
Line 52: | Line 199: | ||
Se la VPN non è attiva, l' | Se la VPN non è attiva, l' | ||
- | Per avviare la VPN si può utilizzare il comando **ipsec start** (attenzione, | ||
- | < | + | ==== Connessione PSK fallita ==== |
- | ipsec start | + | |
- | Starting strongSwan 5.7.2 IPsec [starter]... | + | |
- | </ | + | |
- | In **syslog** si trovano le seguenti righe: | + | Ecco cosa appare in syslog |
< | < | ||
- | charon: | + | charon: |
- | charon: | + | charon: |
- | charon: | + | charon: |
- | charon: 09[NET] received packet: from 134.191.21.5[500] to 132.82.168.98[500] (360 bytes) | + | charon: 13[IKE] remote host is behind NAT |
- | charon: | + | charon: 14[CFG] looking for peer configs matching |
- | charon: | + | charon: 14[CFG] selected peer config ' |
- | charon: 10[IKE] CHILD_SA office1-office2{1} established with SPIs cdd18e01_i ... | + | charon: |
+ | charon: | ||
</ | </ | ||
- | |||
- | In Debian 10, che utilizza systemd, è opportuno utilizzare **systemctl** invece di invocare direttamente **ipsec** (che supporta gli eventuali parametri '' | ||
===== Servizi systemd ===== | ===== Servizi systemd ===== |
doc/appunti/linux/sa/ipsec_strongswan.1612538202.txt.gz · Last modified: 2021/02/05 16:16 by niccolo