Azure - AWS間で S2S VPNを張ってみた。

とある案件でS2Svpnの技術検証をすることになったので
やってみた。

参考にさせて頂きました。ありがとうございます。
dev.classmethod.jp
dev.classmethod.jp

Azure VPN Gateway構築

仮想ネットワーク、サブネット作成

仮想ネットワークのアドレス範囲を 10.5.0.0/16、 サブネットのアドレス範囲を 10.5.0.0/24
f:id:onrenkai:20200820103623p:plain

ゲートウェイサブネット作成

ゲートウェイ用のサブネットを作成します
f:id:onrenkai:20200820112914p:plain

ゲートウェイサブネットのアドレス範囲は 10.5.254.0/24
f:id:onrenkai:20200820113557p:plain

仮想ネットワークゲートウェイ作成

仮想ネットワークゲートウェイが Azure側のVPNルータに当たります

f:id:onrenkai:20200820114032p:plain
f:id:onrenkai:20200820132237p:plain


ここでパブリックIPアドレスをメモしておく。

AWS VPN Gateway構築

VPC、サブネット作成

VPC: 10.10.0.0/16
subnet: 10.10.11.0/24

カスタマーゲートウェイ作成

静的を選択
Azureの仮想ネットワークゲートウェイ作成時に生成したパブリックIPアドレスを記載する
f:id:onrenkai:20200820132725p:plain


仮想プライベートゲートウェイ作成

AWS側のVPNルータを作成し、該当するVPCをアタッチします。

f:id:onrenkai:20200820135006p:plain



サブネットのルーティング設定を下記のように変更

f:id:onrenkai:20200820140008p:plain

VPN接続設定

AWS側作業:VPN接続設定

サイト間のVPN接続からVPN接続の作成を選択

f:id:onrenkai:20200820140639p:plain
f:id:onrenkai:20200820141345p:plain

AWSのサイト間 VPN接続はデフォルトで冗長化されており、 2つのトンネル (2つのVPNルータ) が作成されます。

それぞれの VPNルータの設定を取得し、後述のAzure側作業で使用します。 設定のダウンロード から適当なConfigファイルをダウンロードします。

f:id:onrenkai:20200820141214p:plain



ダウンロードしたファイルの中身はこんな感じです。

Amazon Web Services
Virtual Private Cloud

VPN Connection Configuration
================================================================================
AWS utilizes unique identifiers to manipulate the configuration of 
a VPN Connection. Each VPN Connection is assigned a VPN Connection Identifier 
and is associated with two other identifiers, namely the 
Customer Gateway Identifier and the Virtual Private Gateway Identifier.

Your VPN Connection ID		         : vpn-xxxxxxxxxxxxxxxxxxxxx
Your Virtual Private Gateway ID          : vgw-xxxxxxxxxxxxxxxxxxxxx
Your Customer Gateway ID    		 : cgw-xxxxxxxxxxxxxxxxxxxxx
		
A VPN Connection consists of a pair of IPSec tunnel security associations (SAs). 
It is important that both tunnel security associations be configured. 

				
IPSec Tunnel #1
================================================================================
#1: Internet Key Exchange Configuration
		
Configure the IKE SA as follows:
Please note, these sample configurations are for the minimum requirement of AES128, SHA1, and DH Group 2.
Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
You will need to modify these sample configuration files to take advantage of AES256, SHA256, or other DH groups like 2, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
The address of the external interface for your customer gateway must be a static address.
Your customer gateway may reside behind a device performing network address translation (NAT).
To ensure that NAT traversal (NAT-T) can function, you must adjust your firewall !rules to unblock UDP port 4500. If not behind NAT, we recommend disabling NAT-T.
  - IKE version              : IKEv1 
  - Authentication Method    : Pre-Shared Key 
  - Pre-Shared Key           : xxxxxxxxxxxxxxxxxxxxx
  - Authentication Algorithm : sha1
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 28800 seconds
  - Phase 1 Negotiation Mode : main
  - Diffie-Hellman           : Group 2

#2: IPSec Configuration

Configure the IPSec SA as follows:
Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
Please note, you may use these additionally supported IPSec parameters for encryption like AES256 and other DH groups like 2, 5, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
  - 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       : 1379 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 		        : xxx.xxx.xxx.xxx
  - Virtual Private Gateway	        : xxx.xxx.xxx.xxx
		
Inside IP Addresses
  - Customer Gateway         		: xxx.xxx.xxx.xxx/xx
  - Virtual Private Gateway             : xxx.xxx.xxx.xxx/xx

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       : xxx.xxx.xxx.xxx
  
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.  
  
		
				
IPSec Tunnel #2
================================================================================
#1: Internet Key Exchange Configuration
		
Configure the IKE SA as follows:
Please note, these sample configurations are for the minimum requirement of AES128, SHA1, and DH Group 2.
Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
You will need to modify these sample configuration files to take advantage of AES256, SHA256, or other DH groups like 2, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
The address of the external interface for your customer gateway must be a static address.
Your customer gateway may reside behind a device performing network address translation (NAT).
To ensure that NAT traversal (NAT-T) can function, you must adjust your firewall !rules to unblock UDP port 4500. If not behind NAT, we recommend disabling NAT-T.
  - IKE version              : IKEv1 
  - Authentication Method    : Pre-Shared Key 
  - Pre-Shared Key           : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  - Authentication Algorithm : sha1
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 28800 seconds
  - Phase 1 Negotiation Mode : main
  - Diffie-Hellman           : Group 2

#2: IPSec Configuration

Configure the IPSec SA as follows:
Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
Please note, you may use these additionally supported IPSec parameters for encryption like AES256 and other DH groups like 2, 5, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
  - 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       : 1379 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 		        : xxx.xxx.xxx.xxx 
  - Virtual Private Gateway	        : xxx.xxx.xxx.xxx
		
Inside IP Addresses
  - Customer Gateway         		: xxx.xxx.xxx.xxx/xx
  - Virtual Private Gateway             : xxx.xxx.xxx.xxx/xx

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       : xxx.xxx.xxx.xxx
  
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.  
  
		 
 

Additional Notes and Questions
================================================================================

  - Amazon Virtual Private Cloud Getting Started Guide: 
      http://docs.amazonwebservices.com/AmazonVPC/latest/GettingStartedGuide
  - Amazon Virtual Private Cloud Network Administrator Guide: 
      http://docs.amazonwebservices.com/AmazonVPC/latest/NetworkAdminGuide
  - XSL Version: 2009-07-15-1119716


Configファイルの下記項目をメモしておきます。

IPsec Tunnel #1 のPreShared Key
IPsec Tunnel #1 のAWSグローバルIP
IPsec Tunnel #2 のPreShared Key
IPsec Tunnel #2 のAWSグローバルIP



Azure側作業:VPN接続設定

まず AWS側で作成した IPsec Tunnel #1 の接続を確立させるための設定をしてきます。

  • アドレス範囲: 対向 (AWS)側ローカル (10.10.11.0/24) を記入

f:id:onrenkai:20200820142415p:plain



次に 手順1で作成した仮想ネットワークゲートウェイから 接続 、+追加 を選択

  • 接続の種類: サイト対サイト (IPsec) を選択
  • 共有キー(PSK): IPsec Tunnel #1 のPreShared Key を記入

f:id:onrenkai:20200820142900p:plain

f:id:onrenkai:20200820142704p:plain


以上で IPsec Tunnel#1 の設定は完了です。

同じ手順で IPsec Tunnel#2 版 ローカルネットワークゲートウェイ・接続も作成します。


確認

接続済みとなっていればOKです。
f:id:onrenkai:20200820143245p:plain

AWS側のサイト間のVPN接続のトンネル詳細を見てみます。
ステータスが アップ となっていれば OKです。
f:id:onrenkai:20200820144638p:plain



AWS内のEC2WindowsServer2019 にRDPして
対向のAzureに対してPingを打ってみます。

通りました!!!
f:id:onrenkai:20200820145019p:plain


反対にAzure内のWindowsServer2019にRDPして
対向のAWSのEC2に対してRDPで繋いでみます。
f:id:onrenkai:20200820145742p:plain


繋がりました!!!

おしまい。