This comprehensive guide covers the complete setup of Oracle Cloud Infrastructure (OCI) including tenancy governance, network architecture, VM deployment, and hybrid connectivity testing between OCI and Azure environments.

After receiving your activation email from Oracle, the first step is to create your tenancy:
Before deploying infrastructure, establish governance frameworks:
Navigate to Governance → Tags to define organizational standards:
Benefits of Tags:
The root compartment is powerful but not recommended for operational use:
Create a compartment hierarchy:
Root Compartment
└── core-shared-services (Central IT managed resources)
├── IT Ops
├── Networking
├── Database
└── Shared Services
Compartment Strategy:
1. Navigate: Identity → Groups
2. Create Groups:
- admin-it (IT Operations administrators)
- admin-core (Core infrastructure admins)
- audit-team (Compliance and audit)
Oracle uses a powerful matrix-based policy model:
Allow <subject> to <verb> <resource-type> in <location> where <conditions>
Example Policies:
# Allow IT ops full resource management in core-shared-services
Allow group admin-it to manage all-resources in compartment core-shared-services
# Allow IT ops to manage VCNs and related networking
Allow group admin-it to manage virtual-network-family in compartment core-shared-services
# Allow IT ops to manage compute resources
Allow group admin-it to manage instance-family in compartment core-shared-services
Allow group admin-it to manage compute-management-family in compartment core-shared-services
# Allow audit team read-only access
Allow group audit-team to read all-resources in compartment core-shared-services
Policy Structure Benefits:

Implement a hub-and-spoke topology for centralized network management:
Architecture Overview:
1. Navigate: Networking → Virtual Cloud Networks
2. Create VCN:
- Name: vcn-core-hub
- CIDR: 10.0.100.0/16
- Compartment: core-shared-services
3. Click "Create VCN"
Public Subnet (DMZ/VPN Gateway):
Name: subnet-public-vpn
VCN: vcn-core-hub
CIDR: 10.0.100.0/28
Subnet Type: Public
Route Table: Public Route Table
Security List: Public Security List
Private Subnet (Internal Services):
Name: subnet-private-internal
VCN: vcn-core-hub
CIDR: 10.0.100.16/28
Subnet Type: Private
Route Table: Private Route Table
Security List: Private Security List
Security Lists in OCI function similarly to Network Security Groups (NSGs) in Azure but are applied at the subnet level.
Ingress Rules:
| Protocol | Source | Port | Purpose |
|---|---|---|---|
| TCP | 0.0.0.0/0 | 22 | SSH management |
| UDP | 0.0.0.0/0 | 500 | IPsec IKE |
| UDP | 0.0.0.0/0 | 4500 | IPsec NAT-T |
| ICMP | 0.0.0.0/0 | All | Ping/troubleshooting |
| TCP | 172.16.0.0/24 | 443 | Azure SSL access |
Egress Rules:
Protocol: All
Destination: 0.0.0.0/0
Allows all outbound traffic from VPN instances
Example Configuration:
Ingress Rule 1:
Stateless: No
Protocol: TCP
Source: 0.0.0.0/0
Source Port: All
Destination Port: 22
Ingress Rule 2:
Stateless: No
Protocol: UDP
Source: 0.0.0.0/0
Source Port: All
Destination Port: 500
Ingress Rule 3:
Stateless: No
Protocol: ICMP
Source: 0.0.0.0/0
Allow internal communication and traffic through VPN gateway:
Ingress:
- TCP from 10.0.100.0/24 (all ports)
- UDP from 10.0.100.0/24 (all ports)
- ICMP from 10.0.100.0/24
- All from 172.16.0.0/24 (Azure network)
Egress:
- All traffic to 0.0.0.0/0
Provides internet access for public-facing resources:
1. Create IGW:
Navigate: Networking → Internet Gateways
Name: igw-core
VCN: vcn-core-hub
2. Create Route Table:
Name: rt-public
Add Route:
Destination: 0.0.0.0/0
Target: igw-core
3. Associate with public subnet
Allows private resources to initiate outbound internet connections:
1. Create NAT Gateway:
Navigate: Networking → NAT Gateways
Name: nat-core
VCN: vcn-core-hub
2. Create Route Table:
Name: rt-private
Add Route:
Destination: 0.0.0.0/0
Target: nat-core
3. Associate with private subnet
Important Considerations:
Essential for VPN and multi-network connectivity:
1. Create DRG:
Navigate: Networking → Dynamic Routing Gateways
Name: drg-core
Compartment: core-shared-services
2. Attach to VCN:
Select DRG → Attach
VCN: vcn-core-hub
3. Create Route Table for VPN Traffic:
Name: rt-drg
Add Route:
Destination: 172.16.0.0/24 (Azure network)
Target: drg-core (IPsec connection)
┌─────────────────────────────────────────────┐
│ OCI VCN (10.0.100.0/16) │
│ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ IGW │ │ NAT Gateway │ │
│ │ (Internet) │ │ (Outbound only) │ │
│ └──────────────┘ └──────────────────┘ │
│ ▲ ▲ │
│ │ │ │
│ ┌──────────────────────────────────────┐ │
│ │ Public Subnet (10.0.100.0/28) │ │
│ │ - VPN Gateway VM │ │
│ │ - Admin/Jumpbox VM │ │
│ └──────────────────────────────────────┘ │
│ │ │
│ │ ┌──────────┐ │
│ └─────▶│ DRG │◀──────────┐ │
│ │ (IPsec) │ │ │
│ └──────────┘ To Azure│
│ │ │
│ ┌──────────────────────────────────────┐ │
│ │ Private Subnet (10.0.100.16/28) │ │
│ │ - Internal Services │ │
│ │ - Application Servers │ │
│ └──────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────┘

We need multiple VMs for different purposes:
Before creating instances, generate SSH keys:
On Linux/Mac:
ssh-keygen -t rsa -b 4096 -f ~/.ssh/oci-key
# Save the generated key securely
# You'll need the public key during VM creation
On Windows (using PuTTYgen):
1. Navigate: Compute → Instances
2. Create Instance:
Name: vm-vpn-core-shared-services
Image: Ubuntu 20.04 or 22.04
Shape: Standard.E2.Micro (free tier eligible)
Subnet: subnet-public-vpn
3. Add SSH Public Key:
Paste your public SSH key
4. Click "Create Instance"
Instance Details to Note:
Using SSH:
ssh ubuntu@<public-ip> -i ~/.ssh/oci-key
Using OCI Console VNC:
1. Create Instance:
Name: vm-admin-core-shared-services
Image: Ubuntu 20.04 or 22.04
Shape: Standard.E2.Micro
Subnet: subnet-private-internal
2. Note: Private IP only (accessible through VPN or bastion)
1. Create Instance:
Name: vm-internal-test
Image: Ubuntu 20.04 or 22.04
Shape: Standard.E2.Micro
Subnet: subnet-private-internal
2. This VM will verify internal routing and VPN connectivity

Goal: Establish secure IPsec tunnel between:
Libreswan is a robust IPsec implementation, easier to configure than Strongswan.
Connect to VPN VM:
ssh ubuntu@<vm-public-ip> -i ~/.ssh/oci-key
Install Libreswan:
sudo apt-get update
sudo apt-get install libreswan -y
sudo systemctl enable ipsec
Create /etc/ipsec.d/azure-oci.conf:
version 2.0
config setup
uniqueids=yes
strictcrlpolicy=no
conn azure-oci
authby=secret
left=%defaultroute
leftid=mouradcloudsecu.westeurope.cloudapp.azure.com
leftnexthop=172.16.0.1
leftsubnet=172.16.0.0/24
right=130.61.50.28
rightsubnet=10.0.100.0/24
rightnexthop=10.0.100.1
ike=aes256-sha1;modp2048
esp=aes256-sha1
keyingtries=0
ikelifetime=1h
lifetime=8h
dpddelay=30
dpdtimeout=120
dpdaction=restart
auto=start
Create /etc/ipsec.d/azure-oci.conf:
version 2.0
config setup
uniqueids=yes
strictcrlpolicy=no
conn azure-oci
authby=secret
left=%defaultroute
leftid=130.61.50.28
leftnexthop=10.0.100.1
leftsubnet=10.0.100.0/24
right=mouradcloudsecu.westeurope.cloudapp.azure.com
rightsubnet=172.16.0.0/24
rightnexthop=172.16.0.1
ike=aes256-sha1;modp2048
esp=aes256-sha1
keyingtries=0
ikelifetime=1h
lifetime=8h
dpddelay=30
dpdtimeout=120
dpdaction=restart
auto=start
Create /etc/ipsec.secrets on both sides:
%any %any : PSK "YOUR_SECURE_PRESHARED_KEY_HERE"
Security Considerations:
Edit /etc/sysctl.conf on both VPN endpoints:
# IP forwarding (essential for VPN gateway role)
net.ipv4.ip_forward = 1
# Accept source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Accept redirects (generally not needed for VPN)
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
# Send redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
# Reverse path filtering (disable for VPN scenarios)
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
# Per-interface settings
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.ens3.send_redirects = 0
net.ipv4.conf.ens3.rp_filter = 0
Apply changes:
sudo sysctl -p
Enable masquerading for traffic traversing the VPN:
Azure VPN VM:
sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -d 10.0.100.0/24 -j MASQUERADE
OCI VPN VM:
sudo iptables -t nat -A POSTROUTING -s 10.0.100.0/24 -d 172.16.0.0/24 -j MASQUERADE
Execute on both VPN endpoints:
# Start/restart IPsec service
sudo ipsec start
sudo ipsec restart
# Load the connection
sudo ipsec auto --add azure-oci
# Initiate the connection
sudo ipsec auto --up azure-oci
# Check status
sudo ipsec status
Expected Output:
Total IPsec connections: 1
azure-oci (10.0.100.0/24===172.16.0.0/24); eroute owner: #1
azure-oci: IKEv1 proposal: AES_256-SHA1;MODP2048
azure-oci: ESP proposal: AES_256-SHA1
Configure OCI as next hop from Azure VMs:
# Create route table
$routeTable = New-AzureRmRouteTable `
-ResourceGroupName $ResourceGroupName `
-Name "rt-to-oci" `
-Location $location
# Add route to OCI network
$routeTable | Add-AzureRmRouteConfig `
-Name "route-to-oci" `
-AddressPrefix "10.0.100.0/24" `
-NextHopType "VirtualAppliance" `
-NextHopIpAddress "172.16.0.5" | `
Set-AzureRmRouteTable
# Associate with subnet
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "default" -VirtualNetwork $vnet
Set-AzureRmVirtualNetworkSubnetConfig `
-VirtualNetwork $vnet `
-Name "default" `
-AddressPrefix $subnet.AddressPrefix `
-RouteTable $routeTable | Set-AzureRmVirtualNetwork
From OCI VPN VM:
sudo ipsec status
sudo ipsec trafficstatus
Expected Tunnel Status:
Total IPsec connections: 1
azure-oci (10.0.100.0/24===172.16.0.0/24); eroute owner: #1
azure-oci: newest ISAKMP SA: #1; newest IPsec SA: #2;
...state: ESTABLISHED
From OCI VPN VM (10.0.100.5):
# Ping Azure VPN endpoint
ping 172.16.0.5
# Expected: Replies from 172.16.0.5
PING 172.16.0.5 (172.16.0.5) 56(84) bytes of data.
64 bytes from 172.16.0.5: icmp_seq=1 ttl=64 time=45.2 ms
64 bytes from 172.16.0.5: icmp_seq=2 ttl=64 time=43.8 ms
From Azure VPN VM (172.16.0.5):
# Ping OCI VPN endpoint
ping 10.0.100.5
# Expected: Replies from 10.0.100.5
Verify traffic routes through VPN gateway to reach remote VMs:
Test Scenario:
On OCI Internal VM:
# Configure static route to Azure network via VPN gateway
sudo ip route add 172.16.0.0/24 via 10.0.100.5
# Ping Azure internal VM through VPN gateway
ping 172.16.0.7
# Trace route
traceroute 172.16.0.7
Expected Traceroute Output:
traceroute to 172.16.0.7 (172.16.0.7), 30 hops max, 60 byte packets
1 10.0.100.5 (10.0.100.5) 2.345 ms 2.312 ms 2.298 ms
2 172.16.0.1 (172.16.0.1) 45.123 ms 44.987 ms 45.234 ms
3 172.16.0.7 (172.16.0.7) 45.456 ms 45.512 ms 45.389 ms
Ensure ICMP is allowed in security lists:
Azure NSG:
Allow ICMP from 10.0.100.0/24
OCI Security List:
Allow ICMP from 172.16.0.0/24
Check traffic statistics:
# View encrypted traffic
sudo ipsec trafficstatus
# Monitor in real-time
watch -n 1 'sudo ipsec trafficstatus'
VPN Not Connecting:
# Check logs
sudo tail -f /var/log/auth.log
sudo tail -f /var/log/syslog
# Verify PSK matches on both sides
grep PSK /etc/ipsec.secrets
# Test connectivity without IPsec
ping -c 1 <remote-vm-ip>
Traffic Not Passing Through Tunnel:
# Verify routing table
ip route show
# Check NAT rules
sudo iptables -t nat -L -v
# Verify security lists/NSGs
# Both sides must allow required protocols (500, 4500 UDP for IPsec)
┌─────────────────────────────────────────────────────────────────┐
│ AZURE │
│ 172.16.0.0/24 │
│ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ Subscription / Resource Group │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────┐ │ │
│ │ │ VNET: 172.16.0.0/24 │ │ │
│ │ │ │ │ │
│ │ │ ┌──────────────┐ ┌──────────────────────────┐ │ │ │
│ │ │ │ VPN VM │ │ Internal VMs │ │ │ │
│ │ │ │ 172.16.0.5 │◀───│ 172.16.0.7 │ │ │ │
│ │ │ │(Libreswan) │ │ 172.16.0.10 │ │ │ │
│ │ │ └──────┬───────┘ └──────────────────────────┘ │ │ │
│ │ │ │ IPsec Tunnel │ │ │
│ │ │ │ UDP 500, 4500 │ │ │
│ │ │ └────────────────────┐ │ │ │
│ │ │ NSG: Allow IPsec traffic │ │ │ │
│ │ └─────────────────────────────┼──────────────────────┘ │ │
│ │ │ │ │
│ └─────────────────────────────────┼─────────────────────────┘ │
│ │ │
│ mouradcloudsecu.westeurope.cloudapp.azure.com │
│ │ │
└─────────────────────────────────────┼───────────────────────────┘
│
╔═════════════════════════╗ │ ╔═════════════════════════╗
║ IPsec Encryption (SA) ║ │ ║ 10.0.100.0/24 ║
║ AES256-SHA1 ║─┼─║ OCI VCN ║
║ Lifetime: 8h ║ │ ║ ║
╚═════════════════════════╝ │ ╚═════════════════════════╝
│
┌─────────────────────────────────────┼───────────────────────────┐
│ │ OCI │
│ 130.61.50.28 │ │
│ (Public IP of VPN VM) │ │
│ │ │
│ ┌──────────────────────────────────▼──────────────────────┐ │
│ │ VCN: 10.0.100.0/16 │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────────┐ │ │
│ │ │ Public Subnet: 10.0.100.0/28 │ │ │
│ │ │ │ │ │
│ │ │ ┌─────────────────────┐ ┌────────────────┐ │ │ │
│ │ │ │ VPN VM │ │ Jumpbox VM │ │ │ │
│ │ │ │ 10.0.100.5 │ │ 10.0.100.4 │ │ │ │
│ │ │ │ (Libreswan) │ │ │ │ │ │
│ │ │ └─────────────────────┘ └────────────────┘ │ │ │
│ │ │ │ │ │
│ │ │ Security List: Allow 500, 4500 UDP, SSH, ICMP │ │ │
│ │ └─────────────────────┬──────────────────────────┘ │ │
│ │ │ │ │
│ │ │ Routes internal traffic │ │
│ │ ▼ │ │
│ │ ┌──────────────────────────────────────────────────┐ │ │
│ │ │ Private Subnet: 10.0.100.16/28 │ │ │
│ │ │ │ │ │
│ │ │ ┌──────────────────┐ ┌──────────────────┐ │ │ │
│ │ │ │ Internal VM │ │ Test VM │ │ │ │
│ │ │ │ 10.0.100.17 │ │ 10.0.100.18 │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ Reaches Azure │ │ Reaches Azure │ │ │ │
│ │ │ │ through VPN │ │ through VPN │ │ │ │
│ │ │ └──────────────────┘ └──────────────────┘ │ │ │
│ │ │ │ │ │
│ │ │ Security List: Allow internal traffic │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ DRG (Dynamic Routing Gateway) │ │
│ │ Manages IPsec connection to Azure │ │
│ │ │ │
│ └────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
VPN Tunnel Flow:
1. Azure VM (172.16.0.7) sends packet to OCI VM (10.0.100.17)
2. Azure routing table directs to VPN VM (172.16.0.5)
3. VPN VM encrypts with IPsec (AES256-SHA1)
4. Encrypted packet transits internet to OCI VM (130.61.50.28)
5. OCI VPN VM (10.0.100.5) decrypts
6. Packet delivered to destination (10.0.100.17)
This comprehensive guide demonstrates:
The resulting architecture provides a solid foundation for multi-cloud deployments, centralized management, and secure inter-cloud communication.
Key Resources:
Oracle Cloud Infrastructure provides powerful, flexible infrastructure for hybrid cloud architectures. This guide establishes the foundation for secure, scalable multi-cloud operations.