Заметки системного администратора

  1. apt install strongswan
  2. apt install certbot
  3. certbot certonly --standalone -d yourdomain.ru
  4. ln -s /etc/letsencrypt/live/yourdomain.ru/chain.pem /etc/ipsec.d/cacerts/ca.pem
  5. ln -s /etc/letsencrypt/live/yourdomain.ru/cert.pem /etc/ipsec.d/certs/certificate.pem
  6. ln -s /etc/letsencrypt/live/yourdomain.ru/privkey.pem /etc/ipsec.d/private/key.pem
  7. nano /lib/systemd/system/certbot.service
    ExecStart=/usr/bin/certbot renew --deploy-hook "systemctl restart strongswan.service"
  8. systemctl daemon-reload
  9. nano /etc/ipsec.conf
    config setup
      charondebug="ike 1, knl 1, cfg 1"
    conn BASE
      authby=psk
      keyexchange=ikev2
      ike=aes128-sha1-modp1024
      esp=aes128-sha1-modp1024
      pfs=no
      dpdaction=restart
      auto=add

    conn Home
      also=BASE
      left=yourIP
      leftprotoport=47
      right=remoteIP
      rightprotoport=47
      type=transport

    conn ikev2-vpn
      auto=add
      compress=no
      type=tunnel
      keyexchange=ikev2
      fragmentation=yes
      forceencaps=yes
      ike=aes256-sha1-modp1024
      esp=aes256-sha1
      dpdaction=clear
      dpddelay=30s
      rekey=no
      left=%any
      leftid=@yourdomain
      leftcert=certificate.pem
      leftsendcert=always
      leftsubnet=0.0.0.0/0
      right=%any
      rightid=%any
      rightauth=eap-mschapv2
      rightsourceip=10.1.1.0/24
      rightdns=9.9.9.9,149.112.112.112
      rightsendcert=never
      eap_identity=%identity
  10. nano /etc/ipsec.secrets
    yourdomain : RSA key.pem
    yourIP %any : PSK "P@SSW0RD"
    USER %any% : EAP "PASSWORD"
  11. ipsec rereadsecrets
  12. apparmor_status
    if you see /usr/lib/ipsec/charon /usr/lib/ipsec/stroke
    ln -s /etc/apparmor.d/usr.lib.ipsec.charon /etc/apparmor.d/disable/
    ln -s /etc/apparmor.d/usr.lib.ipsec.stroke /etc/apparmor.d/disable/
    apparmor_parser -R /etc/apparmor.d/usr.lib.ipsec.charon
    apparmor_parser -R /etc/apparmor.d/usr.lib.ipsec.stroke
  13. ipsec start
  14. ipsec listcerts
  15. ipsec statusall