Examine VCN/Subnets characteristics

Summary

The easiest way to examine VCN/Subnets characteristics is to use the Networking menus of the OCI console. There are at least four (4) ways of getting this information:

  1. Use OCI Console
  2. Use Ansible
  3. Use OCI CLI
  4. Use Terraform

References

Notes

VCN Characteristics

A Virtual Cloud Network (VCN):

Subnets

A subnet is a non-overlapping CIDR within a region. Originally, a subnet was restricted to an availability domain (AD).

Subnets act as a unit of configuration: all instances in a given subnet use the same route table, security lists, and DHCP options.

Each compute instance is attached to a virtual network interface card (VNIC) which resides within a subnet.

Use OCI Console

Display VCN

From the main hamburger menu, clicking on Networking shows the following screen (I had created the VCN as part of an earlier project):

Display VCN from OCI console

The characteristics displayed here are:

Display Mastadon Network

More details for a VCN can be displayed by clinking on the VCN name from the Networking menu. A sample display is shown below:

Display Mastadon network from OCI console

Display Subnet

Display Mastadon DB Server sub-network from OCI console

Use Ansible

A sample Ansible playbook can be found at examine-vcnsubnets-characteristics.yml. To run this playbook, type the following:

ansible-playbook examine-vcnsubnets-characteristics.yml

This playbook uses the following two (2) modules:

  1. oracle.oci.oci_network_subnet_facts – Fetches details about one or multiple Subnet resources in Oracle Cloud Infrastructure
  2. oracle.oci.oci_network_vcn_facts – Fetches details about one or multiple Vcn resources in Oracle Cloud Infrastructure

Sample output has been uploaded as ansible-examine-vcnsubnets-characteristics.log.

Use OCI CLI

OCI CLI can be used to get the required characteristics by running the following commands:

oci session authenticate --no-browser --profile-name OCI --region ap-sydney-1
oci network vcn list --compartment-id "ocid1.compartment.oc1..aaaaaaaax4nkky4yov3bahtf3cg226ya2ngsaru7vxkv6pavdjwzz5udsojq" --auth security_token
oci network subnet list --compartment-id "ocid1.compartment.oc1..aaaaaaaax4nkky4yov3bahtf3cg226ya2ngsaru7vxkv6pavdjwzz5udsojq" --auth security_token

I have also created a script called examine-vcnsubnets-characteristics.sh. Sample output is:

VCN, 'Mastadon_Network', is defined in compartment, 'mastadon_compartment', with:
    OCID=ocid1.vcn.oc1.ap-sydney-1.amaaaaaa63mv4jya75cfieoatbehnc3rn4q6abdcjmwxa5pdqddhic464n4q
    CIDR Block 10.1.0.0/16
    Subnet 'Mastadon Web Server Sub-Network' has CIDR= 10.1.0.0/24
    Subnet 'Mastadon DB Server Sub-Network' has CIDR= 10.1.1.0/24
    DNS Label='mastadon'
    DNS Domain='mastadon.oraclevcn.com'
VCN, 'sandbox-vcn', is defined in compartment, 'Sandbox', with:
    OCID=ocid1.vcn.oc1.ap-sydney-1.amaaaaaa63mv4jyaxs7lsdt2jqb5szggxu2mcm2yqr2zufmi5pqh6jwzfqlq
    CIDR Block 10.0.0.0/16
    Subnet 'example_subnet' has CIDR= 10.0.3.0/24
    Subnet 'private subnet-sandbox-vcn' has CIDR= 10.0.2.0/24
    Subnet 'public subnet-sandbox-vcn' has CIDR= 10.0.1.0/24

Sample output has been uploaded as oci-examine-vcnsubnets-characteristics.log

Use Terraform

Terraform can be used to retrieve the characteristics of a VCN and a subnet by specifying their IDs. A sample Terraform script can be found in examine-vcnsubnets-characteristics. A sample run is:

cd oci-2024-certified-networking-professional/design-and-deploy-oci-virtual-cloud-networks-vcn/examine-vcnsubnets-characteristics
terraform init 
terraform plan

Sample output has been uploaded as terraform-examine-vcnsubnets-characteristics.log

Notes

Region has one or more availability domain (AD) each of which has three (3) fault domains (FD).

Public VCN uses Internet Gateway to access Internet and public endpoints. Private VCN uses NAT Gateway to access the Internet.

VCN is region-specific.