web-dev-qa-db-ja.com

AWS EC2 VPCVPNクライアントを備えたstrongSwanIPsecサーバー

2つのAWSリージョン間にVPNトンネルを作成しようとしています。私がこれを実行しようとしている方法は、1つのリージョンにstrongSwanを使用してLinuxにIPsecサーバーをセットアップし、次に、他のリージョンにVPC VPNをセットアップすることです。
問題は、正しく機能する構成を思い付くことができないことです。

AWSは、IPsecVPNを設定するために次の情報を提供します。

#1: Internet Key Exchange Configuration

Configure the IKE SA as follows
  - Authentication Method    : Pre-Shared Key 
  - Pre-Shared Key           : ***********************
  - Authentication Algorithm : sha1
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 28800 seconds
  - Phase 1 Negotiation Mode : main
  - Perfect Forward Secrecy  : Diffie-Hellman Group 2

#2: IPSec Configuration

Configure the IPSec SA as follows:
  - Protocol                 : esp
  - Authentication Algorithm : hmac-sha1-96
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 3600 seconds
  - Mode                     : tunnel
  - Perfect Forward Secrecy  : Diffie-Hellman Group 2

IPSec Dead Peer Detection (DPD) will be enabled on the AWS Endpoint. We
recommend configuring DPD on your endpoint as follows:
  - DPD Interval             : 10
  - DPD Retries              : 3

IPSec ESP (Encapsulating Security Payload) inserts additional
headers to transmit packets. These headers require additional space, 
which reduces the amount of space available to transmit application data.
To limit the impact of this behavior, we recommend the following 
configuration on your Customer Gateway:
  - TCP MSS Adjustment       : 1387 bytes
  - Clear Don't Fragment Bit : enabled
  - Fragmentation            : Before encryption

#3: Tunnel Interface Configuration

Your Customer Gateway must be configured with a tunnel interface that is
associated with the IPSec tunnel. All traffic transmitted to the tunnel
interface is encrypted and transmitted to the Virtual Private Gateway.



The Customer Gateway and Virtual Private Gateway each have two addresses that relate
to this IPSec tunnel. Each contains an outside address, upon which encrypted
traffic is exchanged. Each also contain an inside address associated with
the tunnel interface.

The Customer Gateway outside IP address was provided when the Customer Gateway
was created. Changing the IP address requires the creation of a new
Customer Gateway.

The Customer Gateway inside IP address should be configured on your tunnel
interface. 

Outside IP Addresses:
  - Customer Gateway                : 54.241.138.199 
  - Virtual Private Gateway         : 87.238.85.44

Inside IP Addresses
  - Customer Gateway                : 169.254.254.6/30
  - Virtual Private Gateway         : 169.254.254.5/30

Configure your tunnel to fragment at the optimal size:
  - Tunnel interface MTU     : 1436 bytes


#4: Static Routing Configuration:

To route traffic between your internal network and your VPC, 
you will need a static route added to your router.

Static Route Configuration Options:

  - Next hop       : 169.254.254.5

You should add static routes towards your internal network on the VGW.
The VGW will then send traffic towards your internal network over 
the tunnels.  

ローカルstrongSwan側のプライベートサブネットは10.2.0.0/16
リモートVPN側のプライベートサブネットは10.4.0.0/16

これで、次のような構成を使用してみました。

conn eu-west-1-1
        left=10.2.0.40
        leftsubnet=0.0.0.0/0
        right=87.238.85.40
        rightsubnet=10.4.0.0/16
        auto=add
        type=tunnel
        keyexchange=ikev1
        authby=secret
        ikelifetime=28800s
        keylife=28800s
        ike=aes128
        esp=aes128

ただし、これにより次のエラーが発生します。

pluto[1763]: "eu-west-1-1" #12: cannot respond to IPsec SA request because no connection is known for 0.0.0.0/0===10.2.0.40[10.2.0.40]...87.238.85.40[87.238.85.40]===0.0.0.0/0

StrongSwanメーリングリストで見つけた1つのアイデアに従って、0.0.0.0/0 for leftsubnetおよびrightsubnetの場合、これによりトンネルが起動します(AWS Web GUIによって報告されます)が、サーバーへのすべての接続が失われます(私は推測します)すべてのトラフィックをブラックホール化する0.0.0.0/0へのルートを作成しています)。

これを機能させるために構成を調整する方法について誰かがヒントを提供できますか?

はい、両端で2つのstrongSwan、OpenVPN、またはその他のソフトウェアVPNを使用できることを知っていますが、AWSのVPN機能を使用することで、VPNの両端ではなく片端のみを維持することを心配する必要があります。 ==

6
Patrick

あなたがこれを投稿してからしばらく経っていることは知っていますが、私はあなたが説明したことを実行しました。ここに、値を使用した接続ブロックの例を示します。

conn vpc1
        type=tunnel
        compress=no
        keyexchange=ikev1
        ike=aes128-sha1-modp1024!
        auth=esp
        authby=psk
        left=54.241.138.199 
        leftid=54.241.138.199 
        leftsubnet=169.254.254.6/32,10.2.0.0/16
        rightsubnet=169.254.254.5/32,10.4.0.0/16
        right=87.238.85.44
        rightid=87.238.85.44
        esp=aes128-sha1-modp1024!
        auto=route

その後、ipsec up vpc1 ; ipsec route vpc1を実行できます。

左がローカル側、右がAmazon VPCVPN側です。うまくいけば、私はIPの権利を取得しました。

問題は、ipsecがカーネルに正しいip xfrmポリシーを作成する必要があることです。適切な設定がないと、トンネルの実行方法がわかりません。それと暗号化設定は完璧でなければなりません。

私は多くの試みを行い、最終的にstrongswanの開発者と協力してこれを理解しました。警告:この接続はDPDを適切に実行していないため、ドロップすることがあります。また、service ipsec startが呼び出されても、start + routeは実行されません。

幸運を!

11
Jesse