OCI assigned IP address list

<font color="red">
========================================================

July 2024 update

You can now check the IP address assignment status from the OCI console.
You can also check the IP addresses assigned by the service. </font>

From the OCI console navigation, Networking>> Virtual Cloud Network>> VCN>> Subnet
- CIDR/prefix Utilization
- IP Address Insights

Announcing IP Address Insights on Oracle Cloud Infrastructure
https://blogs.oracle.com/cloud-infrastructure/post/announcing-ip-address-insights-to-oracle-cloud

<font color="red">
========================================================
</font>


This site is based on machine translation. The original is https://qiita.com/tktk2712/items/e59fd02c3f20c838124c (Japanese)

## overview
This is how to to obtain a list of IP address assigned on OCI.

## Private IP information
■Obtain compartment ID
Enter the compartment name in the search window of the OCI console, the compartment will be displayed and select it.
<img width="300" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2730992/445525ad-fc29-4e91-5bde-16d5326de493.png">

The compartment information will be displayed, then click Copy to get the OCID.
<img width="600" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2730992/b08e3d48-551c-5683-61f8-d9f4025ef7cb.png">

Select the icon to the right of the region at the top right of the OCI console and select Cloud Shell to open Cloud Shell.
<img width="300" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2730992/350679a8-f369-b374-5838-c61dd0cbb6d7.png">


Obtain the subnet using OCI CLI commands.
This example, only the necessary information is extracted using JQ.
``` CloudShell
user@cloudshell:~ (ap-sydney-1)$ oci network subnet list --compartment-id [your compartment OCID] | jq -r '["cidr-block", "display-name", "id"],(.data[]|[."cidr-block", ."display-name", ."id"])|@csv'
"cidr-block","display-name","id"
"10.106.2.0/24","SYD-Sub-10.106.2.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaawbf54vsw6eeo5gov7ank4ijjx2h2iihczw57uncackmmylr*****"
"10.106.1.0/24","SYD-Sub-10.106.1.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaa3hon5pi4vrr5qrgwd4brhbpanfpf4qtgu3hvjc5uu25e4y3*****"
"10.105.3.0/24","SYD-Sub-10.105.3.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaanrbqj6yyge42tpwj53wzshtd5ehs72co3zae2icr5svdwhj*****"
"10.105.64.0/24","SYD-Sub-10.105.64.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaaxs4qfv73w5xp4bju2pf3dzbg76d43btlcof2nh56lshro6i*****"
"10.105.66.0/24","SYD-Sub-10.105.66.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaa6nxhpfhuqeqj5fq7bifcqdoglhkyzwbcl755usz2oklgtdx*****"
"10.105.65.0/24","SYD-Sub-10.105.65.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaawkbt4hcrixxde3nywbriibucds2qqar4avhhtci2spctdck*****"
"10.105.2.0/24","SYD-Sub-10.105.2.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaavz4tl3jlgjgvry7evxpqdizosmzmo3qkdqse6z5m3krgcnj*****"
"10.105.1.0/24","SYD-Sub-10.105.1.0","ocid1.subnet.oc1.ap-sydney-1.aaaaaaaaq4yxne6x56qczzpkpbq3rjb6l6lq54bdjc5kjhm2xug754a*****"
user@cloudshell:~ (ap-sydney-1)$ 

```
Obtain the private IP list using the subnet OCID.
This example, only the necessary information is extracted using JQ.
``` CloudShell
user@cloudshell:~ (ap-sydney-1)$ oci network private-ip list --subnet-id [your subnet OCID] | jq -r '["display-name", "ip-address"],(.data[]|[."display-name", ."ip-address"])|@csv'
"display-name","ip-address"
"fss-mnt-1000000052653395","10.105.1.11"
"SYD-VM-06-Softether","10.105.1.96"
"SYD-VM-01-Linux","10.105.1.100"
"SYD-VM-02-Win","10.105.1.104"
"fss-1000000052653395","10.105.1.114"
"privateip20230613083120","10.105.1.152"
user@cloudshell:~ (ap-sydney-1)$ 
```
Please note that the first two and last one of the IP addresses are reserved and cannot be used.
(Example: For 10.0.0.0/24, .0, .1, .255 are reserved)

## Public IP information
You can print the list using the oci network public-ip list command.
There are two types of IPs that can be output: region linked IP address and availability domain linked IP address. You can also see which VM an IP address is associated with based on private IP OCID information.

IP associated with region

``` CloudShell
user@cloudshell:~ (ap-sydney-1)$ oci network public-ip list --compartment-id [your compartment OCID] --scope REGION --all | jq -r '["display-name", "ip-address"],(.data[]|[."display-name", ."ip-address"])|@csv'
"display-name","ip-address"
"IP for NAT gateway: ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaansk4idstu3dtjwftdeqec56fzif2zeyytygr6jvhg2udwc******","***.***.***.***"
"IP for NAT gateway: ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaal2c2nvwlalq3piv4rbdlunc4ydizz47x4fnntdnvd6g6hq******","***.***.***.***"
"Floating IP for VIP public-vip on LB ocid1.loadbalancer.oc1.ap-sydney-1.aaaaaaaanldcymb5pkpbsltraunyenwuvbknh2gqc6bxjpbab7bbr******","***.***.***.***"
"Floating Public IP for cluster ocid1.cluster.oc1.ap-sydney-1.aaaaaaaab5hqve5zaytsqg5lmcyul6w5omcngidjs2conmnaocvx******","***.***.***.***"
user@cloudshell:~ (ap-sydney-1)$ 
```
IP associated with availability domain
``` CloudShell
user@cloudshell:~ (ap-sydney-1)$ oci network public-ip list --compartment-id [your compartment OCID] --scope AVAILABILITY_DOMAIN --availability-domain TGjA:AP-SYDNEY-1-AD-1 --all | jq -r '["display-name", "ip-address"], (.data[]|[."display-name", ."ip-address", ."private-ip-id"])|@csv'
"display-name","ip-address"
"publicip20230615081510","***.***.***.***","ocid1.privateip.oc1.ap-sydney-1.abzxsljr5rar7zowxpwiqezce6oi6cj7o62ckxzai6ertdhyxgrmd******"
"publicip20230612164702","***.***.***.***","ocid1.privateip.oc1.ap-sydney-1.abzxsljrwn76g5euh5cl6tpqj26wxlitq6cocqlkflwzgfvhbm45t******"
"publicip20230613220403","***.***.***.***","ocid1.privateip.oc1.ap-sydney-1.abzxsljr7seguq3kx5ipqdrue2sw4plg5hmtqu4p5mpaufa22v2j7******"
user@cloudshell:~ (ap-sydney-1)$ 
```