LoginSignup
1
1

More than 1 year has passed since last update.

IBM Cloud:(小ネタ)2つ目以降のInterfaceにFloating IPを割り当てる方法

Last updated at Posted at 2020-11-29

2021/06/05 追記
Floating IPをeth0以外に付けるのは、UIでは今はできなくなっており、API・CLI のみで可能になったようです。CLIの場合はibmcloud is in-nic-ipcを利用します。
eth0以外に割り当てるとルーティングテーブルを変更しないといけないため、(個人的には本当に余計なお世話だと思いますが)それに気づかずにeth0以外に付けた利用者が外部通信できなくなってしまうという混乱を避けるため、本当に分かっている人しか変更させないようにという配慮のようです。

はじめに

ずっとFloating IP(FIP)は

  1. 1つのVSIに2つ以上のFIPは割り当てられない
  2. 一番最初のPrimary Interface(eth0)にしか割り振れない

と思っていた。1については現時点でも正しく、確かにすでにFIPが割り当てられている状態で他のInterfaceにFIP追加の画面が出てこない。
2もそうだよなって思っていたら、GUIを見てみたら実際にはPrimary Interface(eth0)だけでなくSecondary Interface(eth1)でもFIPを選択できる構成になっていた。よって、実際に通信が可能かを試してみた。
image.png

(なお、少なくとも過去にはこういう画面は出てこなかった記憶があるし、Docsにも以下のような記載が本記事執筆時点(2020/11/29)にはある。)

https://test.cloud.ibm.com/docs/vpc?topic=vpc-faqs-for-vsis&locale=en#faq-vsi-4
During floating IP assignment in a VPC, a customer must specify the vNIC of the instance, is that correct?
Yes, and in fact, it must be the primary network interface of a server.

FIPのeth1(Secondary Interface)への割り当てと設定

やってみると、Customer Portal上では実際に確かに割り当て可能だった。
image.png

ただし、このままではFIP経由で通信はできないはずである。なぜなら、以下のようにprimary interfaceであるeth0がdefault gatewayになっているから。

ルーティング情報
[root@syasuda-dualnic ~]# ip r
default via 10.0.0.1 dev eth0
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.25
10.4.0.0/24 dev eth1 proto kernel scope link src 10.4.0.6
169.254.0.0/16 dev eth0 scope link metric 1002

よって、この設定を変更する必要がある。default gatewayをeth1のgatewayである10.4.0.1に変更するために、以下のような設定ファイルを作成する。

/etc/dhcp/dhclient.conf
interface "eth1" {
    supersede routers 10.4.0.1;
}

dhclientコマンドを利用してもいいが、OS再起動しても変わらないことを確認しておきたいので、OS再起動をして設定が反映されたことを確認する。

OS再起動後
[root@syasuda-dualnic ~]# ip r
default via 10.4.0.1 dev eth1
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.25
10.4.0.0/24 dev eth1 proto kernel scope link src 10.4.0.6
169.254.0.0/16 dev eth0 scope link metric 1002

テスト

Secondary Interfaceにアクセスできるようになった!

Shinobu-no-MacBook-Pro:~ yasuda$ ssh root@162.xx.xx.xx
The authenticity of host '162.xx.xx.xx (162.xx.xx.xx)' can't be established.
ECDSA key fingerprint is SHA256:bYEv8UMsSudXINj9sWfPo/01Odfxt7TNzdsYwP5hh+8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '162.xx.xx.xx' (ECDSA) to the list of known hosts.
Last login: Sun Nov 29 05:41:11 2020 from 10.0.0.12

おまけ

ドキュメント修正依頼中・・・・・・

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