3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Power Systems Virtual Server on IBM Cloud (AIX) :IBM Cloud外部からAIX Serverに直接接続する方法 (IPSec-VPN接続の場合)

Last updated at Posted at 2020-08-11

はじめに (本記事は2020年8月時点のものです)

IBM Cloudでは、Power Virtual Server のサービスで AIX を利用することが可能です。
AIX環境にCloud外部から直接接続する場合は、いくつか方法がございます。

IBM Cloud マニュアルネットワーク・アーキテクチャーの図
https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-network-reference-architecture

今回はその中でも、IBM Cloud IaaS (Classis) 環境を介して、IPSec-VPNで接続する方法について記事にします。
(実際は、プロジェクトで実装したもののメモ書きです・・・)

IBM Cloud外の拠点からPower構成イメージとしてはこんな感じになります。
image.png

手元にVPN用のスイッチがないため、この記事では Client PC から IBM Cloud上のVPNサーバに接続し、Powerサーバへ接続する設定をガイドします。
またVPN方式は Cloud上に自由に使える「PPTPサーバ」があるので、そちらを利用します。

Power Serverに IaaS経由で接続するためには、どんなネットワークの関係になるか理解してもらえれば幸いです。

vpc環境 での接続については、こちらの記事が参考になります。
NAT変換するのは同じですが、vpcなので、privateとpublicの考え方がありません。

・IBM Cloud: Direct Link Connect 2.0によるIBM Cloud(X86:VPC)とPower Systems Virtual Serverの接続方法
https://qiita.com/testnin2/items/064ddc1c076511f9ad5c

今回実装した環境の構成

今回実装した環境の構成とIPアドレスは以下のような感じになります。
(もしAIXサーバ側からClient PC側に接続したい[ping飛ばしたい]場合は、IBM CloudでPortable Subnet/IPを購入し、それをVPNで利用するIPアドレスに付与すると良いです)

image.png

①PPTPサーバ、②Client PC、③AIXサーバでどのようなネットワーク設定を加えるか記載します。

各サーバのOSは以下のとおりです。
①PPTPサーバ:Debian 4.9.189-3+deb9u1 (2019-09-20) x86_64
②クライアントPC:macOS Mojave 10.14.6
③AIXサーバ:AIX 7.2

設定手順としては以下の手順でガイドします。

  1. VPN終端サーバ(PPTPサーバ)からAIXへの接続
  2. PPTP-VPN設定 ※本記事では対象外
  3. PPTPサーバでのNAT設定
  4. Client PCでのAIXへのルーティング設定

1. VPN終端サーバ(PPTPサーバ)からAIXへの接続

IBM Cloud IaaS上のサーバとDirect Connectで接続したPowerサーバとの間で疎通するためには、以下の2つの設定が必要です。
a)Powerサーバ側で、IaaS上のサーバに対するルーティングをPrivate Gatewayに向ける設定
b)IaaS側のサーバ側で、PowerのPrivate IPアドレスに対しるルーティングをPrivate Gatewayに向ける設定

1-a. Power側の設定

よって、「③ AIXサーバ側」では、IBM CloudのIPアドレス群(10.0.0.0/8)に対してのPrivate Gateway(今回は"192.168.0.2")を静的ルートとして設定します。
※ 10.0.0.0/8が嫌な場合は、IaaS上でアクセス必要なサブネットでも構いません。

netstat -rn でみると、以下のようなルーティングになります。
"10/8"は、"10.0.0.0/8"を意味しています。

10/8               192.168.100.2     UGS       2     97424 en1      -      - 

Private側(en1)のルーティング設定は以下のような感じです。

# netstat -rn | grep en1
default            192.168.130.89    UG        0    736395 en10     -      -   
10/8               192.168.100.2     UGS       2     97424 en1      -      -   
10.192.27/26       192.168.100.2     UGS       0       118 en1      -      -   
161.26/16          192.168.100.2     UGS       0         0 en1      -      -   
192.168.0/28       192.168.100.2     UGS       0         0 en1      -      -   
192.168.100.0      192.168.100.4     UHSb      0         0 en1      -      -   =>
192.168.100/24     192.168.100.4     U         4         6 en1      -      -   
192.168.100.255    192.168.100.4     UHSb      0         4 en1      -      -   
192.168.130.88     192.168.130.90    UHSb      0         0 en10     -      -   =>
192.168.130.88/29  192.168.130.90    U         1         1 en10     -      -   
192.168.130.95     192.168.130.90    UHSb      0         4 en10     -      - 

なお、PowerサーバのPrivate Gatewayはポータルで確認できます。
image.png

1-b. IaaS側の設定

IBM CloudのIaaS上のサーバである「①PPTPサーバ」にAIXサーバのサブネット(192.168.100.0/24)に対するルーティング設定を加えます。
PPTPサーバのOSは「Debian 4.9.189-3+deb9u1 (2019-09-20) x86_64」です。
"10.212.15.1"は、IAサーバに対するPrivate側のデフォルトゲートウェイのIPアドレスになります。
デフォルトゲートウェイは環境ごとに異なりますので、PortalやOSコマンドなどでご確認ください。

# ip route add 192.168.100.0/24 via 10.212.15.1 dev eth0

こんな感じのルーティング設定になっていれば大丈夫です。

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.0.0.0        10.212.15.1     255.0.0.0       UG        0 0          0 eth0
10.212.15.0     0.0.0.0         255.255.255.192 U         0 0          0 eth0
161.26.0.0      10.212.15.1     255.255.0.0     UG        0 0          0 eth0
166.8.0.0       10.212.15.1     255.252.0.0     UG        0 0          0 eth0
192.168.100.0   10.212.15.1     255.255.255.0   UG        0 0          0 eth0

Direct Connect、及び、AIX側のルーティングが正しく設定されていれば、pingが飛びsshで接続できるはずです。

# ping 192.168.100.4
PING 192.168.100.4 (192.168.100.4) 56(84) bytes of data.
64 bytes from 192.168.100.4: icmp_seq=1 ttl=244 time=137 ms
64 bytes from 192.168.100.4: icmp_seq=2 ttl=244 time=137 ms
64 bytes from 192.168.100.4: icmp_seq=3 ttl=244 time=137 ms
64 bytes from 192.168.100.4: icmp_seq=4 ttl=244 time=137 ms
# ssh -i ~/.ssh/id_rsa -l root 192.168.100.4
2913 unsuccessful login attempts since last login.
Last unsuccessful login: Fri Aug  7 11:31:23 JST 2020 on ssh from 222.186.31.127
Last login: Thu Aug  6 12:15:39 JST 2020 on /dev/pts/0 from 10.192.27.2
*******************************************************************************
*                                                                             *
*                                                                             *
*  Welcome to AIX Version 7.2!                                                *
*                                                                             *
*                                                                             *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*******************************************************************************
# 

2. PPTP-VPN設定 ※本記事では対象外

これでIaaS-AIX間の基本設定は終わりました。
次にVPN設定になりますが、この記事では記載せず、VPNサーバ(PPTPサーバ)の設定が完了したとします。

3. ②VPNサーバ(PPTPサーバ)でのNAT設定

次に ②VPNサーバ のNAT設定をします。
設定する項目は以下の2つです。
a) IP Forwardingの設定
b) NAT設定

なお、今回のPPTPサーバはDubianとなっておりますので、Dubianでの設定となります。
適宜利用OSにあわせて設定してください。

a) IP Forwading設定
"/etc/sysctl.conf"ファイルで「net.ipv4.ip_forward=1」を設定します。

root@dm-dubiansrv2002:~# cat /etc/sysctl.conf | grep ipv4
# net.ipv4.conf.default.rp_filter=1
# net.ipv4.conf.all.rp_filter=1
# net.ipv4.tcp_syncookies=1
net.ipv4.ip_forward=1

b) NAT設定

iptablesにNAT変換の設定をします

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

iptablesの設定はこんな感じになります。
これでPower側へアクセスする際に、PowerからPPTPサーバへ戻ることができるようになります。

# iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere            
# 

4. Client PCでのAIXへのルーティング設定

最後に②Client PC側(VPN接続元)で、VPN接続した状態で Powerへのルーティング設定を行います。
設定内容としては「AIXのアドレスをアクセスする際はVPNを経由してアクセスする」になります。

手元の MAC OS の場合、以下の設定になります。
192.168.100.0/24が、AIXが持つIPアドレスのサブネットで、
192.168.0.1は、PPTPサーバのVPNのIPアドレスです。

sudo route add -net 192.168.100.0/24 192.168.0.1

接続完了!

これで無事にクライアント側から接続することが可能となります。
③AIXサーバ から見える接続元は、②VPNサーバ(10.212.15.49) になっております。

macbook$ ping 192.168.100.4
PING 192.168.100.4 (192.168.100.4): 56 data bytes
64 bytes from 192.168.100.4: icmp_seq=0 ttl=242 time=144.961 ms
64 bytes from 192.168.100.4: icmp_seq=1 ttl=242 time=147.620 ms
64 bytes from 192.168.100.4: icmp_seq=2 ttl=242 time=144.370 ms
^C
--- 192.168.100.4 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 144.370/145.650/147.620/1.414 ms
macbook$ ssh -i ~/.ssh/id_rsa -l root 192.168.100.4
Last unsuccessful login: Tue Aug 11 12:40:51 JST 2020 on ssh from 218.xx.0.210
Last login: Tue Aug 11 12:41:43 JST 2020 on /dev/pts/0 from 10.212.15.49
*******************************************************************************
*                                                                             *
*                                                                             *
*  Welcome to AIX Version 7.2!                                                *
*                                                                             *
*                                                                             *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*******************************************************************************
# who
root        pts/0       Aug 11 12:43     (10.212.15.49)  
# netstat -rn
Routing tables
Destination        Gateway           Flags   Refs     Use  If   Exp  Groups

Route tree for Protocol Family 2 (Internet):
default            192.168.130.89    UG        5   1044996 en10     -      -   
10/8               192.168.100.2     UGS       2    128673 en1      -      -   
10.192.27/26       192.168.100.2     UGS       0       118 en1      -      -   
127/8              127.0.0.1         U         3     78564 lo0      -      -   
161.26/16          192.168.100.2     UGS       0         0 en1      -      -   
192.168.0/28       192.168.100.2     UGS       0         0 en1      -      -   
192.168.100.0      192.168.100.4     UHSb      0         0 en1      -      -   =>
192.168.100/24     192.168.100.4     U         4         6 en1      -      -   
192.168.100.4      127.0.0.1         UGHS      0         1 lo0      -      -   
192.168.100.255    192.168.100.4     UHSb      0         4 en1      -      -   
192.168.130.88     192.168.130.90    UHSb      0         0 en10     -      -   =>
192.168.130.88/29  192.168.130.90    U         1         1 en10     -      -   
192.168.130.90     127.0.0.1         UGHS      0         1 lo0      -      -   
192.168.130.95     192.168.130.90    UHSb      0         4 en10     -      -   

Route tree for Protocol Family 24 (Internet v6):
::/96              0.0.0.0           UC        0         0 sit0     -      -   =>
default            link#4            UC        0         0 en2      -      -   
::1%1              ::1%1             UH        0     80078 lo0      -      -   
fe80::/64          link#4            UCX       1         0 en2      -      -   
fe80::182f:ffff:fe15:ea03 1a:2f:ff:15:ea:3  UHL       1    184636 en2      -      -   
fe80::f84c:c2ff:fea3:fdb6                   UHXLWl    0       659 lo0      -      -   
ff01::%1/16        ::1               U         0         0 lo0      -      -   
ff02::/16          fe80::f84c:c2ff:fea3:fdb6 U         1      3047 en2      -      -   
ff11::%1/16        ::1               U         0         0 lo0      -      -   
ff12::/16          fe80::f84c:c2ff:fea3:fdb6 U         0         0 en2      -      -   
# exit
Connection to 192.168.100.4 closed.

接続完了時のネットワーク状態

念の為、上記のクライアント側からVPNサーバを介してAIXサーバに接続しているときの「①クライアントPC」と「②VPNサーバ」のネットワーク状態も記載します。

①クライアントPC

$ ifconfig -a

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether a8:66:7f:09:90:23 
	inet6 fe80::cd2:3d68:b49:b67d%en0 prefixlen 64 secured scopeid 0x5 
	inet 192.168.11.5 netmask 0xffffff00 broadcast 192.168.11.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
・・・<省略>・・・
ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1456
	inet 192.168.0.234 --> 192.168.0.1 netmask 0xffffff00 

dicek-mr:pppd daisuke$ netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            link#11            UCS            49        0    ppp0       
default            192.168.11.1       UGScI          33        0     en0       
8.8.4.4            link#11            UHWIi          10      105    ppp0       
8.8.8.8            link#11            UHWIi          17      114    ppp0       
9.57.174.157       link#11            UHW3I           0        0    ppp0     39
127                127.0.0.1          UCS             0        0     lo0       
127.0.0.1          127.0.0.1          UH              8   160534     lo0       
162.133.71.101     192.168.11.1       UGHS            1      276     en0       
169.254            link#5             UCS             0        0     en0      !
192.168.0.1        192.168.0.234      UH              1        0    ppp0       
192.168.0.234      ppp0               UHS             3       78    ppp0       
192.168.11         link#5             UCS             3        0     en0      !
192.168.11.1/32    link#5             UCS             1        0     en0      !
192.168.11.1       0:1d:73:b3:61:e5   UHLWIir        35      327     en0   1142
192.168.11.2       14:a:c5:a7:d6:e7   UHLWIi          3      177     en0    901
192.168.11.4       f8:62:14:3:92:3c   UHLWI           0        1     en0   1121
192.168.11.5/32    link#5             UCS             0        0     en0      !
192.168.11.255     ff:ff:ff:ff:ff:ff  UHLWbI          0        3     en0      !
192.168.100        192.168.0.1        UGSc            0        0    ppp0       
203.141.91.166     link#11            UHWIi           1       25    ppp0       
224.0.0/4          link#11            UmCS            2        0    ppp0       
224.0.0/4          link#5             UmCSI           1        0     en0      !
224.0.0.251        link#11            UHmW3I          0        0    ppp0     23
239.255.255.250    1:0:5e:7f:ff:fa    UHmLWI          0        4     en0       
239.255.255.250    link#11            UHmW3I          0       23    ppp0     51
255.255.255.255/32 link#11            UCS             0        0    ppp0       
255.255.255.255/32 link#5             UCSI            0        0     en0      !
$ traceroute 192.168.100.4
traceroute to 192.168.100.4 (192.168.100.4), 64 hops max, 52 byte packets
 1  192.168.0.1 (192.168.0.1)  15.118 ms  32.278 ms  24.987 ms
 2  169.254.152.59 (169.254.152.59)  21.892 ms  11.845 ms  14.945 ms
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  10.254.0.26 (10.254.0.26)  166.208 ms  154.960 ms  162.434 ms
13  192.168.100.4 (192.168.100.4)  155.096 ms  157.566 ms  151.122 ms
dicek-mr:pppd daisuke$ 

②VPNサーバ

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         162.133.71.97   0.0.0.0         UG        0 0          0 eth1
10.0.0.0        10.212.15.1     255.0.0.0       UG        0 0          0 eth0
10.212.15.0     0.0.0.0         255.255.255.192 U         0 0          0 eth0
161.26.0.0      10.212.15.1     255.255.0.0     UG        0 0          0 eth0
162.133.71.96   0.0.0.0         255.255.255.240 U         0 0          0 eth1
166.8.0.0       10.212.15.1     255.252.0.0     UG        0 0          0 eth0
192.168.0.234   0.0.0.0         255.255.255.255 UH        0 0          0 ppp0
192.168.100.0   10.212.15.1     255.255.255.0   UG        0 0          0 eth0
# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.212.15.49  netmask 255.255.255.192  broadcast 10.212.15.63
        inet6 fe80::468:46ff:fe88:4f1c  prefixlen 64  scopeid 0x20<link>
        ether 06:68:46:88:4f:1c  txqueuelen 1000  (Ethernet)
        RX packets 365604  bytes 239493947 (228.3 MiB)
        RX errors 0  dropped 24474  overruns 0  frame 0
        TX packets 161  bytes 9902 (9.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 162.133.71.101  netmask 255.255.255.240  broadcast 162.133.71.111
        inet6 fe80::4d0:c4ff:fed5:cf79  prefixlen 64  scopeid 0x20<link>
        ether 06:d0:c4:d5:cf:79  txqueuelen 1000  (Ethernet)
        RX packets 1495117  bytes 126930730 (121.0 MiB)
        RX errors 0  dropped 24474  overruns 0  frame 0
        TX packets 261660  bytes 41484010 (39.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 192.168.0.1  netmask 255.255.255.255  destination 192.168.0.234
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 852  bytes 60993 (59.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 28  bytes 2977 (2.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
# traceroute 192.168.100.4
traceroute to 192.168.100.4 (192.168.100.4), 30 hops max, 60 byte packets
 1  169.254.152.59 (169.254.152.59)  0.848 ms  0.766 ms  0.934 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  10.254.0.26 (10.254.0.26)  136.125 ms  136.637 ms  137.224 ms
12  192.168.100.4 (192.168.100.4)  138.111 ms  140.646 ms  137.448 ms

おわりに

外部から直接VPN経由でPower on IBM Cloud(AIXサーバ)へ接続する際の参考になれば幸いです。

参考サイト

AIXの初期設定や主要なコマンド群については、以下の記事などをご参照ください。
Power Systems Virtual Server on IBM Cloud (AIX) で最初にやること
IBM Cloud: Power Systems Virtual Server(AIX)でよく利用するコマンド

以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?