背景
公式の手順が以下にあるのですが、情報が古くなっておりやり方に迷ったので書き記しておきます。

環境
RockyLinux 8.6 (CentOS8系)
手順
DBサーバーを作成する
事前にDBサーバーを作成しておいてください。
何のために「DBサーバー接続用ネットワーク」を設定するのかと言えばDBを使うためですからね。
実験用にサーバーを作成する
本番環境で変更する前にテストでサーバーを作成します。

シャットダウン
起動したらシャットダウンします。

DBサーバー接続用ネットワークに接続
プライベートネットワークの項目に移動して、DBサーバー接続用ネットワークの項目から、シャットダウンしたサーバーを接続します。

サーバーを起動
サーバーの項目に異動してサーバーを起動します。

デバイスの設定
SSHかコンソールにログインしてインターフェースを設定していきます。
まず、デバイスを有効化します。disconnected になっているので、DHCPを無効化します。エラーで怒られたりしたら nmcli device up ens4 を打ったりすると動いたりします。
nmcli connection modify ens4 ipv4.method manual
次に、IPアドレスを設定します。
connection.autoconnect yes は再起動時に自動的に設定するコンフィグです。
nmcli connection modify ens4 ipv4.address 172.29.100.67/23 connection.autoconnect yes
IPアドレスの値はサーバーのNICを変えると表示されます。
shared-xxxx がDBサーバー接続用ネットワークです。

最後にルーティングを設定します
nmcli connection modify ens4 +ipv4.routes "172.29.92.0/23 172.29.100.1"
ネットワークの範囲は以下のように設定します。私は172.29のネットワークでしたので後者を設定しました。
東京リージョン:
https://support.conoha.jp/v/dbnetwork/
(IPアドレスが172.21..の場合)172.21.74.0/23
(IPアドレスが172.29..の場合)172.29.92.0/23
実行ログ:
[root@118-27-69-203 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens3 ethernet connected ens3
ens4 ethernet disconnected -- <===!!! 追加したNIC
lo loopback unmanaged --
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# nmcli connection modify ens4 ipv4.method manual
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens3 ethernet connected ens3
ens4 ethernet connected ens4 <===!!! connected に変化
lo loopback unmanaged --
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# nmcli connection modify ens4 ipv4.address 172.29.100.67/23 connection.autoconnect yes
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# nmcli connection modify ens4 +ipv4.routes "172.29.92.0/23 172.29.100.1"
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# nmcli -f ipv4.routes connection show ens4
ipv4.routes: { ip = 172.29.92.0/23, nh = 172.29.100.1 }
[root@118-27-69-203 ~]#
動作確認
動作確認を行います。
まずゲートウェイにpingを送ります。
ping -c 3 172.29.100.1
次に自分の”private”の方のデータベースホストにpingを送ります。
ホストはDBサーバーを開いて「データベースリスト」に載っています。
ping -c 3 private.xxxxx.tyo2.database-hosting.conoha.io
実行ログ
[root@118-27-69-203 ~]# ping -c 3 172.29.100.1
PING 172.29.100.1 (172.29.100.1) 56(84) bytes of data.
64 bytes from 172.29.100.1: icmp_seq=1 ttl=255 time=1.58 ms
64 bytes from 172.29.100.1: icmp_seq=2 ttl=255 time=2.51 ms
64 bytes from 172.29.100.1: icmp_seq=3 ttl=255 time=2.22 ms
--- 172.29.100.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 1.578/2.102/2.510/0.389 ms
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]#
[root@118-27-69-203 ~]# ping -c 3 private.xxxxx.tyo2.database-hosting.conoha.io
PING private.unit01.database-hosting.tyo2.conoha.io (172.29.92.12) 56(84) bytes of data.
64 bytes from 172.29.92.12 (172.29.92.12): icmp_seq=1 ttl=63 time=2.43 ms
64 bytes from 172.29.92.12 (172.29.92.12): icmp_seq=2 ttl=63 time=0.433 ms
64 bytes from 172.29.92.12 (172.29.92.12): icmp_seq=3 ttl=63 time=0.575 ms
--- private.unit01.database-hostin
g.tyo2.conoha.io ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.433/1.147/2.433/0.911 ms
成功すれば完了です。
念のため、rebootしても反映されているか確認しておき、終わったらサーバーを削除して終了です。
参考資料



コメント