LoginSignup
5
3

Power Systems Virtual ServerにVPNaaSで接続する

Last updated at Posted at 2021-11-19

2023/8/16追記

PowerVSに対するIPsec接続は、VPN for VPCも利用可能になっていますので、併せてご検討ください。
https://qiita.com/y_tama/items/59a5b9d4848ad8315701

はじめに

Power Systems Virtual Server(Power VS)でVPNaaSが利用可能になりました。
Site-to-Site型のIPSec VPNとなります。
これで、オンプレミスからインターネットVPN接続がしやすくなります。(これまではVRA経由でNATやGREを使うなど、ネットワーク的にひと工夫、必要でした。ちなみに、その方法はこちらに書いてあります。)

VPNaaSのDocsとしては、下記に情報があります。
https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-VPN-connections

2021年11月時点ではCLIのみに対応していますので、IBM Cloud Shell環境で設定を進めます。
Cloud Shellは、管理ポータル右上から開始できるブラウザ内のCLI環境です。

image.png

前提確認

下記を確認します。

##PowerVS用プラグインのバージョン確認
Cloud Shell環境であれば問題ないはずですが、VPN関連のコマンドが入っているのは最近のバージョンのプラグインなので、ローカルのCLI環境をお使いになる場合はバージョンをご確認ください。0.3.10以降ならOKです。

TMGW@cloudshell:~$ ibmcloud plugin list|grep power
power-iaas                                   0.3.10                       false   
TMGW@cloudshell:~$ 

Power VSのサービスインスタンス一覧を確認

TMGW@cloudshell:~$ ibmcloud pi sl
crn:v1:bluemix:public:power-iaas:osa21:a/039dbe6794084c7cb514a276dd2345da:40135547-2d73-48a5-971c-1f45cd6f3dc7::      Power Systems Virtual Server-OSA21-tmgw01   
TMGW@cloudshell:~$

操作対象のインスタンスを指定

TMGW@cloudshell:~$ ibmcloud pi st crn:v1:bluemix:public:power-iaas:osa21:a/039dbe6794084c7cb514a276dd2345da:40135547-2d73-48a5-971c-1f45cd6f3dc7::
Targeting service crn:v1:bluemix:public:power-iaas:osa21:a/039dbe6794084c7cb514a276dd2345da:40135547-2d73-48a5-971c-1f45cd6f3dc7::...
TMGW@cloudshell:~$ 

インスタンス内のサブネット確認

TMGW@cloudshell:~$ ibmcloud pi networks
Listing networks under account IBM as user xxxxx@xxxx.com...
ID                                     Name                                 Address   
75cbb717-70b1-4042-b54f-141014af3655   public-192_168_166_40-29-VLAN_2001   /pcloud/v1/cloud-instances/0cc4b2e7849c42c3b6a8fe8983664d72/networks/75cbb717-70b1-4042-b54f-141014af3655   
795889b4-69fd-45f5-8e4b-6f4802d63e5f   subnet01                             /pcloud/v1/cloud-instances/0cc4b2e7849c42c3b6a8fe8983664d72/networks/795889b4-69fd-45f5-8e4b-6f4802d63e5f   
9917fb9d-b3d7-4c42-baf2-3008587b3911   subnet02                             /pcloud/v1/cloud-instances/0cc4b2e7849c42c3b6a8fe8983664d72/networks/9917fb9d-b3d7-4c42-baf2-3008587b3911   
TMGW@cloudshell:~$ 

2つあるサブネットのうち、subnet01をIPSec用に使います。subnet01の情報を確認します。

TMGW@cloudshell:~$ ibmcloud pi network 795889b4-69fd-45f5-8e4b-6f4802d63e5f
Getting Network 795889b4-69fd-45f5-8e4b-6f4802d63e5f under account IBM as user xxxxx@xxxx.com...
                
ID           795889b4-69fd-45f5-8e4b-6f4802d63e5f   
Name         subnet01   
Type         vlan   
VLAN         223   
CIDR Block   192.168.160.0/24   
IP Range     [192.168.160.2  192.168.160.254]   
Gateway      192.168.160.1   
DNS          127.0.0.1   
TMGW@cloudshell:~$ 

VPNaaS設定

確認は以上で、ここから、実際の設定に入っていきます。
構成イメージは下記です。

image.png

IKEポリシー作成

preshared-keyは伏せ字にしています。適宜設定してください。
また、各パラメータは、要件に合わせ、適宜設定してください。
CLIリファレンス

TMGW@cloudshell:~$ ibmcloud pi vpn-ike-policy-add vpn01-ike --version 1 --authentication sha-256 --encryption aes-256-cbc --dh-group 2 --preshared-key XXXXXXXXX --key-lifetime 28800
Adding a new VPN IKE policy vpn01-ike under account IBM as user xxxxx@xxxx.com...
                    
ID               cd929593f6dd4a70b92f31cd99fa7ec5   
Name             vpn01-ike   
Version          1   
Authentication   sha-256   
Encryption       aes-256-cbc   
Dh Group         2   
Key Lifetime     28800   
TMGW@cloudshell:~$ 

IPSecポリシー作成

各パラメータは、要件に合わせ、適宜設定してください。
CLIリファレンス

TMGW@cloudshell:~$ ibmcloud pi vpn-ipsec-policy-add vpn01-ipsec --authentication hmac-sha-256-128 --encryption aes-256-cbc --dh-group 2 --key-lifetime 28800 --pfs
Adding a new VPN IPSec policy vpn01-ipsec under account IBM as user xxxxx@xxxx.com...
                             
ID                        b64a98c8e2aa4f6bab63b85473d96c81   
Name                      vpn01-ipsec   
Authentication            hmac-sha-256-128   
Encryption                aes-256-cbc   
Dh Group                  2   
Perfect Forward Secrecy   true   
Key Lifetime              28800   
TMGW@cloudshell:~$

VPN作成

CLIリファレンス
peer-gateway-addressには対向(オンプレ側)のVPN終端アドレスを指定します。
peer-subnet-cidrsには対向側のCIDRを指定します。
IKEポリシーとIPSecポリシーは、先ほど作成したポリシーのIDを指定します。
network-idsには、このIPSecトンネルに紐づけるPower VSのサブネットを指定します。

TMGW@cloudshell:~$ ibmcloud pi vpn-connection-create vpn01 --mode policy --peer-gateway-address 52.116.xx.xx --peer-subnet-cidrs "192.168.0.0/24" --ike-policy-id  cd929593f6dd4a70b92f31cd99fa7ec5 --ipsec-policy-id b64a98c8e2aa4f6bab63b85473d96c81 --network-ids 795889b4-69fd-45f5-8e4b-6f4802d63e5f
Adding a new VPN Connection vpn01 under account IBM as user xxxxx@xxxx.com...
OK
Job for creating a VPN connection vpn01 was accepted.
                           
ID                      edd71cd6709b4413b9405a8b4c3b77cc   
Name                    vpn01   
Status                  active   
Mode                    policy   
Local Gateway Address   163.68.xx.xx   
Peer Gateway Address    52.116.xx.xx   
VPN Gateway Address     163.68.xx.xx  
IKE Policy              ID: cd929593f6dd4a70b92f31cd99fa7ec5, Name: vpn01-ike   
IPSec Policy            ID: b64a98c8e2aa4f6bab63b85473d96c81, Name: vpn01-ipsec   
Peer Subnets            192.168.0.0/24   
Networks                -   
Dead Peer Detection     Action: restart, Interval: 10, Threshold: 5   
              
Job ID     f2c1c5ad-22b5-4c21-8b54-7341b540b322   
Job Link   pcloud/v1/cloud-instances/0cc4b2e7849c42c3b6a8fe8983664d72/jobs/f2c1c5ad-22b5-4c21-8b54-7341b540b322   
TMGW@cloudshell:~$

この段階では全部の処理は終わっておらず、このVPN定義にPower VSのsubnetをattachするジョブが裏で走っています。上記で出力されたJob IDで、ジョブの状況を確認できます。

TMGW@cloudshell:~$ ibmcloud pi job f2c1c5ad-22b5-4c21-8b54-7341b540b322
Getting job f2c1c5ad-22b5-4c21-8b54-7341b540b322 under account IBM as user xxxxx@xxxx.com...
                      
Job ID             f2c1c5ad-22b5-4c21-8b54-7341b540b322   
Operation ID       edd71cd6709b4413b9405a8b4c3b77cc   
Operation Target   vpnConnection   
Operation Action   update   
State              running   
Progress           attach-subnets   
Message               
TMGW@cloudshell:~$

2、3分後、確認するとジョブが完了していました。

TMGW@cloudshell:~$ ibmcloud pi job f2c1c5ad-22b5-4c21-8b54-7341b540b322
Getting job f2c1c5ad-22b5-4c21-8b54-7341b540b322 under account IBM as user xxxxx@xxxx.com...
                      
Job ID             f2c1c5ad-22b5-4c21-8b54-7341b540b322   
Operation ID       edd71cd6709b4413b9405a8b4c3b77cc   
Operation Target   vpnConnection   
Operation Action   update   
State              completed   
Progress           attach-subnets   
Message               
TMGW@cloudshell:~$ 

何らかの原因でfailすると、下記のようにState=failedで結果が返ります。
下記の例では、対象subnetが既にCloud Connection(x86 CloudとのDirect Link接続)にattachされていた事が原因です。1つのサブネットをVPNトンネルとCloud Connectionの両方にattachすることはできないのでご注意ください。

TMGW@cloudshell:~$ ibmcloud pi job 53c35098-5a16-41d6-9feb-f10528024cf9
Getting job 53c35098-5a16-41d6-9feb-f10528024cf9 under account IBM as user xxxxx@xxxx.com...
                      
Job ID             53c35098-5a16-41d6-9feb-f10528024cf9   
Operation ID       bd2448fc837646e2aeebce7749b048ea   
Operation Target   vpnConnection   
Operation Action   update   
State              failed   
Progress           attach-subnets   
Message            network 795889b4-69fd-45f5-8e4b-6f4802d63e5f already attached to cloud connection 1ff0fa93-7257-434b-9026-1849291e88ea. detach from cloud connection or select another network   
TMGW@cloudshell:~$

ジョブが完了した後のVPNの状態です。(先ほどは値が入っていなかったNetworksの欄にsubnetが入っています)

TMGW@cloudshell:~$ ibmcloud pi vpn edd71cd6709b4413b9405a8b4c3b77cc
Getting VPN connection edd71cd6709b4413b9405a8b4c3b77cc under account IBM as user xxxxx@xxxx.com...
                           
ID                      edd71cd6709b4413b9405a8b4c3b77cc   
Name                    vpn01   
Status                  active   
Mode                    policy   
Local Gateway Address   163.68.xx.xx   
Peer Gateway Address    52.116.xx.xx   
VPN Gateway Address     163.68.xx.xx   
IKE Policy              ID: cd929593f6dd4a70b92f31cd99fa7ec5, Name: vpn01-ike   
IPSec Policy            ID: b64a98c8e2aa4f6bab63b85473d96c81, Name: vpn01-ipsec   
Peer Subnets            192.168.0.0/24   
Networks                795889b4-69fd-45f5-8e4b-6f4802d63e5f   
Dead Peer Detection     Action: restart, Interval: 10, Threshold: 5   
TMGW@cloudshell:~$ 

対向側VPN設定

対向側でVPN設定をします。

PowerVS側でIPSecを終端するIPアドレスは、上記の出力の中の「VPN Gateway Address」(上記の例では163.68.xx.xx)です。
IKE、IPSecは、Power側の値と合わせます。

StrongSwanを使った設定例を下記に書きました。
https://qiita.com/y_tama/items/55a88bfb38d7b0a14876

AIXのルーティング設定

IPSecの対向サブネット(今回の例では192.168.0.0/24)への通信を、subnet01のデフォルトゲートウェイに渡すよう静的経路をAIX上で設定します。

192.168.0/24       192.168.160.1     UGS       0         6 en1      -      -

疎通確認

設定が正常に行われると、疎通するようになります。AIXから対向のサーバーにpingが通りました。

# ping 192.168.0.6
PING 192.168.0.6 (192.168.0.6): 56 data bytes
64 bytes from 192.168.0.6: icmp_seq=0 ttl=59 time=143 ms
64 bytes from 192.168.0.6: icmp_seq=1 ttl=59 time=143 ms

#Cloud Connectionsとの併用
1つのサブネットは、Cloud ConnectionsとIPSecには同時に繋げられないので、AIXを2つのサブネットに所属させ、subnet01はIPSec、subnet02をCloud Connections、のように接続することで、両方と接続する事ができます。

image.png

以上です。

5
3
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
5
3