Kid-friendly analogy
Imagine you are building your dream house. You need walls, rooms, doors, gates, security guards, and roads. Oracle Cloud Infrastructure (OCI) is exactly like that — but in the cloud!
Kid-friendly analogy
Every VCN-connected app you build on OCI lives inside a private "neighbourhood" called a VCN. The networking pieces we will learn , are the walls, doors, gates, and traffic signs of that neighbourhood.
Source: Oracle documentation.
01. The Big Picture — What Is OCI Networking?
Understanding OCI Like a City
Kid-friendly analogy
Before we dive into individual pieces, let's understand the whole picture first. Think of Oracle Cloud like a giant modern city. Oracle built this city and rents plots of land inside it to companies like yours.
Kid-friendly analogy
When you sign up for OCI and create a VCN (Virtual Cloud Network), you are getting your own private plot of land inside that city. You decide: how to divide your land into rooms (subnets), which gates to install (gateways), what security rules to apply (Security Lists and NSGs), and which roads lead where (Route Tables).
Kid-friendly analogy
Think of it like: Oracle gives you an empty neighbourhood. Everything inside that neighbourhood — the rooms, the locks, the roads — is yours to design and control!
┌──────────────────────────────────────────────────────────────────────┐
│ OCI REGION (e.g., Mumbai) │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ VCN (Your Private Neighbourhood) │ │
│ │ │ │
│ │ ┌─────────────────────┐ ┌───────────────────────┐ │ │
│ │ │ Public Subnet │ │ Private Subnet │ │ │
│ │ │ (The Front Yard) │ │ (The Bedroom) │ │ │
│ │ │ │ │ │ │ │
│ │ │ Web Server │ │ Database │ │ │
│ │ └─────────────────────┘ └───────────────────────┘ │ │
│ │ │ │
│ │ Route Table | Security List | NSG │ │
│ └──────────────────────────────────────────────────────────────┘ │
│ │
│ Internet GW NAT GW Service GW LPG DRG │
└──────────────────────────────────────────────────────────────────────┘
Each section below explains one piece of this diagram in depth. By the end, every single box and arrow above will make complete sense! Let's go.
02. Subnets — Rooms Inside Your House
What Is a Subnet?
Kid-friendly analogy
You have your plot of land — the VCN. Now think of it as a big house. Inside that house, you build separate rooms. One room is the Guest Room (for visitors from the internet). Another is the Bedroom (for your private database). Another is the Kitchen (for backend services).
Kid-friendly analogy
In OCI, each room is called a Subnet. A subnet is simply a smaller chunk of IP addresses carved out of the VCN's address space. Every virtual machine (VM), VCN-connected database, or load balancer in this example must live inside a subnet — just like every person in a house must be in a room.
Source: Oracle documentation.
Kid-friendly analogy
What is an IP address? It's like a house number. Every network interface gets an IP address within its network so messages know exactly where to be delivered. Example: 10.0.1.5 is only being compared to "building 10, floor 0, room 1, desk 5"; its four octets do not encode that physical hierarchy. This is how computers find each other!
Source: Oracle documentation.
The Two Types of Subnets — This Is Critical!
There are two kinds of subnets, and choosing the right one is the most important security decision you make when designing your network:
-
Public Subnet
Kid-friendly analogy
Think of this as your front yard. It faces the public street. Visitors walking by (internet users) can see it and knock on the gate. Resources inside a Public Subnet can be given a public IP address — which permits direct internet access only when routing, security rules, and the service configuration allow it.
→ Use for: Web Servers, Load Balancers, Bastion Hosts (jump servers for admin access) -
Private Subnet
Kid-friendly analogy
Think of this as your bedroom. It has no windows facing the street. No one from outside can directly knock on the bedroom door — they'd have to go through the guest room first. Resources inside a Private Subnet have no public IP address, so the internet literally cannot reach them directly.
→ Use for: Databases, Application Servers, Cache layers, Internal APIs
Source: Oracle documentation.
10.0.0.0/16) gets sliced into two smaller subnets. Focus on one thing only: the Web Server has a public IP (internet can reach it) and the Database only has a private IP (internet is blocked out). That contrast is the whole lesson.
Your VCN: 10.0.0.0/16 (the whole house — 65,536 total addresses)
│
├── Public Subnet: 10.0.1.0/24 ← The Front Yard
│ Resources here CAN have public IPs
│ └── Web Server IP: 10.0.1.10 (also gets public IP like 152.67.88.50)
│ Anyone on internet → can reach 152.67.88.50 if routing and security allow
│
└── Private Subnet: 10.0.2.0/24 ← The Bedroom
Resources here have NO public IPs
└── Database IP: 10.0.2.20 (only private IP — no public IP!)
Internet → CANNOT reach 10.0.2.20 (good! it's protected!)
Source: Oracle documentation.
Kid-friendly analogy
Notice how the VCN uses the address space 10.0.0.0/16 and the subnets are smaller slices of it.
The /16 gives you 65,536 addresses. The /24 gives each subnet 256 total addresses; OCI reserves three IPv4 addresses per subnet.
Think of it like: the VCN owns the whole street (10.0.x.x), and each subnet owns one building on that street (10.0.1.x, 10.0.2.x, etc.).
Source: Oracle documentation.
How to Create a Subnet in OCI Console
- Step 1: Log in to OCI Console → navigate to Networking in the top menu → click Virtual Cloud Networks
- Step 2: Click on your VCN name to open it
- Step 3: In the left panel, click Subnets → then click Create Subnet
-
Step 4: Fill in the form:
- Name: Give it a meaningful name like
public-web-subnetorprivate-db-subnet - CIDR Block: Enter a range like
10.0.1.0/24— must be inside the VCN's CIDR and not overlap other subnets - Subnet Access: Choose Public Subnet or Private Subnet
- Route Table: Attach the correct Route Table (we will learn what this is in Section 05!)
- Security List: Attach the correct Security List (we learn this next!)
- Name: Give it a meaningful name like
- Step 5: Click Create Subnet— done!
Source: Oracle documentation.
03. Security Lists — The Lock on the Room Door
What Is a Security List?
Kid-friendly analogy
Great — you have rooms (subnets) now! But who is allowed to walk in? And who is allowed to walk out? A Security List answers both questions.
Kid-friendly analogy
A Security List is a set of firewall rules that is applied to an entire subnet. Think of it like a notice board on the door of your room that lists the rules: "Only guests wearing a blue badge (port 443) may enter. No deliveries are permitted (no allow rule for port 25). Everyone inside may freely exit."
Source: Oracle documentation.
Kid-friendly analogy
Every single resource inside that subnet automatically follows those rules. You cannot give different rules to individual VMs using a Security List — the rules apply equally to everyone in the room. (For that, you need NSGs — coming up in Section 04!)
Source: Oracle documentation.
Ingress vs Egress — Understanding Traffic Direction
Security List rules come in two flavours, based on the direction of the traffic:
-
Ingress Rules — Controls traffic coming INTO your subnet.
Kid-friendly analogy
Analogy: "Who is allowed to knock on my door and come inside?"
Example: "Allow port 443 from 0.0.0.0/0" means "Let anyone from the internet connect on HTTPS port 443" → your website is reachable -
Egress Rules — Controls traffic going OUT OF your subnet.
Kid-friendly analogy
Analogy: "Where am I allowed to go when I leave my room?"
Example: "Allow all protocols to 0.0.0.0/0" means "Let my resources send traffic to anyone" → your server can send responses back to users
Very important: OCI Security Lists use a deny by default policy. New traffic without an applicable allow rule is BLOCKED; tracked stateful replies are allowed. You only write rules for what you WANT to let through! Source: Oracle documentation.
Source: Oracle documentation.
Incoming traffic knocks at the subnet door...
Internet → Port 443 (HTTPS) → [Ingress Rule: ALLOW port 443] → Web Server gets it!
Internet → Port 22 (SSH) → [No matching ALLOW rule ] → BLOCKED at the gate!
Internet → Port 3306 (MySQL) → [No matching rule at all ] → BLOCKED automatically!
Outgoing traffic tries to leave the subnet...
Web Server → Internet → [Stateful return traffic ] → Response reaches user!
Source: Oracle documentation.
A Real-World Security List for a Web Server
Imagine you run an e-commerce website. Customers browse using HTTPS (port 443) and HTTP (port 80). Your admin team connects to the server using SSH (port 22) to fix bugs. The server must send back responses to all of them. The four rules below make all of this work safely — while blocking everything else!
-
Rule 1 — Ingress, TCP, Port 443, Source: 0.0.0.0/0
Translation: "Allow HTTPS traffic from ANYONE on the internet."
Why: Your website customers use HTTPS.0.0.0.0/0means "from the entire internet". -
Rule 2 — Ingress, TCP, Port 80, Source: 0.0.0.0/0
Translation: "Allow HTTP traffic from anyone."
Why: Some old browsers still use HTTP. Usually you'd redirect to HTTPS, but the port still needs to be open to receive the redirect request. -
Rule 3 — Ingress, TCP, Port 22, Source: 203.0.113.50/32
Translation: "Allow SSH login ONLY from the specific IP address of our office."
Why:/32means "exactly this one IP address". Only your admin's computer can SSH in — hackers get blocked! -
Rule 4 — Egress, All Protocols, All Ports, Destination: 0.0.0.0/0
Translation: "Allow all outbound traffic."
Why: This permits new outbound connections. Replies to stateful ingress are already allowed.
Source: Oracle documentation.
Notice Rule 3 carefully: instead of 0.0.0.0/0 (the whole internet) we restrict SSH to one specific IP.
The /32 at the end means "exactly this single IP address — not a range".
This tiny change makes your server dramatically safer.
The Big Limitation of Security Lists
Security Lists work well for simple setups. But they have one significant weakness: every resource in the subnet shares the exact same rules.
Imagine you have a subnet with 5 web server VMs (needing port 443 open) and 5 API server VMs (needing port 8080 open). With a Security List, you must open BOTH ports for the entire subnet — meaning your web servers also have port 8080 open (even though they don't need it), and your API servers also have port 443 open (even though they don't use it). That's unnecessary exposure at the network-rule layer; an allowed port still needs a listening service and host-firewall permission. Source: Oracle documentation.
This is exactly why OCI introduced Network Security Groups (NSGs). Let's learn about them now!
04. Network Security Groups (NSGs) — Smart Badges for Each Resource
What Is an NSG?
Kid-friendly analogy
Picture a big hotel. Every floor has a master key that unlocks all rooms on that floor — that's like a Security List. But VIP guests get a personal smart badge that unlocks specific doors based on who they are. That personal badge is an NSG (Network Security Group)!
An NSG is a set of firewall rules that you attach to individual resources: a specific VM, a specific database, a specific load balancer. Unlike a Security List (which applies to every resource in a subnet), an NSG only applies to the resources you explicitly attach it to.
Even better: NSG rules can say "allow traffic from another NSG" instead of from an IP address. This means you can write rules like "the App Server can talk to the Database" without knowing or hardcoding any IP addresses. This is incredibly powerful for dynamic cloud environments where IPs change!
Security List vs NSG — The Clear Difference
Kid-friendly analogy
Security List → Attached to a whole subnet. Every resource in that subnet shares the same rules. Like a sign on the room door that applies to all occupants. Rules use IP addresses or CIDR ranges as source/destination.
- NSG → Attached to individual resources (a specific VM, DB, or Load Balancer). Each resource gets its own unique rules. One resource can be in multiple NSGs at once. Rules can reference other NSGs as source/destination — not just IP addresses!
Source: Oracle documentation.
WITHOUT NSG (Security List only — all resources share same rules):
┌──────────────── Private Subnet ─────────────────────────────────────┐
│ App Server (needs port 8080) │ Database (needs port 3306 ONLY) │
│ │
│ Security List opens BOTH 8080 AND 5432 for the WHOLE subnet. │
│ The database now has port 8080 open even though it should never │
│ receive app traffic directly. Bad design! │
└─────────────────────────────────────────────────────────────────────┘
WITH NSG (each resource gets its own tailored rules):
App Server → NSG-AppTier → Rules: Allow port 8080 FROM NSG-LoadBalancer only
Database → NSG-DbTier → Rules: Allow port 5432 FROM NSG-AppTier only
The database ONLY accepts connections from the App Server NSG if no other applicable rule allows them.
Even if a hacker gets inside the subnet, they still cannot reach the database
unless their resource is also in NSG-AppTier!
Source: Oracle documentation 1; Oracle documentation 2.
A Complete NSG Design for a 3-Tier Application
Let's design NSGs for a real app: Load Balancer → App Servers → Database. Here's how each layer is protected:
-
NSG-LoadBalancer rules:
- Ingress: Allow port 443 from
0.0.0.0/0— internet users can reach the load balancer via HTTPS - Egress: Allow port 8080 to NSG-AppTier — load balancer can forward requests to app servers
- Ingress: Allow port 443 from
-
NSG-AppTier rules:
- Ingress: Allow port 8080 from NSG-LoadBalancer — ONLY the load balancer can send requests to app servers
- Egress: Allow port 3306 to NSG-DbTier — app servers can query the database
- Egress: Allow all to
0.0.0.0/0— app servers can call external APIs or download updates
-
NSG-DbTier rules:
- Ingress: Allow port 3306 from NSG-AppTier — ONLY app servers can query the database. Period.
- Egress: Allow all outbound — database can initiate outbound connections; stateful replies need no separate egress rule
Source: Oracle documentation 1; Oracle documentation 2.
Kid-friendly analogy
The result: even if a hacker somehow gets onto a machine in your VCN, they still cannot reach the database unless that machine has the "NSG-AppTier badge". This assumes no broader Security List or NSG rule allows access; a compromised app server in the allowed NSG can still reach the database. This is defence in depth — multiple layers of security!
Source: Oracle documentation.
How to Create an NSG
- Step 1: OCI Console → Networking → Virtual Cloud Networks → Your VCN
- Step 2: In the left panel, click Network Security Groups
- Step 3: Click Create Network Security Group
- Step 4: Give it a descriptive name like
nsg-app-serversand click Next - Step 5: Add rules — choose Direction (Ingress/Egress), Protocol (TCP/UDP/ICMP), Port range, Source or Destination
- Step 6: Click Create
- Step 7: When creating a VM or Database, in the Networking section, select this NSG to attach it to that specific resource
05. Route Tables — Road Signs for Your Network Traffic
What Is a Route Table?
Kid-friendly analogy
You've built your rooms (subnets) and put locks on the doors (Security Lists, NSGs). Now, when a packet of data leaves a VM in your subnet, how does it know which road to take? Should it go to the internet? To another subnet? To your on-premises office? To Oracle Object Storage?
Kid-friendly analogy
A Route Table is like a set of road signs posted at every junction in your neighbourhood. Each sign says: "If you are trying to reach destination X — take road Y (gateway)."
Without any route rules, traffic can only move within the VCN itself. To go anywhere else (internet, Oracle services, another VCN, your office), you need Route Table rules. Every subnet is associated with one Route Table; a VNIC or IP address can use an overriding per-resource route table. The Local rows below show implicit routing, not rules to create. Source: Oracle documentation.
How Route Rules Work — A Simple Breakdown
Each route rule has exactly two parts:
- Destination CIDR or service CIDR label — "I am looking for this address range." (Example:
0.0.0.0/0means "any internet address") - Target (Gateway) — "Go through this gateway to get there." (Example: Internet Gateway, NAT Gateway, DRG, etc.)
Source: Oracle documentation.
Kid-friendly analogy
Sticky Note for Beginners: These are two separate "signposts" — one for the public subnet, one for the private subnet. Read each row as "destination → gateway to use". Notice the public subnet points internet traffic to the Internet Gateway, while the private subnet points the same internet destination to the NAT Gateway instead. That single difference is what keeps your private resources hidden.
Route Table — Public Subnet (for your web servers):
┌──────────────────────────────────┬──────────────────────────────────┐
│ Destination │ Target (Which gateway to use?) │
├──────────────────────────────────┼──────────────────────────────────┤
│ 0.0.0.0/0 (all internet) │ Internet Gateway │
│ 10.0.2.0/24 (private subnet) │ Local (no gateway — it's local) │
└──────────────────────────────────┴──────────────────────────────────┘
Route Table — Private Subnet (for your databases and app servers):
┌──────────────────────────────────┬──────────────────────────────────┐
│ Destination │ Target (Which gateway to use?) │
├──────────────────────────────────┼──────────────────────────────────┤
│ 0.0.0.0/0 (all internet) │ NAT Gateway │
│ All Oracle Services │ Service Gateway │
│ 192.168.0.0/16 (on-premises) │ Dynamic Routing Gateway (DRG) │
│ 10.0.1.0/24 (public subnet) │ Local (no gateway — it's local) │
└──────────────────────────────────┴──────────────────────────────────┘
Kid-friendly analogy
Notice the key difference: the Public Subnet routes internet traffic through the Internet Gateway (two-way door), while the Private Subnet routes internet traffic through the NAT Gateway (outbound-only door). This protects your private resources while still letting them download updates!
Kid-friendly analogy
The #1 beginner mistake: You create a gateway (like Internet Gateway or NAT Gateway) and wonder why your server still can't reach the internet. The answer: you forgot the Route Table rule! Gateways are just doors — they exist but no traffic goes through them until the Route Table has a rule pointing to them. Always create the gateway AND the matching route rule. Both steps are required!
06. Internet Gateway — The Main Front Door
What Is an Internet Gateway?
Your VCN is completely sealed by default. No traffic comes in, no traffic goes out. This is safe, but useless if you want to run a public website!
Kid-friendly analogy
An Internet Gateway (IGW) is like installing a big, two-way front gate on your neighbourhood. Once the gate is installed (and you add the road sign pointing to it in the Route Table), traffic can flow in BOTH directions:
- → Internet visitors can reach your public web server
- → Your web server can send responses back to visitors
Kid-friendly analogy
One important rule: the gate only works for resources that have a visible address on the public street — a public IP address. Your private bedroom (private subnet) has no nameplate on the public street, so the gate is useless for it. Only Public Subnet resources with public IPs can use the Internet Gateway!
THE ENTIRE INTERNET
│
│ Customers request your website (port 443)
│ Your server sends back webpages
▼
┌───── Internet Gateway ──────┐
│ The two-way front gate │
│ One per VCN (you only need │
│ one, no matter how many VMs)│
└─────────────┬───────────────┘
│
┌─────────────▼──────────────────┐
│ Public Subnet │
│ Load Balancer / Web Server │
│ (has a public IP address) │
└─────────────────────────────────┘
│
│ (private traffic — no internet)
▼
┌─────────────────────────────────┐
│ Private Subnet │
│ App Servers / Databases │
│ (NO public IP — internet │
│ cannot reach them!) │
└─────────────────────────────────┘
Everything You Need to Know About Internet Gateway
- One per VCN — You only ever need one Internet Gateway per VCN, regardless of how many subnets or VMs you have
- Two-way traffic — Handles both incoming (inbound) requests and outgoing (outbound) responses
- Free — OCI does not charge for the Internet Gateway itself (you're billed for data egress, not the gateway)
- Resources need public IPs — Only resources with a public IP address can use the Internet Gateway
- Requires a Route Table rule —
Destination: 0.0.0.0/0 → Target: Internet Gateway - Not for private subnets — Private subnet resources should never route through Internet Gateway
- Not for outbound-only from private resources — That's what NAT Gateway is for!
☐ Step 1: Create Internet Gateway inside your VCN
☐ Step 2: Add route rule in your Public Subnet's Route Table:
0.0.0.0/0 → Internet GatewayMiss either step and nothing works. Both are required!
07. NAT Gateway — The One-Way Secret Exit
What Is a NAT Gateway?
Here's a puzzle: Your database lives in a private subnet (nice and hidden from the internet). But your database needs to download security patches from the internet. How can the database call OUT to the internet, without letting the internet call BACK IN to the database?
Kid-friendly analogy
The answer is a NAT Gateway! NAT stands for Network Address Translation. Think of it like a one-way revolving door at a hotel lobby — hotel guests (your private resources) can walk out to the street (internet), but random people from the street cannot walk in through that same revolving door.
Here's the magic in detail: when your database sends a request to the internet (like "download this Linux patch"),
the NAT Gateway steps in front and sends the request using its own public IP address — hiding the database's private IP completely.
The internet sees the NAT Gateway's IP, not 10.0.2.20 (your database's private IP).
When the response comes back, NAT Gateway forwards it to the database.
But no one on the internet can ever initiate a new connection inward through the NAT Gateway. They don't even know your database exists!
INTERNET
▲
│ ← Outbound: "Please download this patch"
│ → Inbound: "Here is your patch data"
│
│ (Internet sees NAT Gateway's IP, not the DB's IP!)
│
┌────── NAT Gateway ──────────┐
│ Has its own public IP │
│ Translates: private IP │
│ → its own public IP │
│ for outbound requests only │
└─────────────┬───────────────┘
│
┌─────────────▼────────────────────────┐
│ Private Subnet │
│ │
│ Database (IP: 10.0.2.20) │
│ App Server (IP: 10.0.2.21) │
│ │
│ CAN send outbound (e.g., updates) │
│ Internet CANNOT reach them! │
└──────────────────────────────────────┘
Internet Gateway vs NAT Gateway — Crystal Clear Comparison
This is one of the most confusing points for beginners. Here is the definitive explanation:
-
Internet Gateway
- Which subnet uses it? → Public Subnets
- Traffic direction? → BOTH ways (inbound AND outbound)
- Can internet initiate connections to my resources? → YES (that's the point — web servers need this!)
- Do my resources need public IPs? → YES
- Example: A web server that users browse to
-
NAT Gateway
- Which subnet uses it? → Private Subnets
- Traffic direction? → Outbound connections and their inbound replies
- Can internet initiate connections to my resources? → NO (they're hidden!)
- Do my resources need public IPs? → NO (NAT GW uses its own public IP)
- Example: A database that needs to download OS security patches
Source: Oracle documentation.
Source: Oracle documentation.
08. Service Gateway — The Private Oracle Tunnel
What Is a Service Gateway?
Your application is running inside OCI and needs to store backup files in Oracle Object Storage. Or it needs to write logs to OCI Logging. Or it needs to pull a Docker image from OCI Container Registry.
Two options for supported regional Oracle service endpoints from your VCN are: Source: Oracle documentation.
- Option A (Public endpoint): Route the traffic to public service endpoints via NAT Gateway. Traffic to OCI-managed public IPs stays on OCI; same-region data transfer is free.
Kid-friendly analogy
Option B (Private path): Use a Service Gateway! This creates a private route from your VCN straight to Oracle's services, without leaving Oracle's private network backbone at all. Like having a secret corridor from your building directly to the Oracle office next door — no need to go outside!
Source: Oracle documentation 1; Oracle documentation 2.
Source: Oracle documentation.
WITHOUT Service Gateway — the public-endpoint path:
Private VM → NAT Gateway → OCI backbone → Oracle Object Storage
(OCI-managed public endpoints remain on OCI; same-region transfer is free.)
WITH Service Gateway — the private path:
Private VM → Service Gateway → Oracle Object Storage directly
(Same-region transfer is free. Stays on Oracle's network.)
Source: Oracle documentation 1; Oracle documentation 2; Oracle documentation 3.
Which Oracle Services Can You Reach Through Service Gateway?
Service Gateway access depends on supported regional service endpoints; examples to check include:Source: Oracle documentation.
- Object Storage — Store and retrieve files, images, ML training data, backups
- Autonomous Database — Fully managed Oracle database (ADB-S, ADB-D)
- OCI Monitoring and Logging — Send metrics and logs without internet
- OCI Container Registry (OCIR) — Pull Docker container images privately
- OCI Vault — Access encryption keys and secrets without internet exposure
- OCI Functions — Trigger serverless functions from your VCN
- Other supported OCI regional service endpoints.
Source: Oracle documentation.
The Three Big Benefits You Get Immediately
- Private network path — Traffic travels on Oracle's private backbone network, not the public internet. Latency improvements require measurement.
- Free data transfer within the same region — Data moving through a Service Gateway to Oracle services in the same region incurs NO egress charges. If you process 10TB of data between your VMs and Object Storage per month using Service Gateway — that's completely free! Same-region access through public OCI endpoints is also free of data transfer charges; service usage charges still apply.
- More secure — Your data never touches the public internet. Continue using encryption, IAM, and appropriate access controls. For financial data, healthcare records, or any sensitive information, this matters enormously.
Source: Oracle documentation 1; Oracle documentation 2.
Source: Oracle documentation.
09. Local Peering Gateway (LPG) — Bridge Between Two Neighbourhoods
What Is a Local Peering Gateway?
As your company grows, you'll often end up with multiple separate VCNs in the same OCI region. Maybe you have one VCN for your Development team and another for your Finance team. They need to share data — but you absolutely don't want that traffic going over the public internet!
Kid-friendly analogy
A Local Peering Gateway (LPG) is like building a private road between two separate neighbourhoods. The road connects them directly — no public streets involved, no traffic from outsiders, completely private. VCN-A and VCN-B can talk to each other using their private IP addresses, and all traffic stays entirely on Oracle's internal network.
Kid-friendly analogy
Sticky Note for Beginners: Two separate VCNs, two separate address ranges, one private "road" (the LPG) joining them in the middle. The important detail to notice: the CIDR ranges (10.0.0.0/16 and 172.16.0.0/16) are different from each other — that's required, and Section 09 explains exactly why just below.
Source: Oracle documentation.
OCI Region: Mumbai
┌─────────────────────────────────┐ ┌────────────────────────────────────┐
│ VCN-A (Dev Team) │ │ VCN-B (Finance Team) │
│ CIDR: 10.0.0.0/16 │ │ CIDR: 172.16.0.0/16 │
│ │ │ │
│ Dev App Server: 10.0.1.10 │◄──LPG──►│ Finance Database: 172.16.1.20 │
│ │ private │ │
│ This server can query the │ road │ This DB only accepts connections │
│ Finance DB privately! │ │ from trusted VCN-A resources │
└─────────────────────────────────┘ └────────────────────────────────────┘
Traffic stays entirely on Oracle's private network — never touches public internet!
Setting Up an LPG — Step by Step
Kid-friendly analogy
Think of setting up an LPG like two neighbours agreeing to build a connecting gate between their gardens. Both neighbours must build their side of the gate. Both must unlock it. Then traffic can flow!
- Step 1: Go to VCN-A in OCI Console → Create a Local Peering Gateway called
lpg-to-vcn-b - Step 2: Go to VCN-B in OCI Console → Create a Local Peering Gateway called
lpg-to-vcn-a - Step 3: From VCN-A's LPG, click "Peer This Gateway" and paste in the OCID (unique identifier) of VCN-B's LPG — this establishes the peering connection
-
Step 4: Update Route Tables in both VCNs so they know the road to each other:
- VCN-A Route Table: Add rule —
Destination: 172.16.0.0/16 → Target: lpg-to-vcn-b - VCN-B Route Table: Add rule —
Destination: 10.0.0.0/16 → Target: lpg-to-vcn-a
- VCN-A Route Table: Add rule —
- Step 5: Update Security Lists or NSGs in both VCNs to allow traffic on the specific ports needed across the peering connection
This is the most common LPG setup failure. If VCN-A uses
10.0.0.0/16 and VCN-B also uses 10.0.0.0/16,
OCI cannot route traffic correctly — both VCNs have the same addresses and OCI doesn't know which one you mean!
The fix: Plan your IP ranges BEFORE creating any VCNs. Use a simple rule:
VCN-A: 10.0.0.0/16, VCN-B: 172.16.0.0/16, On-Premises: 192.168.0.0/16
No overlap = no problems. Write this down before you build anything!
10. Dynamic Routing Gateway (DRG) — The Superhighway Hub
What Is a DRG?
You've now mastered everything inside OCI. But what about the bigger picture? What if your company has a physical data center (real servers in a building) that needs to talk to OCI? Or what if you need your Mumbai VCN and your London VCN to communicate privately? Or what if you need a multi-cloud setup connecting OCI to AWS?
Kid-friendly analogy
This is the job of the Dynamic Routing Gateway (DRG). Think of it as a massive highway interchange — the kind where motorways from 5 different cities all meet at one central junction, and traffic can flow between any of them through that single hub.
You attach your VCN to the DRG. Then the DRG becomes the central routing brain that manages connections to the outside world: your office, other OCI regions, other clouds. Everything routes through the DRG!
Kid-friendly analogy
Sticky Note for Beginners: Think of the DRG box as a train station with three platforms. Platform 1 connects to your own VCN, platform 2 connects to a sibling VCN in another region, platform 3 connects to your physical office. All three "trains" arrive at the same central station — that central station is the DRG.
┌────────────────────────────────────────────┐
│ DRG (The Central Highway Hub) │
└──────┬────────────────┬────────────┬───────┘
│ │ │
┌────────────┘ ┌───────────┘ ┌────────┘
▼ ▼ ▼
┌──────────────────┐ ┌─────────────┐ ┌──────────────────────┐
│ Your VCN │ │ Other VCN │ │ Company Office │
│ (Mumbai) │ │ (London) │ │ Physical Servers │
│ │ │ DR Site │ │ (via VPN or │
│ Main workload │ │ Failover │ │ FastConnect) │
└──────────────────┘ └─────────────┘ └──────────────────────┘
What Can DRG Connect To ?
OCI DRG v2 (the current version) supports four major connection types:
-
IPSec VPN (Site-to-Site VPN)
Kid-friendly analogy
Creates an encrypted tunnel over the public internet between your office and OCI. Imagine a completely opaque pipe going through a busy street — people on the street can see the pipe, but they cannot see what's flowing inside (all data is encrypted end-to-end).
Your office router connects to OCI's VPN endpoint. Traffic between your office and OCI flows through this encrypted tunnel.
Best for: Smaller offices, quick initial setup, budget-friendly, testing hybrid connectivity.
Limitation: Speed depends on your internet connection quality. Shared with internet traffic. -
FastConnect (Dedicated Private Line)
Kid-friendly analogy
A dedicated private connection to Oracle through a partner, third-party provider, or colocation. Think of it as your company arranging a private road to Oracle — no public internet on that connection.
Best for: Large enterprises, banks, hospitals — any company needing high bandwidth and more consistent private connectivity; actual performance depends on the design.
Available in: 1, 10, 100, or 400 Gbps cross-connect options, depending on location and connection model. -
Remote Peering Connections (VCNs in Different Regions)
Connects VCNs that are in different OCI regions privately. Example: Your Mumbai VCN (production) and your London VCN (disaster recovery site) can talk to each other through DRG-to-DRG peering. Traffic stays entirely on Oracle's global backbone — no public internet.
Best for: Multi-region architectures, global applications, disaster recovery setups. -
Transit Routing — Many VCNs Through One DRG
This is the most powerful feature of DRG v2. Attach multiple VCNs to a single DRG, and they can ALL communicate with each other through the DRG as the central router. No need to create individual LPGs between every pair of VCNs.
Example: 5 VCNs all attached to one DRG. Any VCN can talk to any other VCN through the DRG. That's 1 DRG doing the work of potentially 10 peering connections (20 LPGs) — much simpler to manage!
Best for: Organisations with many VCNs. Enterprise-scale architectures.
Source: Oracle documentation 1; Oracle documentation 2.
The Hub-and-Spoke Model — The Gold Standard Architecture
As organisations grow on OCI, they often end up with many VCNs: one for Dev, one for Prod, one for Security, one for Shared Services, one for Analytics, etc. The smartest way to organise all of this is the Hub-and-Spoke architecture using DRG.
Kid-friendly analogy
Imagine a bicycle wheel: The hub is a central VCN connected to the DRG, containing shared services: firewalls, centralised DNS, logging, bastion hosts. Each team or workload VCN is a spoke that connects to the hub through the DRG. ALL traffic between spokes can be routed through the hub for inspection when the DRG and VCN routes enforce that path.
Source: Oracle documentation.
Kid-friendly analogy
Sticky Note for Beginners: Picture a wheel: the DRG is the axle, the Hub VCN sits right next to it, and every Spoke VCN (Dev, Production, On-Premises) is a spoke reaching out from the centre. The key sentence to remember is written right under the diagram: spoke-to-spoke traffic passes through the hub only when routing enforces the inspection path.
Source: Oracle documentation.
┌──────────────────────────┐
│ HUB VCN │
│ (Shared Services) │
│ Centralised Firewall │
│ DNS / Bastion / Logging│
└────────────┬─────────────┘
│
┌───▼───┐
│ DRG │ ← Central Router for Everything
└───┬───┘
┌──────────────────────┼──────────────────────┐
│ │ │
┌────────▼────────┐ ┌──────────▼──────┐ ┌────────────▼──────┐
│ Spoke VCN │ │ Spoke VCN │ │ On-Premises │
│ (Dev Team) │ │ (Production) │ │ Data Center │
│ 10.1.0.0/16 │ │ 10.2.0.0/16 │ │ 192.168.0.0/16 │
└─────────────────┘ └─────────────────┘ └───────────────────┘
With inspection routing configured, traffic between spokes passes through Hub VCN.
Centralised security inspection, logging, and control.
Adding a new team's VCN? Attach it to DRG and configure routes and security rules.
Source: Oracle documentation 1; Oracle documentation 2.
The hub-and-spoke model with DRG v2 has become the standard enterprise architecture pattern on OCI. It scales to dozens of VCNs while keeping your network manageable and secure.
Source: Oracle documentation 1; Oracle documentation 2.
11. The Complete Picture — All Concepts Working Together
Building a Real E-Commerce Application on OCI
Now let's see ALL ten concepts working together in one complete, real architecture. Imagine you are launching an online shopping app. You need: a Load Balancer to receive customer traffic, App Servers to process orders, a Database to store customer data, Oracle Object Storage for product images, and a connection to your physical warehouse management system.
THE INTERNET
│
Customers visit your shop
│
┌───────────▼───────────┐
│ Internet Gateway │
│ (two-way front door) │
└───────────┬───────────┘
│
┌───────────────────────────▼───────────────────────────────────────┐
│ VCN: 10.0.0.0/16 │
│ │
│ ┌──────────────── Public Subnet: 10.0.1.0/24 ───────────────┐ │
│ │ Route Table: 0.0.0.0/0 → Internet Gateway │ │
│ │ NSG-LB: Allow port 443 inbound from 0.0.0.0/0 │ │
│ │ │ │
│ │ Load Balancer (has public IP) │ │
│ └──────────────────────────┬────────────────────────────────┘ │
│ │ (forwards to port 8080) │
│ ┌──────────────── Private Subnet A: 10.0.2.0/24 ────────────┐ │
│ │ Route Table: 0.0.0.0/0 → NAT Gateway │ │
│ │ All OCI Services → Service Gateway
│ │ 192.168.0.0/16 → DRG │ │
│ │ NSG-App: Allow port 8080 from NSG-LB only │ │
│ │ │ │
│ │ App Server 1 (10.0.2.10) App Server 2 (10.0.2.11)│ │
│ └──────────────────────────┬────────────────────────────────┘ │
│ │ (queries database on port 3306) │
│ ┌──────────────── Private Subnet B: 10.0.3.0/24 ────────────┐ │
│ │ Route Table: All OCI Services → Service Gateway │ │
│ │ NSG-DB: Allow port 5432 from NSG-App ONLY │ │
│ │ │ │
│ │ MySQL Database (10.0.3.10) │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────┐ ┌───────────────────┐ ┌──────────────┐ │
│ │ NAT Gateway │ │ Service Gateway │ │ DRG │ │
│ └───────┬───────┘ └────────┬──────────┘ └──────┬───────┘ │
└──────────┼────────────────────┼─────────────────────┼───────────┘
│ │ │
▼ ▼ ▼
Internet Oracle Object Warehouse Office
(OS patches, Storage (Inventory System via
Docker images) (Product images, IPSec VPN — private
Order backups) and encrypted)
Source: Oracle documentation 1; Oracle documentation 2.
Let's Follow a Customer's Order Request — Step by Step!
A customer clicks "Buy Now" on your website. Here's the complete journey:
- Step 1 — Internet Gateway: The customer's browser sends an HTTPS request to your load balancer's public IP. The request enters through the Internet Gateway (the front door).
- Step 2 — NSG-LB check: The NSG-LB rule asks: "Is this port 443 from the internet? Yes." → Request is allowed through
- Step 3 — Load Balancer: The Load Balancer distributes the request to one of the healthy App Servers on port 8080.
- Step 4 — NSG-App check: The NSG-App rule asks: "Is this coming from a resource with the NSG-LB badge? Yes." → Allowed
- Step 5 — App Server processing: The App Server processes the order and needs to check inventory — it queries the database on port 3306.
- Step 6 — NSG-DB check: The NSG-DB rule asks: "Is this coming from a resource with the NSG-App badge? Yes." → Allowed
- Step 7 — Database: The database retrieves inventory data and sends it back to the App Server.
- Step 8 — Service Gateway: The App Server saves the order receipt image to Oracle Object Storage — via the Service Gateway. Same-region data transfer is free; service usage charges still apply. Never touches public internet.
- Step 9 — DRG + VPN: The App Server sends the order details to the Warehouse Management System in your physical office — through the DRG and the encrypted IPSec VPN tunnel. Private and secure.
- Step 10 — Response: The "Order Confirmed!" page travels back through App Server → Load Balancer → Internet Gateway → Customer's browser.
Source: Oracle documentation 1; Oracle documentation 2.
Every single component we learned plays its exact role in this journey. This is how real, production-grade OCI architectures work!
12. Common Beginner Mistakes to Avoid
After teaching hundreds of beginners, here are the mistakes that come up again and again. Study these — each one represents real pain you can avoid!
Kid-friendly analogy
Mistake 1: Creating a Gateway but forgetting the Route Table rule
You create an Internet Gateway but your server can't reach the internet. Confused?
The fix: Go to your subnet's Route Table and add: Destination: 0.0.0.0/0 → Target: Internet Gateway.
Remember: a gateway is just a door. The Route Table is the road sign telling traffic to use that door.
Both must exist!
Within minutes of launching a server with port 22 open to the whole internet, automated attack bots will find it and try thousands of username/password combinations per second. The fix: Restrict SSH to your specific office IP (e.g.,
203.0.113.50/32).
Even better: use OCI Bastion Service — it creates temporary, audited access without public inbound ports on the target; private target access rules are still required!
Source: Oracle documentation.
It's tempting to put everything in one public subnet for simplicity. A database in a public subnet with a public IP is a disaster waiting to happen. The fix: Always use separate public and private subnets. Web servers and load balancers go in Public Subnets. Databases and app servers go in Private Subnets. Always.
You try to set up an LPG between two VCNs and it fails because both use
10.0.0.0/16.
The fix: Plan your entire IP address scheme BEFORE creating your first VCN.
Draw a table: VCN-A → 10.0.0.0/16, VCN-B → 172.16.0.0/16, On-premises → 192.168.0.0/16.
Once VCNs are created with the wrong ranges, fixing it often requires rebuilding from scratch!
You haven't set up a Service Gateway, so all outbound traffic (including calls to Object Storage) goes through NAT Gateway and the public internet. The fix: Create a Service Gateway, add the route rule in your Private Subnet's Route Table, to obtain a private path to supported same-region service endpoints.
Source: Oracle documentation.
You carefully set up all your Ingress rules but forget Egress. New outbound connections then lack permission; stateful replies still work. The fix: Add a broad egress rule as a default:
All Protocols → All Ports → Destination: 0.0.0.0/0.
Unless you have a very specific reason to restrict outbound traffic (like a high-security environment), allow all egress.
Source: Oracle documentation.
13. Quick Cheat Sheet — Everything at a Glance
All 10 OCI networking concepts summarised:
Kid-friendly analogy
VCN → Your private city in OCI. VCN-connected resources use it. Create it before those resources.
Kid-friendly analogy
Subnet → Rooms inside the VCN. Public = front yard (internet-facing). Private = bedroom (hidden). Divide by security level!
- Security List → Firewall rules for the entire subnet. All resources in the subnet share the same rules. Good for broad defaults. Deny by default.
- NSG → Smart firewall rules for individual resources. Can reference other NSGs as source/destination. The preferred approach in production.
Kid-friendly analogy
Route Table → Road signs for traffic. Tells packets "to reach X, go through gateway Y". Every subnet needs one. Must be updated when you add a gateway!
Kid-friendly analogy
Internet Gateway → Two-way front door. Internet can reach your Public Subnet resources (inbound AND outbound). One per VCN. Free.
Kid-friendly analogy
NAT Gateway → One-way exit for Private Subnets. Your resources can call the internet; internet CANNOT initiate connections back in. Use for OS patches, Docker pulls, external APIs.
Kid-friendly analogy
Service Gateway → Private shortcut to Oracle services. Free data transfer within region, never touches public internet. Use for supported regional endpoints.
Kid-friendly analogy
LPG → Private bridge between two VCNs in the same OCI region. No internet. Requires non-overlapping CIDRs and Route Table rules on both sides.
Kid-friendly analogy
DRG → The superhighway hub. Connects VCN to on-premises (via VPN or FastConnect), other OCI regions (Remote Peering), and multiple VCNs (transit routing). Foundation of enterprise hybrid cloud.
Source: Oracle documentation 1; Oracle documentation 2.
14. Frequently Asked Questions
Written for engineers who already know the basics — the kind of questions that come up in a real design-review meeting.
Q: Security Lists and NSGs support stateful rules — what does that actually mean for how I write my rules?
Stateful means OCI automatically tracks an established connection and allows the matching return traffic, even if you didn't write an explicit rule for it. If a client connects inbound on port 443, the response traffic going back out doesn't need a separate egress rule to match it — it's recognised as part of the same session. This is why the article's egress rule for the web server (allow all outbound) is about new outbound connections your server initiates, not about replies to inbound requests.
Q: Can one VNIC belong to multiple NSGs at the same time, and how do conflicting rules get resolved?
Yes — a single VM's VNIC can be attached to more than one NSG simultaneously (OCI documents a maximum per VNIC, so check current service limits before designing around it). When multiple NSGs are attached, OCI takes the union of all their rules — if ANY attached NSG allows the traffic, it's allowed. There's no "deny wins" conflict resolution the way some other firewall systems work, so avoid assuming one NSG can override another's allow rule.
Q: In a hub-and-spoke DRG design, how do I actually stop two spoke VCNs from talking directly to each other and bypassing the hub?
This is controlled through DRG route tables (a separate concept from VCN route tables), using route distributions and import/export rules per attachment. By default, DRG v2 can propagate routes between all attachments, so isolation isn't automatic — you deliberately configure the DRG's route table so traffic entering from each spoke is forwarded toward the hub for inspection. VCN subnet routes must also be configured; DRG routes are not dynamically exported into VCN route tables. This is a common review point in enterprise landing-zone designs, so it's worth validating against Oracle's current DRG route table documentation before go-live.
Q: We're migrating from a flat Security-List-only design to NSG-based microsegmentation. What's the safest rollout approach?
Run them in parallel rather than cutting over in one step. Since Security Lists and NSGs are additive (traffic is allowed if either permits it), you can attach the new, tighter NSGs to resources while the existing Security List rules are still active, verify application behaviour and logs show no unexpected drops, and only then progressively tighten or remove the broader Security List rules. This avoids an outage caused by an incomplete NSG rule set going live before it's fully tested.
Q: Does Service Gateway traffic ever incur cross-region egress costs, or is it always free?
It's free specifically for traffic to OCI services within the same region as your VCN. If your application calls an OCI service endpoint in a different region, that traffic does not qualify for the same-region Service Gateway benefit and standard data transfer pricing can apply. This is a subtle point worth flagging in cost-review discussions for multi-region architectures — always confirm current pricing on Oracle's official cost pages for your specific scenario.
Q: Can a Local Peering Gateway connect VCNs that live in different tenancies, or is it strictly intra-tenancy?
Yes. LPG peering supports VCNs in different tenancies within the same region, with the required IAM policies. Cross-region peering uses DRGs and remote peering connections.
Q: If a NAT Gateway hides my private IP behind its own public IP, how do I attribute outbound traffic back to a specific instance for security auditing?
Address translation at the NAT Gateway obscures the source IP from the destination's point of view, but OCI's VCN Flow Logs capture the original private IP, port, and instance-level metadata for captured flows at the source VNIC; enable logging and account for sampling, exclusions, and unavailable metadata. For audit and forensic purposes, correlate flow logs (or VCN-level network visibility tooling) rather than relying on the external-facing NAT IP alone — the NAT IP alone won't tell you which of your ten app servers made a given request.
Q: For a regulated workload (say, PCI-DSS or a banking client), is FastConnect mandatory, or is IPSec VPN over the DRG considered acceptable?
IPSec VPN encrypts traffic between the VPN endpoints; its acceptability for a regulated workload requires assessment against the applicable controls — the "public internet" concern is mitigated by the encryption itself, not eliminated by avoiding the internet. FastConnect is chosen more for bandwidth guarantees, latency consistency, and reduced dependency on public internet reliability than for encryption per se (FastConnect traffic itself isn't automatically encrypted unless you configure suitable encryption, such as IPSec or supported MACsec). The right choice is usually driven by your specific compliance framework and SLA requirements — worth a direct conversation with your compliance and network architecture teams rather than a one-size-fits-all answer.
Source: Oracle documentation 1; Oracle documentation 2; Oracle documentation 3; Oracle documentation 4; Oracle documentation 5.
15. Additional References
- Networking Overview — Overview of VCNs, subnets, gateways, connectivity choices, and network components.
- Security Rules — Security Lists, Network Security Groups, and important security-rule concepts.
- VCN Route Tables — Route rules, next-hop targets, and routing behavior within and beyond a VCN.
- NAT Gateway — Outbound internet access for private resources, response traffic, and required routing.
- Access to Oracle Services: Service Gateway — Private access to supported regional Oracle services and Service Gateway configuration.
- Dynamic Routing Gateways — DRG attachments, routing tables, and connectivity to other VCNs and on-premises networks.
- Local VCN Peering using Local Peering Gateways — Same-region and cross-tenancy peering, routing, and the two-LPG relationship.
- Bastion Overview — Time-limited private-target access and connection controls.
- FastConnect Overview — Connection models and location-dependent port speeds.
- Virtual Cloud Network FAQ — OCI backbone routing and regional public service access.
- Virtual Cloud Network Pricing — Intra-region transfer and internet-egress charging distinctions.
- MySQL Port Reference Tables — Default MySQL client/server ports used to align the example.
16. Finally — Summary
OCI networking becomes easier to understand when each component has a clear job. A VCN provides the private network, and subnets divide its address space. Security Lists and NSGs govern allowed traffic, while route tables determine where that traffic goes.
The gateways serve different destinations and connection needs: Internet Gateway supports public internet connectivity, NAT Gateway lets private resources initiate internet connections, and Service Gateway provides private access to supported Oracle services. LPG connects VCNs in the same region, while DRG supports broader connectivity between VCNs and on-premises networks.
The practical lesson is to design routing and security together. In the three-tier example, the load balancer, application servers, and database each have a defined role and carefully scoped access. Keep address ranges non-overlapping, avoid unnecessarily exposed services, and check both routes and security rules when troubleshooting connectivity.

Comments
Post a Comment