なにかの技術メモ置き場

なにかの技術メモ置き場

@インフラエンジニア

ラックのケーブリングを少し頑張る

f:id:none06:20210822085824j:plain

概要

今まで無視してきた、ラックのケーブリングを少しだけ頑張ってみた。

LANケーブルの作成

LANケーブルは自作するもの。
f:id:none06:20210819210316j:plain
切り出す。
f:id:none06:20210819210349j:plain
被膜を切り取る。
f:id:none06:20210819210400j:plain
銅線のヨリをほぐして並べる。
f:id:none06:20210819210413j:plain
長さを揃える。
f:id:none06:20210819210423j:plain
RJ-45コネクタを取り付ける。
f:id:none06:20210819210434j:plain
かしめる。
f:id:none06:20210819210445j:plain
ひたすら繰り返す。わりと時間がかかる。
f:id:none06:20210819210455j:plain

ケーブリング

スイッチに結線する。この密度が最高。
f:id:none06:20210822085920j:plain
上の隙間から背面にケーブルを逃がす。
f:id:none06:20210822090416j:plain
ラック背面にケーブルを送る。
f:id:none06:20210822085954j:plain
ラック背面上部で固定する。
f:id:none06:20210822090008j:plain
各機器の背面に結線する。難しい。
f:id:none06:20210822090124j:plain
f:id:none06:20210822090135j:plain

あとがき

ラック選び、しくじった。
ググるとわかるが、本来はケーブルを左右に逃がすことができる。しかし、このラックは全面パネルレスのため、逃がすとそのまま外に出てしまう。
オフィス向けの小型ラックが似た構造になっているらしく、そのケーブリングを参考にした。

参考tweet

QLogicのHBAでSANブートする

f:id:none06:20210807091758j:plain

概要

FC-SAN(※)環境が整ったので、憧れのSANブートをやってみた。
※厳密にはDAS。FC-SWがないので。

環境

概念図

不要?

構成図

TBD

機器構成

ホスト名 管理NWのIP OS H/W 備考
localhost - CentOS 8.3.2011 HP ProLiant DL360 G7 SANブートする物理マシン(HBA: QLE2562-HP)
DX60 172.16.0.101 ? ETERNUS DX60 S2 FC-SANストレージ

ポートマッピング

ストレージ サーバ 備考
CM#0 Port#0 Port0 -
CM#0 Port#1 - -
CM#1 Port#0 Port1 -
CM#1 Port#1 - -

背面写真

f:id:none06:20210807091510j:plain
f:id:none06:20210807091758j:plain

前提

  • シングルパスでストレージの設定が済んでいる。
    • CM#0 Port#0のみ設定済み(過去記事参照)。当記事では追加でCM#1 Port#0も設定し、マルチパス化する。
  • 10GBのボリュームを2つ作成済み。そのうち1つ目のボリュームでSANブートを行う。
  • SANブートの確認用のOSは新規インストールする。

手順

1. ケーブリング

ポートマッピングと背面写真のとおりにFCケーブルを結線する。

2. ログイン

ETERNUS Web GUIにログインする。

3. FCホストの設定

DL360G7_0(HBA Port0)は設定済み。DL360G7_1(HBA Port1)を追加する。
f:id:none06:20210807084521p:plain
f:id:none06:20210807084622p:plain
f:id:none06:20210807084626p:plain

4. ホストアフィニティの設定

CM#0 Port#0は設定済み。追加でCM#1 Port#0に設定をする。
f:id:none06:20210807084748p:plain

CM#0 Port#0の設定を見ておく。
f:id:none06:20210807085043p:plain

DL360G7_0(HBA Port0)のみアフィニティグループを割り当てている。
f:id:none06:20210807085046p:plain

CM#1 Port#0を設定する。
f:id:none06:20210807085111p:plain

DL360G7_1(HBA Port1)のみアフィニティグループを割り当てる。
f:id:none06:20210807085114p:plain
f:id:none06:20210807085118p:plain
f:id:none06:20210807085121p:plain

設定後の状態。ホスト数がそれぞれ1であることがポイント。
f:id:none06:20210807085137p:plain

5. HBAの設定

[Ctrl+Q]キーでQLogicのFast!UTILに入る。
f:id:none06:20210807090502p:plain

Functionが0のもの(HBA Port0)を選択する。
f:id:none06:20210807092756p:plain

[Configuration Settings]を選択する。
f:id:none06:20210807090218p:plain

[Adapter Settings]を選択する。
f:id:none06:20210807090616p:plain

[Host Adapter BIOS]を[Enabled]に変更する。
f:id:none06:20210807090619p:plain
f:id:none06:20210807090623p:plain

[Esc]キーでいくつか画面を戻り、[Selectable Boot Settings]を選択する。
f:id:none06:20210807090222p:plain

[Selectable Boot]を[Enalbed]に変更する。
[Boot Port Name, Lun]の1番上のエントリを設定する。
f:id:none06:20210807090225p:plain
f:id:none06:20210807090229p:plain

Port1も同様に設定する。

6. BIOSの設定

ローカルディスクを搭載していない場合は設定不要。RAIDコントローラとHBAのブート順序の設定のため。

[F9]キーを押下する。
f:id:none06:20210807090356p:plain

[コントローラのブート順]を変更する。
f:id:none06:20210807090359p:plain
f:id:none06:20210807090402p:plain
f:id:none06:20210807090406p:plain

7. OSのインストール

OSのインストーラを起動する。手段は任意。
f:id:none06:20210807085431p:plain

[インストール先]を選択する。
f:id:none06:20210807085434p:plain

[ディスクの追加]を選択する。
f:id:none06:20210807085438p:plain

10GBのボリューム2つを認識していることを確認できる。
f:id:none06:20210807085441p:plain

マルチパスで認識していることを確認できる。
f:id:none06:20210807085444p:plain

[mpatha]を選択する。
f:id:none06:20210807085447p:plain

こちら側も自動的に設定される。[完了]ボタンを押下する。
f:id:none06:20210807085451p:plain

ディスクを選択できた。
f:id:none06:20210807085454p:plain

以降、任意に設定しOSをインストールする.
f:id:none06:20210807085458p:plain

8. SANブート

OSのインストールが完了するとサーバが再起動する。問題なければGRUBの画面が表示される。
f:id:none06:20210807090834p:plain

OSのログイン画面が表示される。
f:id:none06:20210807090837p:plain

9. 動作確認

カーネルモジュールの認識

[root@localhost ~]# lsmod | grep qla
qla2xxx               880640  8
nvme_fc                45056  1 qla2xxx
scsi_transport_fc      69632  1 qla2xxx

バイスの認識

[root@localhost ~]# ls -l /sys/class/fc_host/
合計 0
lrwxrwxrwx. 1 root root 0  8月  7 04:02 host1 -> ../../devices/pci0000:00/0000:00:09.0/0000:06:00.0/host1/fc_host/host1
lrwxrwxrwx. 1 root root 0  8月  7 04:02 host4 -> ../../devices/pci0000:00/0000:00:09.0/0000:06:00.1/host4/fc_host/host4
[root@localhost ~]# grep "" /sys/class/fc_host/host*/port_name
/sys/class/fc_host/host1/port_name:0x50014380242710b0
/sys/class/fc_host/host4/port_name:0x50014380242710b2
[root@localhost ~]# grep "" /sys/class/fc_host/host*/port_state
/sys/class/fc_host/host1/port_state:Online
/sys/class/fc_host/host4/port_state:Online
[root@localhost ~]# grep "" /sys/class/fc_host/host*/speed
/sys/class/fc_host/host1/speed:4 Gbit
/sys/class/fc_host/host4/speed:4 Gbit

ディスクの認識

[root@localhost ~]# fdisk -l
ディスク /dev/sdb: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


ディスク /dev/sda: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: dos
ディスク識別子: 0x0009f1ff

デバイス   起動 開始位置 終了位置   セクタ サイズ Id タイプ
/dev/sda1  *        2048  2099199  2097152     1G 83 Linux
/dev/sda2        2099200  4196351  2097152     1G 82 Linux スワップ / Solaris
/dev/sda3        4196352 20971519 16775168     8G 83 Linux


ディスク /dev/sdd: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


ディスク /dev/sdc: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: dos
ディスク識別子: 0x0009f1ff

デバイス   起動 開始位置 終了位置   セクタ サイズ Id タイプ
/dev/sdc1  *        2048  2099199  2097152     1G 83 Linux
/dev/sdc2        2099200  4196351  2097152     1G 82 Linux スワップ / Solaris
/dev/sdc3        4196352 20971519 16775168     8G 83 Linux




ディスク /dev/mapper/mpatha: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: dos
ディスク識別子: 0x0009f1ff

デバイス            起動 開始位置 終了位置   セクタ サイズ Id タイプ
/dev/mapper/mpatha1 *        2048  2099199  2097152     1G 83 Linux
/dev/mapper/mpatha2       2099200  4196351  2097152     1G 82 Linux スワップ / Solaris
/dev/mapper/mpatha3       4196352 20971519 16775168     8G 83 Linux


ディスク /dev/mapper/mpathb: 10 GiB, 10737418240 バイト, 20971520 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

マルチパスの状態

[root@localhost ~]# multipath -ll
Aug 07 04:07:26 | /etc/multipath.conf line 3, duplicate keyword: find_multipaths
mpathb (3600000e00d0000000000358500010000) dm-1 FUJITSU,ETERNUS_DXL
size=10G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
-+- policy='service-time 0' prio=50 status=active
`- 1:0:0:1 sdb 8:16 active ready running
`-+- policy='service-time 0' prio=10 status=enabled `- 4:0:0:1 sdd 8:48 active ready running mpatha (3600000e00d0000000000358500000000) dm-0 FUJITSU,ETERNUS_DXL size=10G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
-+- policy='service-time 0' prio=50 status=active
`- 1:0:0:0 sda 8:0 active ready running
`-+- policy='service-time 0' prio=10 status=enabled `- 4:0:0:0 sdc 8:32 active ready running

起動ディスク

[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Aug  6 18:09:05 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=a81a1d3d-cc5f-4c4d-9da4-78e3c30ff453 /                       xfs     defaults        0 0
UUID=5f897012-920b-48e9-9dd9-79a2707add73 /boot                   xfs     defaults        0 0
UUID=d6ec5a00-5f69-46f7-a4c7-af8a984bda05 none                    swap    defaults        0 0
[root@localhost ~]# blkid
/dev/mapper/mpatha3: UUID="a81a1d3d-cc5f-4c4d-9da4-78e3c30ff453" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="0009f1ff-03"
/dev/sda: PTUUID="0009f1ff" PTTYPE="dos"
/dev/sdc: PTUUID="0009f1ff" PTTYPE="dos"
/dev/mapper/mpatha: PTUUID="0009f1ff" PTTYPE="dos"
/dev/mapper/mpatha1: UUID="5f897012-920b-48e9-9dd9-79a2707add73" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="0009f1ff-01"
/dev/mapper/mpatha2: UUID="d6ec5a00-5f69-46f7-a4c7-af8a984bda05" TYPE="swap" PARTUUID="0009f1ff-02"

ベンチマーク
TBD

参考サイト

-

CentOS8/7対応のHBA

f:id:none06:20210805064832j:plain

概要

CentOS8/7で動作確認したHBAの記録。

環境

概要図

TBD

動作実績

CentOS 8.4.2105

製品名 メーカー 結果 備考
QLE2562-HP QLogic -
QLE2460-HP QLogic × -

CentOS 7

製品名 メーカー 結果 備考
QLE2562-HP QLogic 未確認 -
QLE2460-HP QLogic -

製品ページ

-

ログ

CentOS 8.4.2105

QLE2562-HP
[root@kvm01 ~]# lspci | grep -i fibre
06:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
06:00.1 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
[root@kvm01 ~]# lsmod | grep qla
qla2xxx               901120  0
nvme_fc                49152  1 qla2xxx
scsi_transport_fc      81920  1 qla2xxx
[root@kvm01 ~]# ls -l /sys/class/fc_host/
合計 0
lrwxrwxrwx 1 root root 0  8月  4 11:16 host3 -> ../../devices/pci0000:00/0000:00:09.0/0000:06:00.0/host3/fc_host/host3
lrwxrwxrwx 1 root root 0  8月  4 11:17 host4 -> ../../devices/pci0000:00/0000:00:09.0/0000:06:00.1/host4/fc_host/host4
QLE2460-HP

TBD

CentOS 7

QLE2562-HP

TBD

QLE2460-HP

TBD

参考サイト

-

ETERNUS DX60 S2 CLI設定メモ

f:id:none06:20210801103911j:plain

概要

ETERNUS DX60 S2のCLI設定メモ。
初期化済みの状態からサーバにボリュームを提供できる状態までの設定。

環境

概要図

TBD

構成

ノード構成

ホスト名 管理NWのIP OS H/W 備考
DX60 172.16.0.101 TBD FUJITSU ETERNUS DX60 S2 -
localhost 任意 CentOS 8.4.2105 HP ProLiant DL360 G7 HBA: QLE2562-HP

物品構成

製品名 型番 用途 備考
FUJITSU ETERNUS DX60 S2 ET062DCF ストレージ -
? QLE2562-HP HBA -

ストレージ構成
  • 接続ポート
    • storage: CM#0 Port#0
    • server: Port0
  • ディスク構成
    • System Disk:Disk#00,01
    • Data Disk:Disk#02,03,04,05,06
  • RAIDグループ
    • name: RG0
    • level: RAID6
  • ボリューム
    • name: LV0
      • size: 10GB
    • name: LV1
      • size: 10GB
  • FCホスト
    • name: DL360G7_0
    • wwn: 50014380242710b0
  • アフィニティグループ
    • name: AG0
    • No: 0
      • lun: 0
      • volume: LV0
    • No: 1
      • lun: 1
      • volume: LV1
  • ホストアフィニティ
    • port: 00(CM#0 Port#0)
    • host-name: DL360G7_0
    • ag-name: AG0

前提

  • サーバ側(HBA)の接続設定は実施済みとする。

コマンド

# RAIDグループの作成
show raid-groups
create raid-group -name RG0 -level 6 -disks 002-006
show raid-groups

# ボリュームの作成
show volumes
create volume -name LV -count 2 -rg-name RG0 -type open -size 10gb
show volume-progress
show volumes

# FCホスト設定の作成
show host-wwn-names
discover host-wwn-names
create host-wwn-name -name DL360G7_0 -wwn 50014380242710b0
show host-wwn-names

# アフィニティグループの作成
show affinity-groups
create affinity-group -name AG0 -lun 0,1 -volume-name LV0,LV1
show affinity-groups -ag-name AG0
show affinity-groups

# ホストアフィニティの設定
show host-affinity
set host-affinity -port 00 -ag-name AG0 -host-name DL360G7_0
show host-affinity

操作ログ

# RAIDグループの作成
CLI> show raid-groups
CLI> create raid-group -name RG0 -level 6 -disks 002-006
CLI> show raid-groups
RAID Group           RAID    Assigned Status                    Total        Free
No. Name             Level   CM                                 Capacity(MB) Capacity(MB)
  0 RG0              RAID6   CM#0     Available                      1677312      1677312
CLI>

# ボリュームの作成
CLI> show volumes
CLI> create volume -name LV -count 2 -rg-name RG0 -type open -size 10gb
CLI> show volume-progress
Volume                 Status                     Formatting  Migrating  Encrypting
No.  Name                                         Progress    Progress   Progress
   0 LV0               Available                          7%          -           -
   1 LV1               Available                          0%          -           -
CLI> show volumes
Volume                Status                    Type      Encryption Expansion       RAID Group           Size(MB)   Reserved
No.  Name                                                            (Concatenation) No. Name                        Deletion
   0 LV0              Available                 Open      OFF                      -   0 RG0                  10240
   1 LV1              Available                 Open      OFF                      -   0 RG0                  10240
CLI>

# FCホスト設定の作成
CLI> show host-wwn-names
CLI> discover host-wwn-names
CM#0 Port#0
    50014380242710b0
CLI> create host-wwn-name -name DL360G7_0 -wwn 50014380242710b0
CLI> show host-wwn-names
Host                 WWN              Host Response
No. Name                              No. Name
  0 DL360G7_0        50014380242710b0   0 Default
CLI>

# アフィニティグループの作成
CLI> show affinity-groups
CLI> create affinity-group -name AG0 -lun 0,1 -volume-name LV0,LV1
CLI> show affinity-groups -ag-name AG0
Affinity Group No.0
Affinity Group Name   AG0
LUN  Volume                Status                    Size(MB) Multi-Group
     No.  Name                                                Volume
   0    0 LV0              Available                    10240 No
   1    1 LV1              Available                    10240 No
CLI> show affinity-groups
Affinity Group       Multi-Group
No. Name             Volumes
  0 AG0              No
CLI>

# ホストアフィニティの設定
CLI> show host-affinity
CM#0 Port#0 (Host Affinity Mode Enable)

CM#0 Port#1 (Host Affinity Mode Enable)

CM#1 Port#0 (Host Affinity Mode Enable)

CM#1 Port#1 (Host Affinity Mode Enable)
CLI> set host-affinity -port 00 -ag-name AG0 -host-name DL360G7_0
CLI> show host-affinity
CM#0 Port#0 (Host Affinity Mode Enable)
Host                 Affinity Group       Multi-Group
No. Name             No. Name             Volumes
  0 DL360G7_0          0 AG0              No

CM#0 Port#1 (Host Affinity Mode Enable)

CM#1 Port#0 (Host Affinity Mode Enable)

CM#1 Port#1 (Host Affinity Mode Enable)
CLI>

おまけ:設定削除コマンド

操作ログは割愛。

# ホストアフィニティの削除
show host-affinity
release host-affinity -port 00 -host-name DL360G7_0
show host-affinity

# アフィニティグループの削除
show affinity-groups
delete affinity-group -ag-name AG0
show affinity-groups

# FCホスト設定の削除
show host-wwn-names
delete host-wwn-name -host-name DL360G7_0
show host-wwn-names

# ボリュームの削除
show volumes
delete all-volumes -rg-name RG0
show volumes

# RAIDグループの削除
show raid-groups
delete raid-group -rg-name RG0
show raid-groups

補足

-

ETERNUS DX60 S2 導入記録

f:id:none06:20210801103911j:plain

目次

概要

念願のFCストレージをお迎えした。初期化や最小構成での設定を記録した。

環境

概要図

ノード構成

ホスト名 管理NWのIP OS H/W 備考
DX60 172.16.0.101 TBD FUJITSU ETERNUS DX60 S2 -
kvm01 任意 CentOS7 HP ProLiant DL360 G7 HBA: QLE2460-HP

物品構成

製品名 型番 用途 備考
FUJITSU ETERNUS DX60 S2 ET062DCF ストレージ -
? QLE2460-HP HBA -

購入

  1. 某オークションサイトにて購入。
    • 本体
    • レールキット

設置

  1. ラックにレールを取り付ける。 f:id:none06:20210801090102j:plain f:id:none06:20210801090136j:plain f:id:none06:20210801090146j:plain

  2. レールに筐体を搭載する。 f:id:none06:20210801090212j:plain f:id:none06:20210801090222j:plain

  3. 電源ケーブル、LANケーブルを接続する。 f:id:none06:20210801090334j:plain

    • LANケーブルはMNTポートに接続する。
  4. システムディスクを搭載する。 f:id:none06:20210801090858j:plain

    • 写真ではDisk#0~#17にマウンタが付いているが、実際にはDisk#0,#1にしか搭載していない。
    • Disk#0,#1に搭載したディスクがシステムディスク、Disk#2以降に搭載したディスクがデータディスクになるらしい。そういう仕様。

初期化

  1. MNTポートのIPアドレスを初期化する。中古で購入したためIPアドレスが不明である前提とする。 f:id:none06:20210801095626j:plain

    • [IP RST]ボタンを2秒以内に2回連続して押下する。
    • デフォルト値[192.168.1.1]に初期化される。
  2. 保守担当員(CE)権限アカウントでETERNUS Web GUIにログインする。 f:id:none06:20210801091456p:plain

  3. システムディスクの初期化を行う。

ストレージ側の設定

  1. RAIDグループを作成する。 f:id:none06:20210801093339p:plain f:id:none06:20210801093342p:plain f:id:none06:20210801093346p:plain

  2. ボリュームを作成する。 f:id:none06:20210801093430p:plain f:id:none06:20210801093434p:plain f:id:none06:20210801093437p:plain

  3. FCホスト設定を行う。 f:id:none06:20210801093631p:plain f:id:none06:20210801093634p:plain

    • WWNを自動入力したい場合は先に「サーバ側の設定(HBA)」「接続」を完了させること。
  4. LUNマッピング設定を行う。

    1. アフィニティグループを作成する。 f:id:none06:20210801093814p:plain f:id:none06:20210801093818p:plain f:id:none06:20210801093821p:plain
    2. ポートにアフィニティグループを紐づける。 f:id:none06:20210801093924p:plain f:id:none06:20210801093927p:plain f:id:none06:20210801093930p:plain f:id:none06:20210801093934p:plain

サーバ側の設定(HBA)

  1. サーバにHBAを搭載する。 f:id:none06:20210801100611j:plain f:id:none06:20210801100623j:plain

  2. HBAの設定を行う。 f:id:none06:20210801101347p:plain

    • SANブートしないならデフォルトで良さそう。

接続

  1. サーバとストレージをFCケーブルで接続する。 f:id:none06:20210801101039j:plain

    • サーバ側。4GbpsでLinkUpしている。 f:id:none06:20210801101102j:plain
    • ストレージ側。LinkUpしている。 f:id:none06:20210801101127j:plain
  2. HBAからボリュームが認識できていることを確認する。 f:id:none06:20210801101503p:plain f:id:none06:20210801101507p:plain

サーバ側の設定(OS)

1.カーネルモジュールをインストールする。

# modprobe qla2xxx
  • CentOS7ではデフォルトでインストール済みだった。

2.OSから確認する。 カーネルモジュールがインストールされていること。

[root@localhost ~]# lsmod | grep qla
qla2xxx               807125  0 
nvme_fc                33721  1 qla2xxx
scsi_transport_fc      64007  1 qla2xxx

ポートの状態や速度を表示できること。

[root@localhost ~]# cat /sys/class/fc_host/host1/port_state
Online
[root@localhost ~]# cat /sys/class/fc_host/host1/port_speed 
4 Gbit

ディスクを認識していること。/dev/sdaがローカル、/dev/sdbがFC経由。

[root@localhost ~]# fdisk -l

Disk /dev/sda: 600.1 GB, 600093712384 bytes, 1172058032 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x000951e3

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    55709695    26805248   82  Linux swap / Solaris
/dev/sda3        55709696  1172056063   558173184   83  Linux

Disk /dev/sdb: 10.5 GB, 10485760000 bytes, 20480000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

せっかくなのでベンチマーク

[root@localhost ~]# hpddparm -t de/dev/sd?

/dev/sda:
 Timing buffered disk reads: 518 MB in  3.00 seconds = 172.42 MB/sec

/dev/sdb:
 Timing buffered disk reads: 596 MB in  3.01 seconds = 198.30 MB/sec
  • FCの理論値(500MB/sec=4Gbps)に届いていない。RAIDグループをRAID1で作成したためSASディスクの読み取り速度がボトルネックになっている。

トラブル1

システムディスクの初期化が失敗した。ディスクのステータスを見ると「Not Supported」となっている。 f:id:none06:20210801091622p:plain

調べたところ、フォーマットが異なることが原因だと判明した。 qiita.com https://www.sgv417.jp/~makopi/blog/archives/3701

サーバやPC用のディスクはセクタサイズが512byteだが、一部のストレージ用のディスクは520byteらしい。

そのへんに転がっているLinuxサーバにディスクを接続し、520byteでフォーマットする。600GBで1時間以上かかった。

[root@localhost ~]# fdisk -l /dev/sdc

ディスク /dev/sdc: 558.9 GiB, 600127266816 バイト, 1172123568 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: dos
ディスク識別子: 0x00085e39

デバイス   起動 開始位置   終了位置     セクタ サイズ Id タイプ
/dev/sdc1           2048       4095       2048     1M 83 Linux
/dev/sdc2  *        4096 1172123534 1172119439 558.9G 83 Linux
[root@localhost ~]# sg_format --format --size=520 /dev/sdc
    SEAGATE   ST600MM0006       6103   peripheral_type: disk [0x0]
      << supports protection information>>
      Unit serial number: S0M6YHM20000K6276TJS
      LU name: 5000c50095ff8b03
Mode Sense (block descriptor) data, prior to changes:
  Number of blocks=1172123568 [0x45dd2fb0]
  Block size=512 [0x200]

A FORMAT UNIT will commence in 15 seconds
    ALL data on /dev/sdc will be DESTROYED
        Press control-C to abort

A FORMAT UNIT will commence in 10 seconds
    ALL data on /dev/sdc will be DESTROYED
        Press control-C to abort

A FORMAT UNIT will commence in 5 seconds
    ALL data on /dev/sdc will be DESTROYED
        Press control-C to abort

Format unit has started
Format in progress, 1.01% done
Format in progress, 2.03% done
・・・
FORMAT Complete

再度ストレージにディスクを搭載し、システムディスクの初期化を行う。

トラブル2

CentOS8でボリュームを認識できない。HBAは認識している(lspci)。カーネルドライバ(qla2xxx)はインストールされている(lsmod)。原因切り分けのためにCentOS7で試したところあっさり認識した。 H/W被疑ではないことが切り分けできたため、CentOS8対応は追って調査していく。

あとがき

  • CentOS8で実装したい。カーネル再構築とかめんどうなので、CentOS8に標準対応したHBAを導入する方針。 →した。 none06.hatenadiary.org
  • SANブートはできたので別記事にて。
  • CLI手順も整備したい。 →した。 none06.hatenadiary.org
  • FC-SWを導入してFC-SAN構成にしたい。

参考サイト

AWS CloudFormationを使ってみた - Route 53/EC2によるDR環境構築

f:id:none06:20210710190259p:plain

概要

AWS CloudFormationでインフラ構築を自動化する。
Route 53を使用したDR(Disaster Recovery)環境を構築する。

目的

  • CloudFormationに慣れる
  • 構築の自動化
  • 構築の冪等性の確保
  • 構築内容・手順の可視化(IaC)

今回作成する構成

f:id:none06:20210710190259p:plain

処理概要

スタック1 - プライマリサイトのEC2インスタンスの構築

  • VPCを作成
  • サブネットを作成
  • インタネットゲートウェイを作成
  • ルートテーブルを作成
  • ルートテーブルをサブネットに紐づけ
  • Elastic IPを作成
  • Elastic IPをECインスタンスにアタッチ
  • EC2セキュリティグループを作成
  • EC2インスタンスを作成
  • Elastic IPをアウトプット/エクスポート

スタック2 - セカンダリサイトのEC2インスタンスの構築

  • VPCを作成
  • サブネットを作成
  • インタネットゲートウェイを作成
  • ルートテーブルを作成
  • ルートテーブルをサブネットに紐づけ
  • Elastic IPを作成
  • Elastic IPをECインスタンスにアタッチ
  • EC2セキュリティグループを作成
  • EC2インスタンスを作成
  • Elastic IPをアウトプット/エクスポート

スタック3 - Route53でのフェイルオーバールーティングの設定

  • ホストゾーンの作成
  • プライマリサイト向けDNSレコードの作成
  • セカンダリサイト向けDNSレコードの作成
  • ヘルスチェックの作成

作成したテンプレート

template01.yaml

スタック1、スタック2用のテンプレート。処理が全く同じなので同じテンプレートをを使用する。というか管理する資材(テンプレート)を増やしたくなかったため、マルチリージョン・マルチサイトに対応するよう設計した。

AWSTemplateFormatVersion: "2010-09-09"
Description: TBD

Parameters:
  # EC2 Instance Type
  InstanceType:
    Description: EC2 Instance type
    Type: String
    Default: t2.micro
    AllowedValues:
    - t1.micro
    - t2.nano
    - t2.micro
    - t2.small
    - t2.medium
    - t2.large
    ConstraintDescription: must be a valid EC2 instance type

Mappings:
  RegionAmiMap:
    ap-northeast-1:
      hvm: ami-001f026eaf69770b4
    ap-southeast-1:
      hvm: ami-0e8e39877665a7c92
  RegionAzMap:
    ap-northeast-1:
      AZ: ap-northeast-1a
    ap-southeast-1:
      AZ: ap-southeast-1a
  RegionKeypairMap:
    ap-northeast-1:
      KeyPair: keypair-ap-northeast-1
    ap-southeast-1:
      KeyPair: keypair-ap-southeast-1
  RegionSiteMap:
    ap-northeast-1:
      Site: Primary
    ap-southeast-1:
      Site: Secondary

Resources:
  # VPC
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      Tags:
      - Key: Application
        Value: !Ref AWS::StackId
      - Key: Name
        Value: !Sub ${AWS::StackName}-vpc
  # Subnet
  Subnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId:
        Ref: VPC
      CidrBlock: 10.0.0.0/24
      AvailabilityZone: !FindInMap [RegionAzMap, !Ref AWS::Region, AZ]
      Tags:
      - Key: Application
        Value: !Ref AWS::StackId
      - Key: Name
        Value: !Sub ${AWS::StackName}-sbunet
  # Internet Gateway
  InternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
      - Key: Application
        Value: !Ref AWS::StackId
      - Key: Name
        Value: !Sub ${AWS::StackName}-igw
  AttachGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref InternetGateway
  # Route Table
  RouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref VPC
      Tags:
      - Key: Application
        Value: !Ref AWS::StackId
      - Key: Name
        Value: !Sub ${AWS::StackName}-rtb
  # Route
  Route:
    Type: AWS::EC2::Route
    DependsOn: AttachGateway
    Properties:
      RouteTableId: !Ref RouteTable
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref InternetGateway
  # Subnet Route Table Association
  SubnetRouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref Subnet
      RouteTableId: !Ref RouteTable
  # Elastic IP Address
  EIP:
    Type: AWS::EC2::EIP
    DependsOn: AttachGateway
    Properties:
      Domain: vpc
      InstanceId: !Ref EC2Instance
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-eip
  AttachEIP:
    Type: AWS::EC2::EIPAssociation
    Properties:
      AllocationId: !GetAtt EIP.AllocationId
      InstanceId: !Ref EC2Instance
  # Instance Security Group
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      VpcId: !Ref VPC
      GroupDescription: Accept SSH, HTTP
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 22
        ToPort: 22
        CidrIp: 0.0.0.0/0
      - IpProtocol: tcp
        FromPort: 80
        ToPort: 80
        CidrIp: 0.0.0.0/0
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-securitygroup
  # EC2 Instance 
  EC2Instance:
    Type: AWS::EC2::Instance
    DependsOn: AttachGateway
    Properties:
      ImageId: !FindInMap [RegionAmiMap, !Ref AWS::Region, hvm]
      AvailabilityZone: !FindInMap [RegionAzMap, !Ref AWS::Region, AZ]
      InstanceType: !Ref InstanceType
      KeyName: !FindInMap [RegionKeypairMap, !Ref AWS::Region, KeyPair]
      NetworkInterfaces:
      - GroupSet:
        - Ref: InstanceSecurityGroup
        AssociatePublicIpAddress: true
        DeviceIndex: 0
        DeleteOnTermination: true
        SubnetId: !Ref Subnet
      UserData:
        Fn::Base64: !Sub
          - |
            #!/bin/bash -xe
            sudo su -
            yum -y install httpd
            cat <<EOF > /var/www/html/index.html
            <html><h1>Here is ${SITE}!</h1></html>
            EOF
            cat /var/www/html/index.html
            systemctl enable httpd.service --now
            systemctl status httpd.service
            curl http://localhost/
            exit
            exit
          - {
              SITE: !FindInMap [RegionSiteMap, !Ref AWS::Region, Site]
            }
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-instance

Outputs:
  EIP:
    Value: !Ref EIP
    Export:
      Name: !Join ["", [!FindInMap [RegionSiteMap, !Ref AWS::Region, Site], EIP] ]

template02.yaml

スタック3用のテンプレート。

AWSTemplateFormatVersion: "2010-09-09"
Description: TBD

Parameters:
  # Hosted Zone
  HostedZoneName:
    Type: String
    Description: DNS Name to create
    Default: example.co.jp
    AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
    ConstraintDescription: must be a valid DNS zone name
  # Secondary Elastic IP
  SecondaryEIP:
    Type: String
    Description: Secondary Elastip IP
    Default: _SecondaryEIP_

Resources:
  # Hosted Zone
  HostedZone:
    Type: AWS::Route53::HostedZone
    Properties:
      Name: !Ref HostedZoneName
      HostedZoneTags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-hostedzone
  # Primary DNS Record
  PrimaryDNSRecord:
    Type: AWS::Route53::RecordSet
    DependsOn: HostedZone
    Properties:
      HostedZoneId: !Ref HostedZone
      Comment: DNS Name for Elastic IP Address
      Name: !Join ["", [www, ".", !Ref HostedZoneName, "."] ]
      Type: A
      TTL: 60
      ResourceRecords:
      - !ImportValue PrimaryEIP
      Failover: PRIMARY
      HealthCheckId: !Ref HealthCheck
      SetIdentifier: ec2-primary
  # Secondary DNS Record
  SecondaryDNSRecord:
    Type: AWS::Route53::RecordSet
    DependsOn: HostedZone
    Properties:
      HostedZoneId: !Ref HostedZone
      Comment: DNS Name for Elastic IP Address
      Name: !Join ["", [www, ".", !Ref HostedZoneName, "."] ]
      Type: A
      TTL: 60
      ResourceRecords:
      #- !ImportValue SecondaryEIP
      - !Ref SecondaryEIP
      Failover: SECONDARY
      #HealthCheckId: !Ref HealthCheck
      SetIdentifier: ec2-secondary
  # HealthCheck
  HealthCheck:
    Type: AWS::Route53::HealthCheck
    Properties:
      HealthCheckConfig:
        Type: HTTP
        IPAddress: !ImportValue PrimaryEIP
        Port: 80
        FullyQualifiedDomainName: !Join ["", [www, ".", !Ref HostedZoneName] ]
        ResourcePath: /index.html
        RequestInterval: 30
        FailureThreshold: 3
      HealthCheckTags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-healthcheck

前提条件

  • プライマリサイトとセカンダリサイトのリージョンは異なる場所にする。DRなので。

サイト リージョン 補足
プライマリ ap-norheast-1 東京
セカンダリ ap-southeast-1 シンガポール

キーペア名 リージョン
keypair-ap-norheast-1 ap-norheast-1
keypair-ap-southeast-1 ap-southeast-1

  • ドメイン名はexample.co.jpとする。
  • スタック1とスタック3は同一リージョンのCloudFormationで作成する。
    • Elastic IPの値をスタック1からExportし、スタック3にImportするため。Export/Importは同一リージョン内でのみ可能。
    • スタック2はリージョンが異なるためExport/Importができない。そのため、手動で値をコピーする方式とした。自動化の検討ポイントである。

スタックの作成

今までは1つのスタックだけだったため気にする必要がなかったが、今回は3つのスタックを順序性を意識して実行する。

  • 1と2は順不同。並列実行も可能。
  • 3の開始条件は「1の完了」かつ「2の完了」。順序性を意識するのはここだけ。

1.プライマリサイトの構築

  • プライマリサイトのリージョン(ap-northeast-1)のCloudFormationでスタック1を作成する。
  • テンプレートはtemplate01.yml。
  • スタック名は任意。

2.セカンダリサイトの構築

  • セカンダリサイトのリージョン(ap-southeast-1)のCloudFormationでスタック2を作成する。
  • テンプレートはtemplate01.yml。
  • スタック名は任意。

3.フェイルオーバールーティングの設定

  • スタック2の出力より「SecondaryEIP」の値をコピーする。
  • プライマリサイトのリージョン(ap-northeast-1)のCloudFormationでスタック3を作成する。
  • テンプレートはtemplate02.yml。
  • スタック名は任意。
  • パラメータ「SecondaryEIP」にはコピーしておいた「SecondaryEIP」の値を入力する。

参考

これらをAWS CLILinuxコマンドで表したものを掲載しておく。

# 1.プライマリサイトの構築
aws cloudformation create-stack --stack-name stack01 --region ap-northeast-1 --template-body file://template01.yml
aws cloudformation describe-stacks --stack-name stack01 --region ap-northeast-1

# 2.セカンダリサイトの構築
aws cloudformation create-stack --stack-name stack02 --region ap-southeast-1 --template-body file://template01.yml
aws cloudformation describe-stacks --stack-name stack02 --region ap-southeast-1

# 3.フェイルオーバールーティングの設定
_SecondaryEIP=`aws cloudformation describe-stacks --stack-name stack02 --region ap-southeast-1 --output text | grep OUTPUTS | grep SecondaryEIP | awk '{print $4}'`
sed "s/_SecondaryEIP_/${_SecondaryEIP}/g" template02.yml > template02_tmp.yml
diff template02.yml template02_tmp.yml
aws cloudformation create-stack --stack-name stack03 --region ap-northeast-1 --template-body file://template02_tmp.yml
aws cloudformation describe-stacks --stack-name stack03 --region ap-northeast-1

スタック作成後の作業

1.ドメインの取得

任意のサービスでドメイン名「example.co.jp」を取得する。有料だがAWSでも取得できる。
なお、スタック作成前でも可。

2.ドメインサービス側の設定

Route53のホストゾーンのNSレコードのDNSサーバ名を、ドメインサービス側のDNSサーバに登録する。

3.動作確認

http://www.example.co.jpにアクセスし、以下を確認する。

  • プライマリサイトの正常稼働時は「Here is Primary!」と表示されること。
  • プライマリサイトを停止すると「Here is Secondary!」に表示が変わること。
  • プライマリサイトを復旧すると「Here is Primary!」に表示が変わること。

あとがき

まだまだ自動化の余地がある。スタックが完了したら次のスタックを起動するなどの処理はAWSのサービスで実現可能なはず。

AWS CloudFormationを使ってみた - Site-to-Site VPN

f:id:none06:20210706223542p:plain

概要

AWS CloudFormationでインフラ構築を自動化する。
オンプレミス環境とのVPN接続を設定する。

目的

  • CloudFormationに慣れる
  • 構築の自動化
  • 構築の冪等性の確保
  • 構築内容・手順の可視化(IaC)

今回作成する構成

f:id:none06:20210706223542p:plain

処理概要

作成したテンプレート

AWSTemplateFormatVersion: 2010-09-09

Parameters:
  # VPC
  VpcCidrBlock:
    Description: VPC CIDR Block
    Type: String
    Default: 172.18.0.0/16
  # Customer Gateway IP
  CustomerGatewayIp:
    Description: Gustomer Gateway IP
    Type: String
    Default: X.X.X.X
  # Subnet
  SubnetCidrBlock:
    Description: Subnet CIDR Block
    Type: String
    Default: 172.18.0.0/24
  # EC2 Instance Type
  InstanceType:
    Description: EC2 Instance Type
    Type: String
    Default: t2.micro
    ConstraintDescription: must be a valid EC2 instance type
  # Key Pair Name
  KeyName:
    Description: Key Pair Name
    Type: AWS::EC2::KeyPair::KeyName
    Default: keypair01
    ConstraintDescription: Can contain onluy ASCII characters

Mappings:
  # EC2 Instance image Map
  RegionMap:
    ap-northeast-1:
      hvm: "ami-001f026eaf69770b4"
    ap-southeast-1:
      hmv: "ami-0e8e39877665a7c92"

Resources:
  # VPC
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcCidrBlock
      EnableDnsSupport: true
      EnableDnsHostnames: true
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-vpc
  # Customer Gateway
  CustomerGateway:
    Type: AWS::EC2::CustomerGateway
    Properties:
      Type: ipsec.1
      BgpAsn: 65000
      IpAddress: !Ref CustomerGatewayIp
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-cgw
  # VPN Gateway
  VPNGateway:
    Type: AWS::EC2::VPNGateway
    Properties:
      Type: ipsec.1
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-vgw
  AttachVPNGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref VPC
      VpnGatewayId: !Ref VPNGateway
  # VPN Connection
  VPNConnection:
    Type: AWS::EC2::VPNConnection
    Properties:
      Type: ipsec.1
      StaticRoutesOnly: False
      CustomerGatewayId: !Ref CustomerGateway
      VpnGatewayId: !Ref VPNGateway
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-vpnconn
  # Subnet
  Subnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref VPC
      CidrBlock: !Ref SubnetCidrBlock
      MapPublicIpOnLaunch: False
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-subnet
  # Route Table
  RouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref VPC
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-rtb
  RouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId: !Ref RouteTable
      SubnetId: !Ref Subnet
  RoutePropagation:
    Type: AWS::EC2::VPNGatewayRoutePropagation
    DependsOn: AttachVPNGateway
    Properties:
      RouteTableIds:
      - !Ref RouteTable
      VpnGatewayId: !Ref VPNGateway
  # EC2 Security Group
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      VpcId: !Ref VPC
      GroupDescription: Accept SSH, ICMP
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 22
        ToPort: 22
        CidrIp: 0.0.0.0/0
      - IpProtocol: icmp
        FromPort: -1
        ToPort: -1
        CidrIp: 0.0.0.0/0
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-securitygroup
  # EC2 Instance
  EC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId:
        Fn::FindInMap: [RegionMap, Ref: AWS::Region, hvm]
      InstanceType:
        Ref: InstanceType
      KeyName:
        Ref: KeyName
      Tags:
      - Key: Name
        Value: !Sub ${AWS::StackName}-instance
      NetworkInterfaces:
      - GroupSet:
        - Ref: InstanceSecurityGroup
        AssociatePublicIpAddress: false
        DeviceIndex: 0
        DeleteOnTermination: true
        SubnetId: !Ref Subnet

前提条件

  • CustomerGatewayIpは各自のオンプレのルータのIPアドレスを設定すること。
  • ECインスタンスのキーペアはAWSに登録済みのものを使用する。当環境ではkeypair01を使用。

スタック作成後の作業

1.NATルータのポート開放/マッピング(環境に依存)

当環境ではインターネット接続にNATルータを使用している。いわゆる市販の「無線LAN親機+有線LANのルータ」だ。これがVPNセッションの間に存在する。AWS側のエンドポイント発→オンプレ側のエンドポイント着の通信を通すため、NATルータに転送設定を入れる必要がある。

ポート プロトコル 用途
500 UDP ISAKMP
4500 UDP IPSec NAT Traversal
179 TCP BGP

2.ルータの構築[オンプレ]

そのへんにルータが転がっていなかったので、フリーのソフトウェアルータであるVyOSを使用。QEMU+KVMの仮想ゲストとして作成。VyOSの基本設定は別記事に記載予定。

3.ルータのVPN接続設定[オンプレ]

AWSVPN設定画面より、ルータに投入するコンフィグを入手する。
f:id:none06:20210706232050j:plain

! Amazon Web Services
! Virtual Private Cloud

! AWS utilizes unique identifiers to manipulate the configuration of
! a VPN Connection. Each VPN Connection is assigned an identifier and is
! associated with two other identifiers, namely the
! Customer Gateway Identifier and Virtual Private Gateway Identifier.
!
! Your VPN Connection ID                  : vpn-0f6da5e2f75ebe6a1
! Your Virtual Private Gateway ID         : vgw-0d3787853b3d7acf6
! Your Customer Gateway ID                : cgw-0bbe8c483fb8bcd62
!
!
! This configuration consists of two tunnels. Both tunnels must be
! configured on your Customer Gateway.
!
! --------------------------------------------------------------------------------
! IPSec Tunnel #1
! --------------------------------------------------------------------------------
! #1: Internet Key Exchange (IKE) Configuration
!
! A policy is established for the supported ISAKMP encryption,
! authentication, Diffie-Hellman, lifetime, and key parameters.
! 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, and you are not using an Accelerated VPN, we recommend disabling NAT-T. If you are using an Accelerated VPN, make sure that NAT-T is enabled.
!

set vpn ipsec ike-group AWS lifetime '28800'
set vpn ipsec ike-group AWS proposal 1 dh-group '2'
set vpn ipsec ike-group AWS proposal 1 encryption 'aes128'
set vpn ipsec ike-group AWS proposal 1 hash 'sha1'
set vpn ipsec site-to-site peer 13.113.234.114 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 13.113.234.114 authentication pre-shared-secret 'vBj9QDCoZb0rAT8Sbgkx_ApK3IHBsyHx'
set vpn ipsec site-to-site peer 13.113.234.114 description 'VPC tunnel 1'
set vpn ipsec site-to-site peer 13.113.234.114 ike-group 'AWS'
set vpn ipsec site-to-site peer 13.113.234.114 local-address 'X.X.X.X'
set vpn ipsec site-to-site peer 13.113.234.114 vti bind 'vti0'
set vpn ipsec site-to-site peer 13.113.234.114 vti esp-group 'AWS'


! #2: IPSec Configuration
!
! The IPSec (Phase 2) proposal defines the protocol, authentication,
! encryption, and lifetime parameters for our IPSec security association.
! 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.
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
!

set vpn ipsec ipsec-interfaces interface 'eth0'
set vpn ipsec esp-group AWS compression 'disable'
set vpn ipsec esp-group AWS lifetime '3600'
set vpn ipsec esp-group AWS mode 'tunnel'
set vpn ipsec esp-group AWS pfs 'enable'
set vpn ipsec esp-group AWS proposal 1 encryption 'aes128'
set vpn ipsec esp-group AWS proposal 1 hash 'sha1'

! This option enables IPSec Dead Peer Detection, which causes periodic
! messages to be sent to ensure a Security Association remains operational.
!
set vpn ipsec ike-group AWS dead-peer-detection action 'restart'
set vpn ipsec ike-group AWS dead-peer-detection interval '15'
set vpn ipsec ike-group AWS dead-peer-detection timeout '30'

! --------------------------------------------------------------------------------
! #3: Tunnel Interface Configuration
!
!  The tunnel interface is configured with the internal IP address.

set interfaces vti vti0 address '169.254.101.30/30'
set interfaces vti vti0 description 'VPC tunnel 1'
set interfaces vti vti0 mtu '1436'

! --------------------------------------------------------------------------------

! #4: Border Gateway Protocol (BGP) Configuration
!
! BGP is used within the tunnel to exchange prefixes between the
! Virtual Private Gateway and your Customer Gateway. The Virtual Private Gateway
! will announce the prefix corresponding to your VPC.
!
! Your Customer Gateway may announce a default route (0.0.0.0/0),
! which can be done with the 'network' statement.
!
! The BGP timers are adjusted to provide more rapid detection of outages.
!
! The local BGP Autonomous System Number (ASN) (65000) is configured
! as part of your Customer Gateway. If the ASN must be changed, the
! Customer Gateway and VPN Connection will need to be recreated with AWS.
!

set protocols bgp 65000 neighbor 169.254.101.29 remote-as '64512'
set protocols bgp 65000 neighbor 169.254.101.29 soft-reconfiguration 'inbound'
set protocols bgp 65000 neighbor 169.254.101.29 timers holdtime '30'
set protocols bgp 65000 neighbor 169.254.101.29 timers keepalive '10'

! To advertise additional prefixes to Amazon VPC, replace the 0.0.0.0/0 from the
! the following line with the prefix you wish to advertise. Make sure the prefix is present
! in the routing table of the device with a valid next-hop.

set protocols bgp 65000 network 0.0.0.0/0

! --------------------------------------------------------------------------------
! IPSec Tunnel #2
! --------------------------------------------------------------------------------
! #1: Internet Key Exchange (IKE) Configuration
!
! A policy is established for the supported ISAKMP encryption,
! authentication, Diffie-Hellman, lifetime, and key parameters.
! 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, and you are not using an Accelerated VPN, we recommend disabling NAT-T. If you are using an Accelerated VPN, make sure that NAT-T is enabled.
!

set vpn ipsec ike-group AWS lifetime '28800'
set vpn ipsec ike-group AWS proposal 1 dh-group '2'
set vpn ipsec ike-group AWS proposal 1 encryption 'aes128'
set vpn ipsec ike-group AWS proposal 1 hash 'sha1'
set vpn ipsec site-to-site peer 52.199.22.93 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 52.199.22.93 authentication pre-shared-secret 'TdBgv71bbrEl9hKNpXpas4Kj6wcXh1Jf'
set vpn ipsec site-to-site peer 52.199.22.93 description 'VPC tunnel 2'
set vpn ipsec site-to-site peer 52.199.22.93 ike-group 'AWS'
set vpn ipsec site-to-site peer 52.199.22.93 local-address 'X.X.X.X'
set vpn ipsec site-to-site peer 52.199.22.93 vti bind 'vti1'
set vpn ipsec site-to-site peer 52.199.22.93 vti esp-group 'AWS'


! #2: IPSec Configuration
!
! The IPSec (Phase 2) proposal defines the protocol, authentication,
! encryption, and lifetime parameters for our IPSec security association.
! 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.
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
!

set vpn ipsec ipsec-interfaces interface 'eth0'
set vpn ipsec esp-group AWS compression 'disable'
set vpn ipsec esp-group AWS lifetime '3600'
set vpn ipsec esp-group AWS mode 'tunnel'
set vpn ipsec esp-group AWS pfs 'enable'
set vpn ipsec esp-group AWS proposal 1 encryption 'aes128'
set vpn ipsec esp-group AWS proposal 1 hash 'sha1'

! This option enables IPSec Dead Peer Detection, which causes periodic
! messages to be sent to ensure a Security Association remains operational.
!
set vpn ipsec ike-group AWS dead-peer-detection action 'restart'
set vpn ipsec ike-group AWS dead-peer-detection interval '15'
set vpn ipsec ike-group AWS dead-peer-detection timeout '30'

! --------------------------------------------------------------------------------
! #3: Tunnel Interface Configuration
!
!  The tunnel interface is configured with the internal IP address.

set interfaces vti vti1 address '169.254.25.154/30'
set interfaces vti vti1 description 'VPC tunnel 2'
set interfaces vti vti1 mtu '1436'

! --------------------------------------------------------------------------------

! #4: Border Gateway Protocol (BGP) Configuration
!
! BGP is used within the tunnel to exchange prefixes between the
! Virtual Private Gateway and your Customer Gateway. The Virtual Private Gateway
! will announce the prefix corresponding to your VPC.
!
! Your Customer Gateway may announce a default route (0.0.0.0/0),
! which can be done with the 'network' statement.
!
! The BGP timers are adjusted to provide more rapid detection of outages.
!
! The local BGP Autonomous System Number (ASN) (65000) is configured
! as part of your Customer Gateway. If the ASN must be changed, the
! Customer Gateway and VPN Connection will need to be recreated with AWS.
!

set protocols bgp 65000 neighbor 169.254.25.153 remote-as '64512'
set protocols bgp 65000 neighbor 169.254.25.153 soft-reconfiguration 'inbound'
set protocols bgp 65000 neighbor 169.254.25.153 timers holdtime '30'
set protocols bgp 65000 neighbor 169.254.25.153 timers keepalive '10'

! To advertise additional prefixes to Amazon VPC, replace the 0.0.0.0/0 from the
! the following line with the prefix you wish to advertise. Make sure the prefix is present
! in the routing table of the device with a valid next-hop.

set protocols bgp 65000 network 0.0.0.0/0



! 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

ただし、このままでは上手くいかなかった。VyOSとVyattaはあくまで別物だからだろうか。
整理して実際に投入したコンフィグは以下。

# delete previous configuration
configure
delete interface vti vti0
delete interface vti vti1
delete interface vti vti2
delete protocols bgp
delete vpn
commit
save
exit

# configure tunnel #1
configure

set vpn ipsec ike-group AWS lifetime '28800'
set vpn ipsec ike-group AWS proposal 1 dh-group '2'
set vpn ipsec ike-group AWS proposal 1 encryption 'aes128'
set vpn ipsec ike-group AWS proposal 1 hash 'sha1'
set vpn ipsec site-to-site peer 13.113.234.114 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 13.113.234.114 authentication pre-shared-secret 'vBj9QDCoZb0rAT8Sbgkx_ApK3IHBsyHx'
set vpn ipsec site-to-site peer 13.113.234.114 description 'VPC tunnel 1'
set vpn ipsec site-to-site peer 13.113.234.114 ike-group 'AWS'
set vpn ipsec site-to-site peer 13.113.234.114 local-address '10.0.0.253'
set vpn ipsec site-to-site peer 13.113.234.114 vti bind 'vti1'
set vpn ipsec site-to-site peer 13.113.234.114 vti esp-group 'AWS'

set vpn ipsec ipsec-interfaces interface 'eth1'
set vpn ipsec esp-group AWS compression 'disable'
set vpn ipsec esp-group AWS lifetime '3600'
set vpn ipsec esp-group AWS mode 'tunnel'
set vpn ipsec esp-group AWS pfs 'enable'
set vpn ipsec esp-group AWS proposal 1 encryption 'aes128'
set vpn ipsec esp-group AWS proposal 1 hash 'sha1'

set vpn ipsec ike-group AWS dead-peer-detection action 'restart'
set vpn ipsec ike-group AWS dead-peer-detection interval '15'
set vpn ipsec ike-group AWS dead-peer-detection timeout '30'

set interfaces vti vti1 address '169.254.101.30/30'
set interfaces vti vti1 description 'VPC tunnel 1'
set interfaces vti vti1 mtu '1436'

set protocols bgp neighbor 169.254.101.29 remote-as '64512'
set protocols bgp neighbor 169.254.101.29 soft-reconfiguration 'inbound'
set protocols bgp neighbor 169.254.101.29 timers holdtime '30'
set protocols bgp neighbor 169.254.101.29 timers keepalive '10'

set protocols bgp local-as 65000

commit
save
exit

# configure tunnel #2
configure

set vpn ipsec ike-group AWS lifetime '28800'
set vpn ipsec ike-group AWS proposal 1 dh-group '2'
set vpn ipsec ike-group AWS proposal 1 encryption 'aes128'
set vpn ipsec ike-group AWS proposal 1 hash 'sha1'
set vpn ipsec site-to-site peer 52.199.22.93 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 52.199.22.93 authentication pre-shared-secret 'TdBgv71bbrEl9hKNpXpas4Kj6wcXh1Jf'
set vpn ipsec site-to-site peer 52.199.22.93 description 'VPC tunnel 2'
set vpn ipsec site-to-site peer 52.199.22.93 ike-group 'AWS'
set vpn ipsec site-to-site peer 52.199.22.93 local-address '10.0.0.253'
set vpn ipsec site-to-site peer 52.199.22.93 vti bind 'vti2'
set vpn ipsec site-to-site peer 52.199.22.93 vti esp-group 'AWS'

set vpn ipsec ipsec-interfaces interface 'eth1'
set vpn ipsec esp-group AWS compression 'disable'
set vpn ipsec esp-group AWS lifetime '3600'
set vpn ipsec esp-group AWS mode 'tunnel'
set vpn ipsec esp-group AWS pfs 'enable'
set vpn ipsec esp-group AWS proposal 1 encryption 'aes128'
set vpn ipsec esp-group AWS proposal 1 hash 'sha1'

set vpn ipsec ike-group AWS dead-peer-detection action 'restart'
set vpn ipsec ike-group AWS dead-peer-detection interval '15'
set vpn ipsec ike-group AWS dead-peer-detection timeout '30'

set interfaces vti vti2 address '169.254.25.154/30'
set interfaces vti vti2 description 'VPC tunnel 2'
set interfaces vti vti2 mtu '1436'

set protocols bgp neighbor 169.254.25.153 remote-as '64512'
set protocols bgp neighbor 169.254.25.153 soft-reconfiguration 'inbound'
set protocols bgp neighbor 169.254.25.153 timers holdtime '30'
set protocols bgp neighbor 169.254.25.153 timers keepalive '10'

set protocols bgp local-as 65000

commit
save
exit

# route advertisement
configure
set protocols bgp address-family ipv4-unicast network 172.16.0.0/24
commit
save
exit

# confirm
show interfaces
show vpn ike sa
show vpn ipsec sa
show bgp summary
show ip route
show ip bgp

4.VPN接続の確認[オンプレ]

vyos@vyos:~$ show interfaces
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             172.16.0.253/24                   u/u  
eth1             10.0.0.253/24                     u/u  
lo               127.0.0.1/8                       u/u  
                 ::1/128                                
vti1             169.254.101.30/30                 u/u  VPC tunnel 1
vti2             169.254.25.154/30                 u/u  VPC tunnel 2
vyos@vyos:~$ show vpn ike sa
Peer ID / IP                            Local ID / IP               
------------                            -------------
52.199.22.93 52.199.22.93               10.0.0.253 10.0.0.253                  

    State  IKEVer  Encrypt      Hash          D-H Group      NAT-T  A-Time  L-Time
    -----  ------  -------      ----          ---------      -----  ------  ------
    up     IKEv2   AES_CBC_128  HMAC_SHA1_96  MODP_1024      yes    11      0      

Peer ID / IP                            Local ID / IP               
------------                            -------------
13.113.234.114 13.113.234.114           10.0.0.253 10.0.0.253                  

    State  IKEVer  Encrypt      Hash          D-H Group      NAT-T  A-Time  L-Time
    -----  ------  -------      ----          ---------      -----  ------  ------
    up     IKEv2   AES_CBC_128  HMAC_SHA1_96  MODP_1024      yes    28      0      

vyos@vyos:~$ show vpn ipsec sa
Connection             State    Uptime    Bytes In/Out    Packets In/Out    Remote address    Remote ID    Proposal
---------------------  -------  --------  --------------  ----------------  ----------------  -----------  ---------- --------------
peer_52-199-22-93_vti  up       11s       663B/801B       9/11              52.199.22.93      N/A          AES_CBC_12 8/HMAC_SHA1_96
vyos@vyos:~$ show bgp summary

IPv4 Unicast Summary:
BGP router identifier 172.16.0.253, local AS number 65000 vrf-id 0
BGP table version 2
RIB entries 3, using 576 bytes of memory
Peers 2, using 43 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
169.254.25.153  4      64512         6         5        0    0    0 00:00:11            1        2
169.254.101.29  4      64512         7         6        0    0    0 00:00:29            1        2

Total number of neighbors 2
vyos@vyos:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

S>* 0.0.0.0/0 [1/0] via 10.0.0.254, eth1, weight 1, 00:16:15
C>* 10.0.0.0/24 is directly connected, eth1, 00:16:25
C>* 169.254.25.152/30 is directly connected, vti2, 00:00:11
C>* 169.254.101.28/30 is directly connected, vti1, 00:00:29
C>* 172.16.0.0/24 is directly connected, eth0, 00:16:25
B>* 172.18.0.0/16 [20/100] via 169.254.101.29, vti1, weight 1, 00:00:28
vyos@vyos:~$ show ip bgp
BGP table version is 2, local router ID is 172.16.0.253, vrf id 0
Default local pref 100, local AS 65000
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0/24    0.0.0.0                  0         32768 i
*  172.18.0.0/16    169.254.25.153         200             0 64512 i
*>                  169.254.101.29         100             0 64512 i

Displayed  2 routes and 3 total paths

5.VPN接続の確認[AWS]

以下を確認する。スクリーンショットは気が向いたら貼る。

  • VPNのトンネル1,2の状態がアップであること。
  • ルートテーブルにオンプレのルートが自動登録されていること(172.16.0.0/24)。BGPによる伝搬。

6.疎通確認用のサーバの構築[オンプレ]

以下の要件を満たすサーバを用意する。手段は問わない。当環境ではQEMU+KVMの仮想ゲストとしてCentOSを構築した。

7.疎通確認[オンプレ→AWS]

ping疎通を確認。EC2インスタンスのIPは172.18.1.198。これはパブリックIPでもElasticIPでもなく、インターネットゲートウェイに繋がっていないプライベートサブネットのIP。ここ重要。

[root@server ~]# ping 172.18.1.198
PING 172.18.1.198 (172.18.1.198) 56(84) bytes of data.
64 bytes from 172.18.1.198: icmp_seq=1 ttl=253 time=11.10 ms
64 bytes from 172.18.1.198: icmp_seq=2 ttl=253 time=10.2 ms

--- 172.18.1.198 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 10.242/11.116/11.990/0.874 ms

ssh疎通を確認。公開鍵は事前にサーバ上に配置済み。

[root@server ~]# ssh -i /tmp/keypair01.pem -l ec2-user 172.18.1.198
The authenticity of host '172.18.1.198 (172.18.1.198)' can't be established.
ECDSA key fingerprint is SHA256:VqK/desWkzYLa8xHrqkmM3LyyeBvqckLVGWR3oClAxg.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '172.18.1.198' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/

[ec2-user@ip-172-18-1-198 ~]$ 

接続元がオンプレのサーバ(172.16.0.1)であることが確認できる。

[ec2-user@ip-172-18-1-198 ~]$ w
 12:18:51 up 21 min,  1 user,  load average: 0.00, 0.02, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
ec2-user pts/0    ip-172-16-0-1.am 12:18    2.00s  0.02s  0.00s w
[ec2-user@ip-172-18-1-198 ~]$ tps -ef || entstnetstat -an | grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0     36 172.18.1.198:22         172.16.0.1:39320        ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN     

8.疎通確認[AWS→オンプレ]

疎通確認元であるAWSのEC2にログインする手段は、オンプレからのVPN経由しか存在しない。この時点で疎通できていることが明白だが、もしかしたら逆方向のトラフィックは通らないかもしれないので確認する。
ping疎通を確認。

[ec2-user@ip-172-18-1-198 ~]$ ping 172.16.0.1
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=63 time=9.74 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=63 time=10.4 ms

--- 172.16.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 9.748/10.087/10.427/0.354 ms

ssh疎通を確認。

[ec2-user@ip-172-18-1-198 ~]$ ssh root@172.16.0.1
The authenticity of host '172.16.0.1 (172.16.0.1)' can't be established.
ECDSA key fingerprint is SHA256:GaMu1CbR/A6wKpX/Ce0ceD2T8RESL9A+tWE39qTmSSM.
ECDSA key fingerprint is MD5:17:e2:8a:eb:44:46:1a:18:d2:49:b4:8c:ad:27:8f:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.0.1' (ECDSA) to the list of known hosts.
root@172.16.0.1's password: 
Last login: Tue Jul  6 21:18:10 2021
[root@server ~]# 

接続元がEC2(172.18.1.198)であることが確認できる。

[root@server ~]# w
 21:21:46 up 4 min,  2 users,  load average: 0.04, 0.17, 0.09
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     ttyS0    -                21:18    1.00s  1.20s  0.05s ssh -i /tmp/keypair01.pem -l ec2-user 172.18.1.198
root     pts/0    172.18.1.198     21:21    1.00s  0.05s  0.01s w
[root@server ~]# ps -ef | grep netstat -an | grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0     36 172.16.0.1:22          172.18.1.198:50280      ESTABLISHED
tcp        0     36 172.16.0.1:39326       172.18.1.198:22         ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN