User Tools

Site Tools


doc:appunti:linux:sa:ipsec

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:linux:sa:ipsec [2015/09/21 18:33] – [Client Router DrayTek Vigor 2500/2600] niccolodoc:appunti:linux:sa:ipsec [2016/12/13 11:37] – [Configurazione Debian 8 Jessie] niccolo
Line 1: Line 1:
 ====== IPSEC con Debian GNU/Linux ====== ====== IPSEC con Debian GNU/Linux ======
  
 +===== Configurazione Debian 8 Jessie =====
 +
 +IPSEC - su una distribuzione Debian moderna - si basa sui servizi **Setkey** e **Racoon**, questi servizi si avviano con **systemd**.
 +
 +Configuriamo ad esempio  una VPN con nome **static-psk-test**, con indirizzi IP statici e pre-shared key. Gli indirizzi IP privati e pubblici in questione sono:
 +
 +(LAN 192.168.10.0/24) -> (Firewall 5.10.168.170)  <->  (Firewall 5.20.195.220) <- (LAN 192.168.20.0/24)
 +
 +In generale i file di configurazione sono questi (si esamina il firewall 5.10.168.170):
 +
 +**/etc/ipsec-tools.d/static-psk-test.conf**
 +
 +<file>
 +spdadd 192.168.10.0/24  192.168.20.0/24  any -P out ipsec esp/tunnel/5.10.168.170-5.20.195.220/unique;
 +spdadd 192.168.20.0/24  192.168.10.0/24  any -P in  ipsec esp/tunnel/5.20.195.220-5.10.168.170/unique;
 +</file>
 +
 +**/etc/racoon/racoon.conf**
 +
 +<file>
 +include "/etc/racoon/static-psk-test.conf";
 +</file>
 +
 +**/etc/racoon/static-psk-test.conf**
 +
 +<file>
 +remote 5.20.195.220 {
 +    exchange_mode main;
 +    proposal {
 +        encryption_algorithm 3des;
 +        hash_algorithm md5;
 +        authentication_method pre_shared_key;
 +        dh_group modp768;
 +    }
 +    # Verifica l'identita' del peer su psk.txt con l'indirizzo IP.
 +    peers_identifier address "5.20.195.220";
 +    verify_identifier on;
 +    initial_contact on;
 +}
 +
 +sainfo address 192.168.10.0/24 any address 192.168.20.0/24 any {
 +    encryption_algorithm 3des;
 +    authentication_algorithm hmac_md5,hmac_sha1;
 +    compression_algorithm deflate;
 +}
 +</file>
 +
 +
 +**/etc/racoon/psk.txt**
 +
 +<file>
 +5.20.195.220    nai5Ohmo
 +</file>
 +
 +Per fermare e riavviare il servizio:
 +
 +<code>
 +systemctl stop racoon
 +systemctl stop setkey
 +
 +systemctl start setkey
 +systemctl start racoon
 +</code>
 +
 +Il traffico IPSEC va ovviamente gestito in maniera opportuna poiché non corrisponde al criterio standard MASQUERADE di iptables. Ad esempio [[#configurazione_firewall_shorewall|Shorewall]] ha delle direttive apposite per gestire IPSEC.
 +
 +In generale si potrà testare la VPN con un ping, a patto di usare gli indirizzi IP sul lato LAN:
 +
 +<code>
 +ping -I 192.168.10.254 192.168.20.1
 +</code>
 ===== Pezzi di IPSEC per Linux ===== ===== Pezzi di IPSEC per Linux =====
  
Line 289: Line 360:
 viene ripetuta finché il remoto non si accorge. viene ripetuta finché il remoto non si accorge.
  
-==== Client con IP dinamico, network remota, PSK ====+==== Client con IP dinamico e LAN associata, PSK ====
  
 Usando un IP dinamico e la PSK è obbligatorio usare l'aggressive mode. Nel file **''/etc/racoon/psk.txt''** il client con IP dinamico viene identificato con un nome FQDN. Usando un IP dinamico e la PSK è obbligatorio usare l'aggressive mode. Nel file **''/etc/racoon/psk.txt''** il client con IP dinamico viene identificato con un nome FQDN.
Line 350: Line 421:
  
  
-==== Client Router DrayTek Vigor 2500/2600 ====+==== Client con IP statico e LAN associata, PSK (es. router DrayTek Vigor 2500/2600====
  
 :!: **ATTENZIONE**: Si è riscontrato un **[[ipsec_draytek|problema con i router DrayTek]]**. :!: **ATTENZIONE**: Si è riscontrato un **[[ipsec_draytek|problema con i router DrayTek]]**.
Line 368: Line 439:
 } }
  
-# 
-# Connection mariabarbara 
-# 
 remote 217.19.150.165 { remote 217.19.150.165 {
         proposal {         proposal {
Line 445: Line 513:
 </file> </file>
  
 +==== Initiator dietro NAT verso server passivo ====
 +
 +Se il cliente/initiator non ha un IP pubblico, ma sta dietro il NAT di un router, occorrono alcuni aggiustamenti alla configurazione.
 +
 +L'indirizzo del client è **10.0.1.2** (IP privato, dietro NAT), il server ha indirizzo **82.63.172.2**, la PSK è associata a tale IP in **''/etc/racoon/psk.txt''**, la rete privata da raggiungere presso il server è **192.168.100.0/24**.
 +
 +<file>
 +listen {
 +        isakmp 10.0.1.2;
 +        isakmp_natt 10.0.1.2 [4500];
 +        strict_address;
 +}
 +
 +remote 82.63.172.2 {
 +        nat_traversal on;
 +        exchange_mode aggressive;
 +        my_identifier fqdn "vpn.nat-client.net";
 +        # Verifica l'identita' del peer su /etc/racoon/psk.txt con l'indirizzo IP.
 +        peers_identifier address "82.63.172.2";
 +        lifetime time 21600 sec;
 +        proposal_check strict;
 +        proposal {
 +                encryption_algorithm 3des;
 +                hash_algorithm md5;
 +                authentication_method pre_shared_key;
 +                # For aggressive mode, it must be the same on both ends.
 +                dh_group modp1024;
 +        }
 +}
 +
 +sainfo address 10.0.1.0/24 any address 192.168.100.0/24 any {
 +        pfs_group modp1024;
 +        lifetime time 12 hour;
 +        encryption_algorithm 3des, blowfish, des, rijndael;
 +        authentication_algorithm hmac_sha1, hmac_md5;
 +        compression_algorithm deflate;
 +}
 +</file>
 +
 +Nel file **''/etc/ipsec-tools.d/82.63.172.2.conf''** si mette:
 +
 +<file>
 +spdadd 10.0.1.0/24       192.168.100.0/24  any -P out ipsec esp/tunnel/10.0.1.2-82.63.172.2/unique;
 +spdadd 192.168.100.0/24  10.0.1.0/24       any -P in  ipsec esp/tunnel/82.63.172.2-10.0.1.2/unique;
 +</file>
 ===== Configurazione firewall Shorewall ===== ===== Configurazione firewall Shorewall =====
  
doc/appunti/linux/sa/ipsec.txt · Last modified: 2018/01/08 12:24 by niccolo