0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OCI サイト間VPNをパラメータファイルを使って作成

Last updated at Posted at 2024-10-09

概要

Oracle Cloud Infrastructure(OCI)のサイト間VPNをパラメータファイルを使って作成します

何がいいの?

サイト間VPN作成のために多くのパラメータをOCIコンソールで設定する必要があります。少数であればOCIコンソールで問題ありませんが、多くのVPNを作成する場合はパラメータファイルを利用することによって、設定ミスを防いで効率的にVPNを作成可能です。

構成

以下のようなVPNを作成します。

準備

パラメータサンプル取得

パラメータサンプルをOCI CLIを使ってダウンロードします

  • CPEパラメータ
[user@linux]$ oci network cpe create --generate-full-command-json-input
  • VPNパラメータ
[user@linux]$ oci network ip-sec-connection create --generate-full-command-json-input
  • CPE Device info
    CPE機種のIDリスト
    以下はFortigateを抜き出しています
[user@linux]$ oci network cpe-device-shape list
{
  "data": [
    :
    {
      "cpe-device-info": {
        "platform-software-version": "FortiGate 6.0.4 or later",
        "vendor": "Fortinet"
      },
      "id": "c4906b47-9d9a-4d9f-8f77-78879b789d1d"
    },
    :
  ]
}

CPEパラメータファイル作成

【】部分は個別に設定します

cpe001.json
{
  "compartmentId": "【コンパートメントOCID】",
  "cpeDeviceShapeId": "c4906b47-9d9a-4d9f-8f77-78879b789d1d",
  "definedTags": {},
  "displayName": "【CPE名】",
  "freeformTags": {},
  "ipAddress": "【CPE_Global_IP】",
  "isPrivate": false
}

VPNパラメータファイル作成

【】部分は個別に設定します

vpn001.json
{
  "compartmentId": "【コンパートメントOCID】",
  "cpeLocalIdentifier": "【CPE IKE識別子】",
  "cpeLocalIdentifierType": "IP_ADDRESS",
  "definedTags": {},
  "displayName": "【VPN名】",
  "drgId": "【DRG OCID】",
  "freeformTags": {},
  "maxWaitSeconds": 0,
  "staticRoutes": [],
  "tunnelConfiguration": [
    {
      "associatedVirtualCircuits": [],
      "bgpSessionConfig": {
        "customerBgpAsn": "64512",
        "customerInterfaceIp": "192.168.0.9/30",
        "customerInterfaceIpv6": null,
        "oracleInterfaceIp": "192.168.0.10/30",
        "oracleInterfaceIpv6": null
      },
      "displayName": "【トンネル1名】",
      "dpdConfig": {
        "dpdMode": "INITIATE_AND_RESPOND",
        "dpdTimeoutInSec": 20
      },
      "drgRouteTableId": null,
      "encryptionDomainConfig": {},
      "ikeVersion": "V2",
      "natTranslationEnabled": "AUTO",
      "oracleInitiation": "RESPONDER_ONLY",
      "oracleTunnelIp": null,
      "phaseOneConfig": {
        "authenticationAlgorithm": "SHA2_384",
        "diffieHelmanGroup": "GROUP20",
        "encryptionAlgorithm": "AES_256_CBC",
        "isCustomPhaseOneConfig": true,
        "lifetimeInSeconds": 28800
      },
      "phaseTwoConfig": {
        "authenticationAlgorithm": null,
        "encryptionAlgorithm": "AES_256_GCM",
        "isCustomPhaseTwoConfig": true,
        "isPfsEnabled": true,
        "lifetimeInSeconds": 3600,
        "pfsDhGroup": "GROUP5"
      },
      "routing": "BGP",
      "sharedSecret": "【PreSharedKey】"
    },
    {
      "associatedVirtualCircuits": [],
      "bgpSessionConfig": {
        "customerBgpAsn": "64512",
        "customerInterfaceIp": "192.168.0.13/30",
        "customerInterfaceIpv6": null,
        "oracleInterfaceIp": "192.168.0.14/30",
        "oracleInterfaceIpv6": null
      },
      "displayName": "【トンネル2名】",
      "dpdConfig": {
        "dpdMode": "INITIATE_AND_RESPOND",
        "dpdTimeoutInSec": 20
      },
      "drgRouteTableId": null,
      "encryptionDomainConfig": {},
      "ikeVersion": "V2",
      "natTranslationEnabled": "AUTO",
      "oracleInitiation": "RESPONDER_ONLY",
      "oracleTunnelIp": null,
      "phaseOneConfig": {
        "authenticationAlgorithm": "SHA2_384",
        "diffieHelmanGroup": "GROUP20",
        "encryptionAlgorithm": "AES_256_CBC",
        "isCustomPhaseOneConfig": true,
        "lifetimeInSeconds": 28800
      },
      "phaseTwoConfig": {
        "authenticationAlgorithm": null,
        "encryptionAlgorithm": "AES_256_GCM",
        "isCustomPhaseTwoConfig": true,
        "isPfsEnabled": true,
        "lifetimeInSeconds": 3600,
        "pfsDhGroup": "GROUP5"
      },
      "routing": "BGP",
      "sharedSecret": "【PreSharedKey】"
    }
  ],
  "waitForState": [],
  "waitIntervalSeconds": 0
}

Shell作成

OCI CLIコマンドを使用してCPE作成、VPN作成を行います

S2svpnCreate.sh
oci network cpe create --from-json file://cpe001.json > cpecreateout.json
CPEID=`cat cpecreateout.json | jq -r '.data.id'`
if [ -z "$CPEID" ]; then
  echo "No CPE created"
  exit 0
fi
echo CPE OCID = $CPEID

sleep 5s

oci network ip-sec-connection create --cpe-id $CPEID --from-json file://vpn001.json > vpncreateout.json
VPNID=`cat vpncreateout.json | jq -r '.data.id'`
echo VPN OCID = $VPNID

VPN作成

Shell実行

作成したShellを実行します
成功するとCPE OCIDとVPN OCIDを表示します

[user@linux]$ /bin/bash S2svpnCreate.sh
CPE OCID = 【CPE OCID】
VPN OCID = 【VPN OCID】

作成確認

作成完了まで1~2分程度かかるためステータスがAVAILABLEになるまで確認コマンドを実行します

[user@linux]$ oci network ip-sec-tunnel list --ipsc-id 【VPN OCID】 --all | jq '.data[] | [."display-name",."lifecycle-state",."vpn-ip"]' | jq -c
["Home-Rtr-VPN-tun2","PROVISIONING","【OCI_Global_IP2】"]
["Home-Rtr-VPN-tun1","PROVISIONING","【OCI_Global_IP1】"]
[user@linux]$

[user@linux]$ oci network ip-sec-tunnel list --ipsc-id 【VPN OCID】 --all | jq '.data[] | [."display-name",."lifecycle-state",."vpn-ip"]' | jq -c
["Home-Rtr-VPN-tun2","AVAILABLE","【OCI_Global_IP2】"]
["Home-Rtr-VPN-tun1","AVAILABLE","【OCI_Global_IP1】"]
[user@linux]$

VPNステータス確認

Fortigate側も設定して接続確立することを確認します

  • OCI側
    IP Secステータスが稼働中となっています
  • Fortigate側
    StatusがUpしています
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?