Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
|
strongswan [2025/05/09 00:25] |
strongswan [2025/07/03 14:25] (aktuell) |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | Kostenloses selbst gehostetes Site to Site [[VPN]]. Siehe auch [[Libreswan]] | ||
| + | < | ||
| + | sudo apt update | ||
| + | sudo apt install strongswan | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | ipsec status | ||
| + | ipsec restart | ||
| + | |||
| + | ip xfrm policy | ||
| + | ip xfrm state | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | diagnose debug enable | ||
| + | diagnose debug console timestamp enable | ||
| + | diagnose debug application ike -1 | ||
| + | diagnose debug disable | ||
| + | </ | ||
| + | |||
| + | =====Beispiel===== | ||
| + | |||
| + | [[IPSec]] Site-to-site VPN | ||
| + | |||
| + | ^Standort^IP-Adresse^LAN^ | ||
| + | |A (left)|1.1.1.1|192.168.1.0/ | ||
| + | |B (right)|2.2.2.2|192.168.2.0/ | ||
| + | |||
| + | Standort A | ||
| + | |||
| + | < | ||
| + | # / | ||
| + | |||
| + | config setup | ||
| + | charondebug=" | ||
| + | |||
| + | conn site-to-site | ||
| + | auto=start | ||
| + | keyexchange=ikev2 | ||
| + | authby=secret | ||
| + | left=1.1.1.1 | ||
| + | leftsubnet=192.168.1.0/ | ||
| + | right=2.2.2.2 | ||
| + | rightsubnet=192.168.2.0/ | ||
| + | ike=aes256-sha256-modp1024! | ||
| + | esp=aes256-sha256! | ||
| + | dpdaction=restart | ||
| + | dpddelay=30s | ||
| + | dpdtimeout=120s | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # / | ||
| + | # < | ||
| + | 1.1.1.1 2.2.2.2 : PSK " | ||
| + | </ | ||
| + | |||
| + | Standort B | ||
| + | |||
| + | < | ||
| + | # / | ||
| + | |||
| + | config setup | ||
| + | charondebug=" | ||
| + | |||
| + | conn site-to-site | ||
| + | auto=start | ||
| + | keyexchange=ikev2 | ||
| + | authby=secret | ||
| + | left=2.2.2.2 | ||
| + | leftsubnet=192.168.2.0/ | ||
| + | right=1.1.1.1 | ||
| + | rightsubnet=192.168.1.0/ | ||
| + | ike=aes256-sha256-modp1024! | ||
| + | esp=aes256-sha256! | ||
| + | dpdaction=restart | ||
| + | dpddelay=30s | ||
| + | dpdtimeout=120s | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # / | ||
| + | # < | ||
| + | 2.2.2.2 1.1.1.1 : PSK " | ||
| + | </ | ||
| + | |||
| + | Auf beiden Standorten | ||
| + | |||
| + | < | ||
| + | echo ' | ||
| + | sudo sysctl -p | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # Firewall erlauben | ||
| + | sudo ufw allow 500, | ||
| + | |||
| + | # Leite Traffic für 192.168.1.0/ | ||
| + | iptables -t nat -A POSTROUTING -s 192.168.1.0/ | ||
| + | |||
| + | # Leite Traffic für 192.168.2.0/ | ||
| + | iptables -t nat -A POSTROUTING -s 192.168.2.0/ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | sudo systemctl restart strongswan #Nope | ||
| + | sudo systemctl restart strongswan-starter | ||
| + | sudo ipsec statusall | ||
| + | ip route | ||
| + | ip xfrm policy | ||
| + | </ | ||
| + | |||
| + | =====Mitschnitt===== | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | The authenticity of host ' | ||
| + | ED25519 key fingerprint is SHA256: | ||
| + | This key is not known by any other names. | ||
| + | Are you sure you want to continue connecting (yes/ | ||
| + | Warning: Permanently added ' | ||
| + | Enter passphrase for key ' | ||
| + | Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-139-generic x86_64) | ||
| + | |||
| + | * Documentation: | ||
| + | * Management: | ||
| + | * Support: | ||
| + | |||
| + | | ||
| + | |||
| + | System load: 0.92 Processes: | ||
| + | Usage of /: 9.0% of 24.05GB | ||
| + | Memory usage: 9% IPv4 address for eth0: 176.103.220.16 | ||
| + | Swap usage: | ||
| + | |||
| + | |||
| + | Expanded Security Maintenance for Applications is not enabled. | ||
| + | |||
| + | 0 updates can be applied immediately. | ||
| + | |||
| + | Enable ESM Apps to receive additional future security updates. | ||
| + | See https:// | ||
| + | |||
| + | |||
| + | |||
| + | The programs included with the Ubuntu system are free software; | ||
| + | the exact distribution terms for each program are described in the | ||
| + | individual files in / | ||
| + | |||
| + | Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by | ||
| + | applicable law. | ||
| + | |||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | Hit:1 http:// | ||
| + | Hit:2 http:// | ||
| + | Hit:3 http:// | ||
| + | Hit:4 http:// | ||
| + | Reading package lists... Done | ||
| + | Building dependency tree... Done | ||
| + | Reading state information... Done | ||
| + | All packages are up to date. | ||
| + | root@vm-fjqfnd2u: | ||
| + | Reading package lists... Done | ||
| + | Building dependency tree... Done | ||
| + | Reading state information... Done | ||
| + | The following additional packages will be installed: | ||
| + | libcharon-extauth-plugins libstrongswan libstrongswan-standard-plugins strongswan-charon strongswan-libcharon | ||
| + | strongswan-starter | ||
| + | Suggested packages: | ||
| + | libstrongswan-extra-plugins libcharon-extra-plugins | ||
| + | The following NEW packages will be installed: | ||
| + | libcharon-extauth-plugins libstrongswan libstrongswan-standard-plugins strongswan strongswan-charon | ||
| + | strongswan-libcharon strongswan-starter | ||
| + | 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. | ||
| + | Need to get 959 kB of archives. | ||
| + | After this operation, 4,243 kB of additional disk space will be used. | ||
| + | Do you want to continue? [Y/n] y | ||
| + | Get:1 http:// | ||
| + | Get:2 http:// | ||
| + | Get:3 http:// | ||
| + | Get:4 http:// | ||
| + | Get:5 http:// | ||
| + | Get:6 http:// | ||
| + | Get:7 http:// | ||
| + | Fetched 959 kB in 1s (1,206 kB/s) | ||
| + | Preconfiguring packages ... | ||
| + | Selecting previously unselected package libstrongswan. | ||
| + | (Reading database ... 93565 files and directories currently installed.) | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking libstrongswan (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package strongswan-libcharon. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking strongswan-libcharon (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package strongswan-charon. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking strongswan-charon (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package strongswan-starter. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking strongswan-starter (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package libcharon-extauth-plugins. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking libcharon-extauth-plugins (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package libstrongswan-standard-plugins. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking libstrongswan-standard-plugins (5.9.5-2ubuntu2.3) ... | ||
| + | Selecting previously unselected package strongswan. | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking strongswan (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up libstrongswan (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up strongswan-libcharon (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up libcharon-extauth-plugins (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up strongswan-charon (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up libstrongswan-standard-plugins (5.9.5-2ubuntu2.3) ... | ||
| + | Setting up strongswan-starter (5.9.5-2ubuntu2.3) ... | ||
| + | Created symlink / | ||
| + | Setting up strongswan (5.9.5-2ubuntu2.3) ... | ||
| + | Processing triggers for man-db (2.10.2-1) ... | ||
| + | Scanning processes... | ||
| + | Scanning linux images... | ||
| + | |||
| + | Running kernel seems to be up-to-date. | ||
| + | |||
| + | No services need to be restarted. | ||
| + | |||
| + | No containers need to be restarted. | ||
| + | |||
| + | No user sessions are running outdated binaries. | ||
| + | |||
| + | No VM guests are running outdated hypervisor (qemu) binaries on this host. | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | Failed to restart strongswan.service: | ||
| + | root@vm-fjqfnd2u: | ||
| + | Failed to restart strongswan.service: | ||
| + | root@vm-fjqfnd2u: | ||
| + | Failed to start strongswan.service: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | Status of IKE charon daemon (strongSwan 5.9.5, Linux 5.15.0-139-generic, | ||
| + | uptime: 10 seconds, since May 09 13:52:17 2025 | ||
| + | malloc: sbrk 2105344, mmap 0, used 1226144, free 879200 | ||
| + | worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 3 | ||
| + | loaded plugins: charon aesni aes rc2 sha2 sha1 md5 mgf1 random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey pem openssl fips-prf gmp agent xcbc hmac gcm drbg attr kernel-netlink resolve socket-default connmark stroke updown eap-mschapv2 xauth-generic counters | ||
| + | Listening IP addresses: | ||
| + | 176.103.220.16 | ||
| + | 2a10: | ||
| + | Connections: | ||
| + | site-to-site: | ||
| + | site-to-site: | ||
| + | site-to-site: | ||
| + | site-to-site: | ||
| + | Security Associations (1 up, 0 connecting): | ||
| + | site-to-site[1]: | ||
| + | site-to-site[1]: | ||
| + | site-to-site[1]: | ||
| + | root@vm-fjqfnd2u: | ||
| + | default via 176.103.220.1 dev eth0 proto static | ||
| + | 176.103.220.0/ | ||
| + | root@vm-fjqfnd2u: | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | src 192.168.150.0/ | ||
| + | dir out priority 375423 | ||
| + | tmpl src 176.103.220.16 dst 213.33.126.194 | ||
| + | proto esp spi 0x86d8f2b3 reqid 1 mode tunnel | ||
| + | src 192.168.160.0/ | ||
| + | dir fwd priority 375423 | ||
| + | tmpl src 213.33.126.194 dst 176.103.220.16 | ||
| + | proto esp reqid 1 mode tunnel | ||
| + | src 192.168.160.0/ | ||
| + | dir in priority 375423 | ||
| + | tmpl src 213.33.126.194 dst 176.103.220.16 | ||
| + | proto esp reqid 1 mode tunnel | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | root@vm-fjqfnd2u: | ||
| + | src 192.168.150.0/ | ||
| + | dir out priority 375423 | ||
| + | tmpl src 176.103.220.16 dst 213.33.126.194 | ||
| + | proto esp spi 0x86d8f2b3 reqid 1 mode tunnel | ||
| + | src 192.168.160.0/ | ||
| + | dir fwd priority 375423 | ||
| + | tmpl src 213.33.126.194 dst 176.103.220.16 | ||
| + | proto esp reqid 1 mode tunnel | ||
| + | src 192.168.160.0/ | ||
| + | dir in priority 375423 | ||
| + | tmpl src 213.33.126.194 dst 176.103.220.16 | ||
| + | proto esp reqid 1 mode tunnel | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket in priority 0 | ||
| + | src 0.0.0.0/0 dst 0.0.0.0/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket in priority 0 | ||
| + | src ::/0 dst ::/0 | ||
| + | socket out priority 0 | ||
| + | root@vm-fjqfnd2u: | ||
| + | </ | ||
| + | |||
| + | =====Links===== | ||
| + | |||
| + | * [[https:// | ||