このチュートリアルでは、Cloudflare WAN(旧 Magic WAN)と Oracle Cloud の Site-to-site VPN の間で IPsec(Internet Protocol Security)を設定する方法を説明します。
IPsec トンネルを確立するには、事前共有鍵が必要です。次のコードでランダムな鍵を作成できます。
const a = new Uint8Array(48);
crypto.getRandomValues(a);
let base64String = btoa(String.fromCharCode.apply(null, a));
base64String = base64String.replace(/\+/g, '')
.replace(/\//g, '')
.replace(/=/g, '');
console.log(base64String.substring(0, 32));このコードは Workers playground ↗ で試せます。
- Networking > Customer connectivity を開き、Customer-premises equipment を選択します。
- Create CPE を選択します。
- 次の設定を選択します(ここに挙げていない設定はデフォルトのままにできます)。
- Name: 名前を入力します。
- IP Address: Cloudflare の anycast IP アドレスを入力します。
- CPE vendor information: Other を選択します。
- Create CPE を選択します。
- Networking > Customer connectivity を開き、Dynamic routing gateways を選択します。
- Create Dynamic routing gateways を選択します。
- 次の設定を選択します(ここに挙げていない設定はデフォルトのままにできます)。
- Name: 名前を入力します。
- Create Dynamic routing gateways を選択します。
- Networking > Customer connectivity を開き、Site-to-Site VPN を選択します。
- Create IPsec connection を選択します。
- 次の設定を選択します(ここに挙げていない設定はデフォルトのままにできます)。
- Name: 名前を入力します。
- Customer-premises equipment (CPE): 手順 1 で作成した CPE を選択します。
- Dynamic routing gateways (DRG): 手順 2 で作成した DRG を選択します。
- Routes to your on-premises network: Cloudflare WAN へルーティングしたい CIDR(Classless Inter-Domain Routing)範囲を入力します。
- Tunnel 1
- Name: 名前を入力します。
- Provide custom shared secret を選択します。
- 前提条件で作成した pre-shared key を入力します。
- IKE (Internet Key Exchange) version: IKEv2
- Routing type: Static routing
- IPv4 inside tunnel interface - CPE: IPsec トンネルの Cloudflare 側の内部トンネル IP を入力します。この例では
10.200.1.0/31です。 - IPv4 inside tunnel interface - Oracle: IPsec トンネルの Oracle 側の内部トンネル IP を入力します。この例では
10.200.1.1/31です。このトンネルの Cloudflare 側と対になります。- Show advanced options を選択します
- Phase one (ISAKMP) configuration を選択します
- Set custom configurations を選択します
- Custom encryption algorithm: AES_256_CBC
- Custom authentication algorithm: SHA2_256
- Custom Diffie-Hellman group: GROUP20
- IKE session key lifetime in seconds: 86400
- Phase two (IPsec) configuration を選択します
- Set custom configurations を選択します
- Custom encryption algorithm: AES_256_CBC
- HMAC (Hash-based Message Authentication Code)_SHA2_256_128: HMAC_SHA2_256_128
- IPsec session key lifetime in seconds: 28800
- Perfect forward secrecy Diffie-Hellman group: GROUP20
- Tunnel 2
- Tunnel 2 でも同じ手順を繰り返します。IPv4 inside tunnel interface - CPE (Customer-Premises Equipment) には
10.200.2.0/31、IPv4 inside tunnel interface - Oracle には10.200.2.1/31を選択します
- Tunnel 2 でも同じ手順を繰り返します。IPv4 inside tunnel interface - CPE (Customer-Premises Equipment) には
- Create IPsec connection を選択します
Oracle の Site-to-site VPN 接続とトンネルを設定したら、Cloudflare ダッシュボードを開き、Cloudflare WAN 側で対応する IPsec トンネルと静的ルートを作成します。
- IPsec トンネルの追加方法は トンネルを追加する を参照してください。IPsec トンネルを作成するときは、次の設定を必ず指定します。
- Tunnel name: 名前を入力します。
- Interface address: IPsec トンネルの Cloudflare 側の内部トンネル IP を入力します。この例では
10.200.1.0/31です。 - Customer endpoint: Oracle VPN の公開 IP アドレスです。
- Cloudflare endpoint: アカウントに割り当てられた Cloudflare の anycast IP アドレスのいずれかを入力します。Leased IPs ↗ で確認できます。
- Health check type: Request
- Health check direction: Unidirectional
- Health check target: Default
- Pre-shared key: Use my own pre-shared key を選び、前提条件で作成した事前共有鍵を入力します。
- Replay protection: Enabled。
- Add tunnels を選択します。
- Tunnel 2 でも同じ手順を繰り返します。同じ Cloudflare anycast IP アドレスを選び、Interface address には
10.200.2.0/31を選択します
Cloudflare WAN の静的ルートは、Oracle Virtual Cloud Network(VCN)内に作成した適切な仮想マシン(VM)サブネットを指す必要があります。たとえば、VM のサブネットが 192.168.192.0/26 なら、それを静的ルートのプレフィックスとして使います。
静的ルートを作成するには、次の手順を行います。
- 作成方法は 静的ルートを作成する を参照してください。
- Prefix に、VM のサブネットを入力します。例:
192.xx.xx.xx/24。 - Tunnel/Next hop には、前の手順で作成した IPsec トンネルを選びます。
- 作成した 2 本目の IPsec トンネルでも同じ手順を繰り返します。