More Info:
Subnets should be configured as private (no public IP assignment). Public subnets expose resources directly to the internet, bypassing network security controls.Risk Level
MediumAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- HIPAA
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- Reserve Bank of India (RBI) Cyber Security Framework
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To make OCI network subnets private (per CIS-style “subnets should be private”) using the OCI Console, you need to:
-
Identify subnets that are effectively public
- Sign in to the OCI Console.
- In the left menu, go to Networking > Virtual Cloud Networks.
- Select the Compartment you want.
- Click your VCN.
- Go to the Subnets tab.
- For each subnet, note:
- Route table (does it have a route to an Internet Gateway?)
- Public IP assignment (auto-assign allowed?)
- Its route table has a route to an Internet Gateway (IGW), and/or
- It allows public IPs on resources and those resources have them.
-
Make the subnet stop assigning public IPs by default
For each public subnet you want to make private:- In the Subnets tab, click the subnet name.
- Click Edit.
- Under Subnet Access / IPv4 Public IP Address Assignment:
- Set “Allow public IPs” to No (or uncheck “Assign a public IPv4 address” if present).
- Click Save changes.
-
Remove internet access from the subnet’s route table
- From the subnet details page, note the Route Table name and click it, or
go via VCN > Route Tables and open the relevant table. - Check for any route rule like:
- Target Type: Internet Gateway
- Destination:
0.0.0.0/0or any public CIDR
- For each such rule:
- Click the Actions (⋯) menu > Delete.
- Confirm deletion.
- Create / use a NAT Gateway, then
- Add a route with:
- Target Type: NAT Gateway
- Destination CIDR Block:
0.0.0.0/0
- From the subnet details page, note the Route Table name and click it, or
-
Remove existing public IPs from resources in that subnet
For each compute instance in that subnet:- Go to Compute > Instances.
- Filter by Subnet or check the Primary VNIC details.
- Click the instance, then in the Resources section click Attached VNICs.
- Click the primary VNIC.
- Under Public IP, if a public IP is assigned:
- Click Edit, then Unassign or None (you may need to first create a reserved public IP if you must keep it and then move to a bastion later).
- Save changes.
-
(If needed) Move resources into a new dedicated private subnet
If you cannot change an existing subnet as desired (for example, it is heavily used for public-facing workloads), create a new private subnet and move internal workloads there:- In the VCN, go to Subnets > Create Subnet.
- Choose:
- Private subnet (no IGW route, no default public IPs).
- Attach it to a route table with NAT Gateway only (if outbound Internet is needed) or no external route at all.
- Create new instances or re-create services in this private subnet.
-
Verify the subnet is now private
For the subnet you remediated:- Route Table: No routes to an Internet Gateway.
- Subnet settings: Public IP auto-assignment disabled.
- Resources: No public IPs on VNICs in that subnet.
Using CLI
Using CLI
In OCI, a “private” subnet is one where
You can remediate this via OCI CLI by updating each public subnet so it no longer allows public IPs.Below are step‑by‑step CLI instructions.
Result: list of subnet OCIDs and names that are effectively “public”.
Check:
This prevents new VNICs in the subnet from getting public IPs.
Existing VNICs with public IPs keep them; see next step.
If you share your compartment/VCN IDs, I can tailor the exact CLI commands for your environment.
prohibitPublicIpOnVnic = true.You can remediate this via OCI CLI by updating each public subnet so it no longer allows public IPs.Below are step‑by‑step CLI instructions.
0. Prerequisites
- OCI CLI installed and configured (
oci setup config) - Your user has permissions to manage subnets and route tables in the target compartment/VCN.
1. Identify public subnets
List subnets in a compartment and filter those that allow public IPs on VNICs:2. (Optional) Confirm subnet details
For a specific subnet:"prohibit-public-ip-on-vnic": false→ public- Associated route table may have default route (0.0.0.0/0) to an Internet Gateway.
3. Make the subnet private (disallow public IPs)
Update the subnet:Existing VNICs with public IPs keep them; see next step.
4. Remove existing public IPs from VNICs (if required)
-
List VNICs in the subnet:
-
For each VNIC that still has a public IP, find and delete the public IP resource (reserved or ephemeral):
-
List public IPs:
-
Once you identify the public IP OCID:
-
List public IPs:
5. (Recommended) Remove Internet access from route table
A subnet is only fully private if it also does not route to an Internet Gateway.-
Get the subnet’s route table:
-
Inspect the route rules:
-
Remove any rule with destination
0.0.0.0/0that points to an Internet Gateway:-
Build a new route-rules JSON without those entries, e.g.:
-
Update the route table:
-
Build a new route-rules JSON without those entries, e.g.:
6. Apply to all public subnets (script example)
If you share your compartment/VCN IDs, I can tailor the exact CLI commands for your environment.
Using Python
Using Python
To make OCI subnets private using Python, you need to:
This creates
- Ensure VNICs in the subnet cannot get public IPs
- Ensure the subnet’s route table does not route to an Internet Gateway
1. Prerequisites
Install and configure the OCI Python SDK:~/.oci/config with a profile (e.g., DEFAULT).2. Logic to Make a Subnet “Private”
A subnet is “private” if:prohibit_public_ip_on_vnic = True- Its route table has no route rules where:
network_entity_idis an Internet Gateway OCID
- List target subnets (by compartment or VCN).
- For each subnet:
- Enable
prohibit_public_ip_on_vnic. - Clean its route table of Internet Gateway routes.
- Enable
3. Python Script Example
4. How to Use This for “Networking Monitoring”
- Run this script on a schedule (e.g., via cron, OCI Functions, or OCI DevOps) as a remediation job.
- Optionally modify it to:
- Only log non‑compliant subnets instead of updating them.
- Push findings to your monitoring/alerting system (e.g., emit metrics, write to Object Storage, send to OCI Logging or an external SIEM).
Using Terraform
Using Terraform
prohibit_public_ip_on_vnic in place.After updating, terraform plan should show an in-place ~ update in-place on the oci_core_subnet resource with prohibit_public_ip_on_vnic changing from false (or null) to true.
