IBM Cloud: Network Attachments/Virtual Network Interface(VNI)方式とLegacy Network Interface方式の違い

# 1. はじめに

IBM CloudのVSI for VPCおよびBM for VPCのネットワークの構成において、以下のようにNetwork Attachments/Virtual Network Interface(VNI)を注文時に選択するという考え方が新たに出てきました。従来の方式は、Legacy Network Interface方式と呼ばれています。本稿では、新方式での特徴と、従来方式との違いを説明したいと思います。

- Network Attachments/VNI方式（今後推奨される方式）![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/2a7bf2ce-ba36-f044-b691-8a4a21cad253.png)
 
- Legacy Network Interface方式![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/d1346a9d-9256-3488-c931-17bb2a442ac4.png)


# 2. Legacy Network Interface方式とは

従来のLegacy Network Interface方式では、eth0/eth1/eth2...などのインターフェースを作成する際には、IPアドレスを指定したり、Security Groupを設定したり、また各種属性を指定することはできました。しかし、そうした設定はインターフェースに直接紐付いているものであり、もしそのインターフェースをサーバーから取り除く（削除する）と、再作成および再設定が必要になります。

- Legacy Network Interface概要![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/4228ed66-3067-8e8d-a1b2-1c0c2ff1013e.png)
- Legacy Network Interface作成画面。
    - 当然ながら、既存のNetwork Interfaceを選択するというオプションはなく、新規に作成するボタンしかない。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/e8e38dad-c537-6667-7cbb-e06f00e113fb.png)
    - 各種属性を指定。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/88544bfa-e7ed-7156-8d51-0da84a72a184.png)



また、全く同じパラメーターで設定しても、実際は完全に同じになるわけではありません。例えば、以下のようにeth1に10.7.0.10というIPアドレス付与して作成した場合でも、再作成の度にMACアドレスは変わっています。

```txt:MACアドレスは 02:00:0a:41:d5:b4
[root@syasuda-tok1-vpc1 ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:01:02:70:58 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.4/24 brd 10.0.0.255 scope global dynamic eth0
       valid_lft 299sec preferred_lft 299sec
7: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:0a:41:d5:b4 brd ff:ff:ff:ff:ff:ff
    inet 10.7.0.10/24 brd 10.7.0.255 scope global dynamic eth1
       valid_lft 299sec preferred_lft 299sec
```
```txt:eth1を再作成。MACアドレスは 02:00:0c:41:d5:b4
[root@syasuda-tok1-vpc1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:01:02:70:58 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.4/24 brd 10.0.0.255 scope global dynamic eth0
       valid_lft 236sec preferred_lft 236sec
8: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:0c:41:d5:b4 brd ff:ff:ff:ff:ff:ff
    inet 10.7.0.10/24 brd 10.7.0.255 scope global dynamic eth1
       valid_lft 299sec preferred_lft 299sec
```



# 3. Network Attachments/VNI方式とは

Network Attachments/VNI方式では、Legacy Network Interface方式での問題が解決されています。eth0/eth1/eth2...などはNetwork Attachmentsと呼ばれ、Port Speedなどの限られた情報しか保持しません。代わりに、新たにVNI(Virtual Network Interface)という抽象化されたオブジェクトが用意されています。両者には、以下の関係が成り立ちます。

- Network AttachmentsとVNIは1:1で紐付く。
- VNIが紐づかないNetwork Attachmentを作成することはできない。
- VNIはNetwork Attachmentがなくなっても存在し続けることができる。

これにより、

- Network Attachments/VNI概要![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/6ebdeddf-bfb8-44f0-513f-b5b6611046e1.png)
- Network Attachments/VNI作成画面。
    - VNIを新規に作成するか、既存のVNIを選択するかを指定できる。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/7261213e-1945-c617-471a-9c5f8dcc0d90.png)
    - 新規に作成する場合は、VNI名やsubnetを選択する。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/4baff90c-b134-0ee4-a70f-316f662033d6.png)
    - 各種属性を指定。Network Attachmentを削除する時にVNIまで消えてしまわないようにするためには、Auto-releaseはDisabledにしておく。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/bdcd479a-173f-8fde-e484-fd400df5edd6.png) 
    - Primary IP/Secondary IPの指定。Floating IPはVNI作成後に指定可能。![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/4f505a17-6cdc-72d9-f40b-dd5f3dd387c8.png)


これにより、

- Network attachmentを作成する際に、新規にVNIも作成する。
- Network attachmentを作成する際に、既存のVNIを再利用する。
- Network attachmentを削除する際に、紐づいているVNIを一緒に削除しない（今後の再利用のために残しておくことができる）
- Network attachmentを削除する際に、紐づいているVNIも一緒に削除する。

といった柔軟なライフサイクル管理が可能です。加えて、VNIでは、Secondary IPを指定することができるなど、大幅な機能改善がされています（VNI上のIPアドレスは、すべて同じsubnet配下に存在する必要があるため、Secondary IPもPrimary IPも同一subnet配下になります）。今後のIBM Cloud上での新機能はVNIを元に実現されていく予定です。

- その他の制限事項は、以下を参照してください。
    - https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about
    - https://cloud.ibm.com/docs/vpc?topic=vpc-vni-known-issues

# 4. APIで比較してみる。

## 4-1. Legacy Network Interface
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/c3b5feba-3b77-f54c-7266-af56b62c94de.png)


```
$ iam_token=`ibmcloud iam oauth-tokens | awk '{printf $4}'`
$ curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $iam_token" "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_fe6b34c2-7609-47b6-8f62-b7aa0207ec8b/network_interfaces?generation=2&version=2024-03-26" | jq
{
  "network_interfaces": [
    {
      "allow_ip_spoofing": true,
      "created_at": "2020-12-14T21:13:51Z",
      "floating_ips": [
        {
          "address": "xxx.xxx.xxx.xx",
          "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::floating-ip:r022-94cb3a31-40cb-4bd0-b912-9b8ebad804bf",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/floating_ips/r022-94cb3a31-40cb-4bd0-b912-9b8ebad804bf",
          "id": "r022-94cb3a31-40cb-4bd0-b912-9b8ebad804bf",
          "name": "fip-new-syasuda-tok1"
        }
      ],
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_fe6b34c2-7609-47b6-8f62-b7aa0207ec8b/network_interfaces/02e7-73d626a7-3b58-4eaa-be52-ecb77a0fa64b",
      "id": "02e7-73d626a7-3b58-4eaa-be52-ecb77a0fa64b",
      "name": "eth0",
      "port_speed": 2000,
      "primary_ip": {
        "address": "10.0.0.4",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-27a7f718-2164-41c8-9d04-39811d5efccd",
        "id": "02e7-27a7f718-2164-41c8-9d04-39811d5efccd",
        "name": "identify-unwitting-circle-heroics",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "network_interface",
      "security_groups": [
        {
          "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "name": "sg-tok-syasuda-default"
        },
        {
          "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-5d6696b3-cefa-4ee8-9339-3a2a16aa975e",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-5d6696b3-cefa-4ee8-9339-3a2a16aa975e",
          "id": "r022-5d6696b3-cefa-4ee8-9339-3a2a16aa975e",
          "name": "sg-tok-sysauda-cis"
        }
      ],
      "status": "available",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "id": "02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "name": "sub-10-0-0-0-24",
        "resource_type": "subnet"
      },
      "type": "primary"
    },
    {
      "allow_ip_spoofing": false,
      "created_at": "2024-04-04T06:00:26Z",
      "floating_ips": [],
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_fe6b34c2-7609-47b6-8f62-b7aa0207ec8b/network_interfaces/02e7-1e363ed2-f6d6-461b-aacf-b38d409331ea",
      "id": "02e7-1e363ed2-f6d6-461b-aacf-b38d409331ea",
      "name": "eth1",
      "port_speed": 2000,
      "primary_ip": {
        "address": "10.7.0.10",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-6e131498-ed24-4bd3-9399-24636a8e71b8/reserved_ips/02e7-909f9dcd-26ba-441e-b8fc-f3ebc9f5b87d",
        "id": "02e7-909f9dcd-26ba-441e-b8fc-f3ebc9f5b87d",
        "name": "vocalize-molecule-backshift-eagle",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "network_interface",
      "security_groups": [
        {
          "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "name": "sg-tok-syasuda-default"
        }
      ],
      "status": "available",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-6e131498-ed24-4bd3-9399-24636a8e71b8",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-6e131498-ed24-4bd3-9399-24636a8e71b8",
        "id": "02e7-6e131498-ed24-4bd3-9399-24636a8e71b8",
        "name": "sub-10-7-0-0-24",
        "resource_type": "subnet"
      },
      "type": "secondary"
    }
  ]
}
```

## 4-2. Network Attachments/Virtual Network Interface


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/4d09179d-1619-3148-ab87-f70985934731.png)

```txt:network attachments
$ iam_token=`ibmcloud iam oauth-tokens | awk '{printf $4}'`
$ curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $iam_token" "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_attachments?generation=2&version=2024-03-26" | jq
{
  "network_attachments": [
    {
      "created_at": "2024-04-04T06:05:46Z",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_attachments/02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
      "id": "02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
      "lifecycle_state": "stable",
      "name": "eth0",
      "port_speed": 1500,
      "primary_ip": {
        "address": "10.0.0.11",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-51780643-1351-4d22-b4b7-8b155b34f325",
        "id": "02e7-51780643-1351-4d22-b4b7-8b155b34f325",
        "name": "mayflower-panoramic-mosaic-hardness",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "instance_network_attachment",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "id": "02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "name": "sub-10-0-0-0-24",
        "resource_type": "subnet"
      },
      "type": "primary",
      "virtual_network_interface": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::virtual-network-interface:02e7-8ef56e79-7996-4622-a96e-6768927b6696",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-8ef56e79-7996-4622-a96e-6768927b6696",
        "id": "02e7-8ef56e79-7996-4622-a96e-6768927b6696",
        "name": "vni-syasuda-test1",
        "resource_type": "virtual_network_interface"
      }
    },
    {
      "created_at": "2024-04-04T06:05:46Z",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_attachments/02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
      "id": "02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
      "lifecycle_state": "stable",
      "name": "eth1",
      "port_speed": 1500,
      "primary_ip": {
        "address": "10.4.0.20",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-49f73153-f578-4e2d-a00f-c489465207e1",
        "id": "02e7-49f73153-f578-4e2d-a00f-c489465207e1",
        "name": "rocklike-duty-sulfate-shifty",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "instance_network_attachment",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "id": "02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "name": "sub-10-4-0-0-24",
        "resource_type": "subnet"
      },
      "type": "secondary",
      "virtual_network_interface": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::virtual-network-interface:02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
        "id": "02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
        "name": "vni-syasuda-test2",
        "resource_type": "virtual_network_interface"
      }
    }
  ]
}
```

```txt:VNI(vni-syasuda-test1)
$ iam_token=`ibmcloud iam oauth-tokens | awk '{printf $4}'`
$ curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $iam_token" "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-8ef56e79-7996-4622-a96e-6768927b6696?generation=2&version=2024-03-26" | jq
{
  "allow_ip_spoofing": false,
  "auto_delete": false,
  "created_at": "2024-04-04T06:05:46Z",
  "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::virtual-network-interface:02e7-8ef56e79-7996-4622-a96e-6768927b6696",
  "enable_infrastructure_nat": true,
  "href": "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-8ef56e79-7996-4622-a96e-6768927b6696",
  "id": "02e7-8ef56e79-7996-4622-a96e-6768927b6696",
  "ips": [
    {
      "address": "10.0.0.33",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-e1abfbc2-3f8c-48a6-aae7-245f9763b90e",
      "id": "02e7-e1abfbc2-3f8c-48a6-aae7-245f9763b90e",
      "name": "herrying-tractor-olive-pushing",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.0.0.34",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-8d8b960c-9026-4c31-a8e2-07dc78569811",
      "id": "02e7-8d8b960c-9026-4c31-a8e2-07dc78569811",
      "name": "trousers-daffy-jailhouse-exes",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.0.0.11",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-51780643-1351-4d22-b4b7-8b155b34f325",
      "id": "02e7-51780643-1351-4d22-b4b7-8b155b34f325",
      "name": "mayflower-panoramic-mosaic-hardness",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.0.0.28",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-6964fe47-628f-4dd0-be70-9e34be2f6b68",
      "id": "02e7-6964fe47-628f-4dd0-be70-9e34be2f6b68",
      "name": "province-feedable-flaky-clock",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.0.0.29",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-f9187b9f-0747-40b8-a76f-f4169ff3df83",
      "id": "02e7-f9187b9f-0747-40b8-a76f-f4169ff3df83",
      "name": "manners-duked-shininess-wildly",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.0.0.30",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-b6f409f0-da6d-407f-8002-b86eff667bbf",
      "id": "02e7-b6f409f0-da6d-407f-8002-b86eff667bbf",
      "name": "litmus-banking-algorithm-radio",
      "resource_type": "subnet_reserved_ip"
    }
  ],
  "lifecycle_state": "stable",
  "mac_address": "02:00:05:02:70:58",
  "name": "vni-syasuda-test1",
  "primary_ip": {
    "address": "10.0.0.11",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-51780643-1351-4d22-b4b7-8b155b34f325",
    "id": "02e7-51780643-1351-4d22-b4b7-8b155b34f325",
    "name": "mayflower-panoramic-mosaic-hardness",
    "resource_type": "subnet_reserved_ip"
  },
  "resource_group": {
    "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/d072b8a4c0a741ef999dd97caa434fc5",
    "id": "d072b8a4c0a741ef999dd97caa434fc5",
    "name": "Default"
  },
  "resource_type": "virtual_network_interface",
  "security_groups": [
    {
      "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "name": "sg-tok-syasuda-default"
    }
  ],
  "subnet": {
    "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
    "id": "02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
    "name": "sub-10-0-0-0-24",
    "resource_type": "subnet"
  },
  "target": {
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_attachments/02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
    "id": "02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
    "name": "eth0",
    "resource_type": "instance_network_attachment"
  },
  "vpc": {
    "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::vpc:r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/vpcs/r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "id": "r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "name": "vpc-tok-syasuda1",
    "resource_type": "vpc"
  },
  "zone": {
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/regions/jp-tok/zones/jp-tok-1",
    "name": "jp-tok-1"
  }
}
```
```txt:VNI(vni-syasuda-test2)
$ iam_token=`ibmcloud iam oauth-tokens | awk '{printf $4}'`
$ curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $iam_token" "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615?generation=2&version=2024-03-26" | jq
{
  "allow_ip_spoofing": true,
  "auto_delete": true,
  "created_at": "2024-04-04T06:05:47Z",
  "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::virtual-network-interface:02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
  "enable_infrastructure_nat": true,
  "href": "https://jp-tok.iaas.cloud.ibm.com/v1/virtual_network_interfaces/02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
  "id": "02e7-c6b81042-71e4-4a84-a80e-db8aba8dc615",
  "ips": [
    {
      "address": "10.4.0.15",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-0fb03d7a-ff7f-49db-9673-ba7490d2c37e",
      "id": "02e7-0fb03d7a-ff7f-49db-9673-ba7490d2c37e",
      "name": "revision-sliver-factual-citation",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.4.0.20",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-49f73153-f578-4e2d-a00f-c489465207e1",
      "id": "02e7-49f73153-f578-4e2d-a00f-c489465207e1",
      "name": "rocklike-duty-sulfate-shifty",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.4.0.5",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-f200b9d9-7f8a-423c-a313-31a78766a830",
      "id": "02e7-f200b9d9-7f8a-423c-a313-31a78766a830",
      "name": "joyfully-unquote-grace-science",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.4.0.12",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-f00d3ca7-ac81-4191-951a-3e96e79ffa06",
      "id": "02e7-f00d3ca7-ac81-4191-951a-3e96e79ffa06",
      "name": "manager-elsewhere-bush-elastic",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.4.0.13",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-f5d8f426-fd75-477f-8048-7d6f3c06cf6c",
      "id": "02e7-f5d8f426-fd75-477f-8048-7d6f3c06cf6c",
      "name": "gradation-obedience-underling-deafness",
      "resource_type": "subnet_reserved_ip"
    },
    {
      "address": "10.4.0.14",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-846ab98d-a478-446e-a301-318cdfb29263",
      "id": "02e7-846ab98d-a478-446e-a301-318cdfb29263",
      "name": "enactment-gloss-dinghy-passion",
      "resource_type": "subnet_reserved_ip"
    }
  ],
  "lifecycle_state": "stable",
  "mac_address": "02:00:03:0D:50:6A",
  "name": "vni-syasuda-test2",
  "primary_ip": {
    "address": "10.4.0.20",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-49f73153-f578-4e2d-a00f-c489465207e1",
    "id": "02e7-49f73153-f578-4e2d-a00f-c489465207e1",
    "name": "rocklike-duty-sulfate-shifty",
    "resource_type": "subnet_reserved_ip"
  },
  "resource_group": {
    "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/d072b8a4c0a741ef999dd97caa434fc5",
    "id": "d072b8a4c0a741ef999dd97caa434fc5",
    "name": "Default"
  },
  "resource_type": "virtual_network_interface",
  "security_groups": [
    {
      "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
      "name": "sg-tok-syasuda-default"
    }
  ],
  "subnet": {
    "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
    "id": "02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
    "name": "sub-10-4-0-0-24",
    "resource_type": "subnet"
  },
  "target": {
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_attachments/02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
    "id": "02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
    "name": "eth1",
    "resource_type": "instance_network_attachment"
  },
  "vpc": {
    "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::vpc:r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/vpcs/r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "id": "r022-85621b2c-a349-4ae6-87e3-767ddeac7298",
    "name": "vpc-tok-syasuda1",
    "resource_type": "vpc"
  },
  "zone": {
    "href": "https://jp-tok.iaas.cloud.ibm.com/v1/regions/jp-tok/zones/jp-tok-1",
    "name": "jp-tok-1"
  }
}

```


```txt:Legacy Network Interface形式のAPIを利用して、Network Attachments/Virtual Network Interface(VNI)の環境を呼び出した場合。
$ curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $iam_token" "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_interfaces?generation=2&version=2024-03-26" | jq
{
  "network_interfaces": [
    {
      "allow_ip_spoofing": false,
      "created_at": "2024-04-04T06:05:46Z",
      "floating_ips": [
        {
          "address": "xxx.xxx.xxx.xxx",
          "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::floating-ip:r022-7ba0c7a3-5414-488a-8df9-ad0fbeb9bb62",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/floating_ips/r022-7ba0c7a3-5414-488a-8df9-ad0fbeb9bb62",
          "id": "r022-7ba0c7a3-5414-488a-8df9-ad0fbeb9bb62",
          "name": "unknown"
        }
      ],
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_interfaces/02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
      "id": "02e7-8a1a0c76-1fdb-4ad9-8099-3ccbb0290e42",
      "name": "eth0",
      "port_speed": 1500,
      "primary_ip": {
        "address": "10.0.0.11",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636/reserved_ips/02e7-51780643-1351-4d22-b4b7-8b155b34f325",
        "id": "02e7-51780643-1351-4d22-b4b7-8b155b34f325",
        "name": "mayflower-panoramic-mosaic-hardness",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "network_interface",
      "security_groups": [
        {
          "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "name": "sg-tok-syasuda-default"
        }
      ],
      "status": "available",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "id": "02e7-ff96ff2a-fa27-4d88-b855-98fb85112636",
        "name": "sub-10-0-0-0-24",
        "resource_type": "subnet"
      },
      "type": "primary"
    },
    {
      "allow_ip_spoofing": false,
      "created_at": "2024-04-04T06:05:46Z",
      "floating_ips": [],
      "href": "https://jp-tok.iaas.cloud.ibm.com/v1/instances/02e7_ef008e87-7e5d-4db1-82fa-45c0d535bfda/network_interfaces/02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
      "id": "02e7-04c38fc8-3007-4618-a3a5-9e0501d37728",
      "name": "eth1",
      "port_speed": 1500,
      "primary_ip": {
        "address": "10.4.0.20",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7/reserved_ips/02e7-49f73153-f578-4e2d-a00f-c489465207e1",
        "id": "02e7-49f73153-f578-4e2d-a00f-c489465207e1",
        "name": "rocklike-duty-sulfate-shifty",
        "resource_type": "subnet_reserved_ip"
      },
      "resource_type": "network_interface",
      "security_groups": [
        {
          "crn": "crn:v1:bluemix:public:is:jp-tok:a/039dbe6794084c7cb514a276dd2345da::security-group:r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "href": "https://jp-tok.iaas.cloud.ibm.com/v1/security_groups/r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "id": "r022-1a2bb9f2-7647-4332-8a1b-eb925fb6e160",
          "name": "sg-tok-syasuda-default"
        }
      ],
      "status": "available",
      "subnet": {
        "crn": "crn:v1:bluemix:public:is:jp-tok-1:a/039dbe6794084c7cb514a276dd2345da::subnet:02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "href": "https://jp-tok.iaas.cloud.ibm.com/v1/subnets/02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "id": "02e7-b50228c7-2431-4854-ad4c-b68f6c7382a7",
        "name": "sub-10-4-0-0-24",
        "resource_type": "subnet"
      },
      "type": "secondary"
    }
  ]
}
```