Back to Blog
Building a Secure VCN in OCI: A Complete Guide for Small Businesses

Building a Secure VCN in OCI: A Complete Guide for Small Businesses

   Mariusz Antonik    Oracle Cloud (OCI)    3 min read    417 views

1. Introduction

In this guide, I’ll take you through a deep technical walkthrough of building a Virtual Cloud Network (VCN) in Oracle Cloud Infrastructure. If you’re a small business owner, developer, or network engineer, this is the foundation of everything you will ever deploy in OCI.

A poorly designed VCN creates ongoing problems—slow services, blocked traffic, security exposures, and troubleshooting nightmares. A well-designed VCN gives you speed, visibility, and a rock-solid security posture.


2. What Problem This Solves

Most new OCI tenants suffer from:

  • VCN scattered across random subnets

  • Missing route table entries

  • Wide-open 0.0.0.0/0 firewall rules

  • Unnecessary exposure of compute instances

  • No compartment or regional structure

This post solves exactly that—a clean, secure, production-ready VCN setup.


3. Step-by-Step Guide

Step 1 — Create the VCN

OCI Console → Networking → Virtual Cloud Networks → Create VCN

Recommended CIDR:

 
10.0.0.0/16

CLI

 
oci network vcn create \ --cidr-block 10.0.0.0/16 \ --compartment-id <compartment_ocid> \ --display-name prod-vcn

Step 2 — Create Subnets

Recommended structure:

Subnet CIDR Type Purpose
public-lb 10.0.10.0/24 Public Load balancers
app-private 10.0.20.0/24 Private App servers
db-private 10.0.30.0/24 Private Databases

CLI

 
oci network subnet create \ --vcn-id <vcn_ocid> \ --cidr-block 10.0.20.0/24 \ --display-name app-private \ --prohibit-public-ip-on-vnic true \ --compartment-id <compartment_ocid>

Step 3 — Create Gateways

Internet Gateway

 
oci network internet-gateway create \ --vcn-id <vcn_ocid> \ --is-enabled true \ --display-name igw-prod

NAT Gateway

 
oci network nat-gateway create \ --vcn-id <vcn_ocid> \ --display-name nat-prod

Service Gateway (important for DB + Object Storage)

 
oci network service-gateway create \ --vcn-id <vcn_ocid> \ --services '[{"serviceId":"all-gru-services"}]' \ --display-name sgw-prod

Step 4 — Configure Route Tables

App subnet route:

 
0.0.0.0/0 → NAT Gateway objectstorage → Service Gateway

Step 5 — Secure Network with Security Lists

Example security list:

 
# Allow SSH only from your home/work IP oci network security-list update \ --security-list-id <sl_id> \ --egress-security-rules '[{"protocol":"all","destination":"0.0.0.0/0"}]' \ --ingress-security-rules '[ {"protocol":"6","source":"203.0.113.0/24","tcpOptions":{"destinationPortRange":{"min":22,"max":22}}}, {"protocol":"6","source":"10.0.0.0/16","tcpOptions":{"destinationPortRange":{"min":80,"max":80}}} ]'

4. Architecture Diagram

 
┌──────────────────────────────┐ │ Oracle Region │ └──────────────┬───────────────┘ VCN (10.0.0.0/16) ┌──────────────────────────────────────────────────────────────┐ │ Public Subnet (10.0.10.0/24) │ │ ┌───────────────┐ │ │ │ LB (Public) │───Internet Gateway │ │ └───────────────┘ │ ├──────────────────────────────────────────────────────────────┤ │ App Private Subnet (10.0.20.0/24) │ │ ┌───────────────┐ │ │ │ Compute Nodes │───NAT Gateway │ │ └───────────────┘ │ ├──────────────────────────────────────────────────────────────┤ │ DB Private Subnet (10.0.30.0/24) │ │ ┌───────────────┐ │ │ │ MySQL/ATP │───Service Gateway → Object Storage │ │ └───────────────┘ │ └──────────────────────────────────────────────────────────────┘

5. Best Practices

  • Never assign public IPs to compute unless absolutely required

  • Prefer NAT Gateway for outbound traffic

  • Use network security groups instead of security lists for large deployments

  • Create dedicated compartments per environment: prod, qa, dev

  • Always use private subnets for databases

  • Enable VCN Flow Logs for troubleshooting


6. Common Errors / Troubleshooting

Error Cause Fix
Cannot SSH to compute Public subnet missing Move instance or add public IP
Database cannot reach Object Storage No Service Gateway route Add route entry
App cannot reach DB Security list blocking port Add TCP port 3306/1521 rule
Server has no internet Missing NAT route Update route table

7. Summary

You now have a complete, secure, and scalable VCN design ready for production or Always Free Tier environments. This is the backbone of every OCI deployment—compute, databases, load balancers, OKE, and more.


Since this is a networking-related post, CTA = Lead Magnet

👉 Download my free guide:
7 OCI Networking Mistakes to Avoid

https://dmcloudarchitect.com/c/7_oci_mistakes_to_avoid.html

Tags: #OCI
About the Author
Mariusz Antonik

Oracle Cloud Infrastructure expert and consultant specializing in database management and automation.

All Tags
#Advanced #Bash #bash monitoring #bash scripting #Beginner #Best Practices #Capacity Planning #cpu bottleneck #CPU Monitoring #cpu monitoring linux #cpu trends #cpu usage trends linux #cron jobs #database monitoring #database performance #detect slow queries mysql #disk capacity planning server #disk forecasting linux #Disk Monitoring #disk usage #disk usage script linux #disk usage trends #Early Detection #easy infrastructure monitoring #free-tier #Guide #Health Reporting #historical server monitoring #infrastructure #infrastructure health #infrastructure health dashboard #infrastructure health reporting #infrastructure monitoring #infrastructure monitoring report #infrastructure trends monitoring #lightweight monitoring #linux cpu usage #linux disk capacity planning #linux disk usage #Linux monitoring #linux monitoring tools #linux performance #linux performance monitoring #linux server #linux server monitoring #linux servers #linux tools #low maintenance monitoring #monitor cpu usage over time linux #monitor server trends #MySQL #mysql health reporting #MySQL monitoring #mysql optimization #MySQL Performance #mysql performance monitoring #mysql query performance issues #mysql server monitoring #mysql slow query analysis #mysql slow query monitoring #mysql trends #networking #OCI #oracle-cloud #Performance Degradation #performance monitoring #performance trend monitoring #plan disk growth server #practical server monitoring #predict disk usage growth #query optimization #Security #server health #server health reporting #server health weekly report #server monitoring #server trend analysis #server-trends #simple monitoring system #simple ops monitoring #slow queries #slow query reporting mysql #small business infrastructure #small business IT #small infrastructure monitoring #small server monitoring #storage capacity planning linux #storage monitoring #subnets #system health reporting #Trend Monitoring #Tutorial #vcn