Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Public IP from OCI Instance using OCI CLI

How do I get public IP from an OCI instance with OCI CLI?

There is a command from the docs - oci network public-ip get but this expects parameters like --private-ip-id and -public-ip-id which also cannot be fetched using OCI CLI.

like image 946
Jainam MJ Avatar asked Oct 20 '25 00:10

Jainam MJ


1 Answers

You can use list-vnics

oci compute instance list-vnics --instance-id <instance-ocid>

to list the interfaces for the instance. The interface details is a list and each entry contains the field "public-ip". You can use the following CLI command with jq to get the public IP address:

oci compute instance list-vnics --instance-id <instance-id> | jq -r '.data[]."public-ip"'
like image 129
Vishwas Bhat Avatar answered Oct 23 '25 00:10

Vishwas Bhat