LAB 52 ‐ Establish hub and spoke onnectivity and validate custom image software in private instances. - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki

OCI Hub-and-Spoke Connectivity Using DRG and Custom Image Validation

Objective

The objective of this lab was to establish secure connectivity between Hub and Spoke VCNs using a Dynamic Routing Gateway (DRG), validate communication between instances, and verify that software installed on a hardened source VM was successfully inherited by a new private instance created from a Custom Image.


DRG vs LPG Overview

What is LPG (Local Peering Gateway)?

Local Peering Gateway (LPG) was used to connect two VCNs within the same OCI region.

Features

  • Connects VCNs in the same region.
  • Private communication between VCNs.
  • No internet traffic involved.
  • Simple VCN-to-VCN connectivity.

Limitations

  • Works only within the same region.
  • Requires separate LPGs in each VCN.
  • Not suitable for large-scale hub-and-spoke architectures.

Architecture

VCN-A  <-- LPG -->  VCN-B

What is DRG (Dynamic Routing Gateway)?

Dynamic Routing Gateway (DRG) is a virtual router used to connect VCNs with other OCI networks.

DRG supports:

  • Hub-and-Spoke Architecture
  • Remote Peering
  • Site-to-Site VPN
  • FastConnect
  • Cross-region connectivity

DRG Version 1

Features

  • Supported Remote Peering Connections (RPC).
  • Supported connectivity with on-premises networks.
  • Limited routing capabilities.
  • Less flexible route management.

Limitations

  • No advanced route distribution.
  • No centralized routing design.
  • Not ideal for complex architectures.

DRG Version 2 (Current Recommended Version)

DRG Version 2 introduced advanced routing and route distribution capabilities.

Features

  • Supports same-region VCN connectivity.
  • Supports cross-region VCN connectivity.
  • Supports Hub-and-Spoke architecture.
  • Multiple Route Tables.
  • Route Distribution.
  • Centralized network management.
  • Better scalability.

Benefits

Instead of using LPGs for same-region connectivity and RPCs for cross-region connectivity, a single DRG can now be used for both.

Architecture

                 DRG
                  |
    --------------------------------
    |              |              |
 Hub VCN       Spoke VCN-1    Spoke VCN-2

Lab Architecture

Hub VCN

Components

  • Public Subnet
  • Bastion / Jump Server
  • Public IP + Private IP
  • Hardened Source Instance

Spoke VCN

Components

  • Private App Subnet
  • Application Server
  • No Public IP
  • Created using Custom Image

High-Level Architecture

                         Internet
                             |
                        Bastion VM
                       (Hub VCN)
                             |
                             |
                            DRG
                             |
                             |
                  -----------------------
                  |                     |
             Spoke VCN             App Subnet
                                       |
                               spoke-swiggy-vm-01

Implementation Steps

Step 1 - Create Hub VCN

Created a Hub VCN containing:

  • Public Subnet
  • Bastion Jump Server
  • Internet Access

Step 2 - Create Spoke VCN

Created a separate Spoke VCN containing:

  • Private App Subnet
  • No Public IP

Step 3 - Harden the Bastion Server

Installed required software on the Bastion Server.

Apache Installation

sudo dnf install -y httpd

Zip Installation

sudo dnf install -y zip

Unzip Installation

sudo dnf install -y unzip

Step 4 - Create Custom Image

Created a custom image from the hardened Bastion Server.

Navigation:

Compute
→ Bastion Server
→ More Actions
→ Create Custom Image

Image Name:

bastion-jump-server-image

📸 Screenshot:

  • Custom Image Creation

image

Network Design

Hub VCN

Component CIDR
Hub VCN 10.0.0.0/24
Public Subnet 10.0.0.0/25
Private Subnet 10.0.0.128/25

Hub VCN Resources

Resource Purpose
Bastion Jump Server Administrative Access
DRG Attachment Connectivity to Spoke VCN

Dev Spoke VCN

Component CIDR
Dev Spoke VCN 10.0.1.0/24
App Subnet 10.0.1.0/26
Future Subnet 1 10.0.1.64/27
Future Subnet 2 10.0.1.96/27

Spoke VCN Resources

Resource Purpose
App Server (spoke-swiggy-vm-01) Private Application Server
DRG Attachment Connectivity to Hub VCN

Hub-and-Spoke Architecture

Hub VCN (10.0.0.0/24)
│
├── Public Subnet (10.0.0.0/25)
│      └── Bastion Jump Server
│
└── Private Subnet (10.0.0.128/25)

                │
                │
               DRG
                │
                │

Dev Spoke VCN (10.0.1.0/24)
│
├── App Subnet (10.0.1.0/26)
│      └── spoke-swiggy-vm-01
│
├── Future Subnet 1 (10.0.1.64/27)
│
└── Future Subnet 2 (10.0.1.96/27)

Routing Configuration

Hub VCN Public Subnet Route Table

Destination CIDR Target
10.0.1.0/26 DRG

Spoke dev app subnet Route Table

Destination CIDR Target
10.0.0.0/25 DRG

Security Rules

Hub public subnet security list

Allow communication to Spoke VCN:

Direction Protocol CIDR
Ingress TCP 22 (SSH) 122.168.64.153/32
Egress ICMP 10.0.1.0/26
Egress TCP 22 (SSH) 10.0.1.0/26

Note: SSH access to the Bastion Server is restricted to a specific public IP (193.122.143.52/32) instead of allowing access from the entire internet (0.0.0.0/0).

Security list of swiggy-dev-app-subnet

Allow communication from Hub VCN:

Direction Protocol CIDR
Ingress ICMP 10.0.0.0/25
Ingress TCP 22 10.0.0.0/25
Egress All Protocol 0.0.0.0/0

Step 1: Create DRG Networking → Dynamic Routing Gateways→ Create DRG

image image image image

Step 2: Attach Hub VCN to DRG

image

select the DRG that you have created by selecting the right compartment

image image

Step 3: Attach Spoke VCN to DRG

image image image image

Now if we go to Networking-> Customer connectivity->DRG-> select my DRG i.e Hub-Spoke-DRG-> Attachements

if we select the hub-network-compartment we can see the hub-vcn-attachment

image

if we select swiggy-dev-network-compartment we can see the spoke-swiggy-vcn-attachment

image

now we can say that the DRG has two VCN attachments: one attached to the Hub VCN and another attached to the Spoke VCN."

In the OCI Network Visualizer, by selecting the root compartment and all child compartments, we can view the DRG and all its VCN attachments, providing a complete picture of the hub-and-spoke network topology.

image

Phase 2: Route Table Configuration

Step 6: Hub App Subnet Route Table

click on hub-public-subnet

image

click on hub-route-table

image image

select DRG and in destination CIDR block give the CIDR of spoke app-subnet(select the CIDR of spoke app subnet from the network visualizer)

image image image

Step 7: Spoke App Subnet Route Table

image image

select DRG and in destination CIDR block give the CIDR of hub-public-subnet(select the CIDR of hub-public-subnet from the network visualizer)

image image image

Phase 3: Security Rules

Step 8: Hub Security Rules

Hub App Subnet Security List or in NSG : egress rule in hub public subnet security rule give the CIDR of app-subnet for ICMP

image

now ingress rule in app subnet security list give the CIDR of hub public subnet

image

ping is working fine

image image image image

The Network Path Analyzer reported "Ingress access control: Security not applicable" because the traffic was already blocked at the source (Hub) egress security rules and never reached the destination security evaluation stage.

image image image

getting the below error

image

change the permission and it worked and I successfully logged in to spoke vm

chmod 600 newprivatekey.pem
image

Telnet is also working

image

Reverse Ping Validation from Spoke VM to Hub VM

image

Reverse ICMP connectivity from the Spoke VM to the Hub VM is not working and requires further troubleshooting.

now we have to check the incoming (Ingress) security list of hub public subnet

adding the private app subnet CIDR and protocol ICMP

image

now ping is working fine

image

Reverse Connectivity Validation

To validate bidirectional communication, ICMP connectivity was also tested from the Spoke VM to the Hub Bastion Server.

ping 10.0.0.54

Result:

31 packets transmitted, 31 received, 0% packet loss

Validation Successful

This confirmed that routing and security rules were correctly configured in both directions between the Hub and Spoke VCNs.

Validating Software and Hardening Inheritance on the Spoke VM Created from the Custom Image

unzip -v
image
zip -v
image
sudo systemctl status httpd
image

The validation confirms that all required software packages were successfully inherited from the source custom image to the Spoke VM.

Troubleshooting Performed

Issue 1 - SSH Connection Hanging

While attempting SSH connectivity from the Bastion Server to the private Spoke VM, the session continuously hung and never established a connection.

Investigation

Used OCI Network Path Analyzer to trace the network path.

Navigation:

Networking
→ Network Path Analyzer

Root Cause

Missing TCP egress rule in the Security List.

Resolution

Added the required TCP egress rule and re-tested connectivity.

  • Network Path Analyzer Result
  • Security List Update

Issue 2 - SSH Key Authentication Failure

After fixing the routing and security issue, SSH still failed.

Error:

Permission denied (publickey)

Root Cause

Incorrect private key was being used.

Resolution

Created a new PEM file and copied the correct private key content.

mkdir keys
cd keys
vi newprivatekey.pem
chmod 600 newprivatekey.pem

Successfully connected using:

ssh -i newprivatekey.pem [email protected]
  • Successful SSH Login

Connectivity Validation

ICMP Validation

From Bastion Server:

ping 10.0.1.30

Result:

0% Packet Loss

✅ Successful


SSH Validation

ssh -i newprivatekey.pem [email protected]

Result:

[opc@spoke-swiggy-vm-01 ~]$

✅ Successful


Custom Image Validation

A new private instance was launched using the custom image created from the hardened Bastion Server.

Instance Name:

spoke-swiggy-vm-01

Apache Validation

rpm -qa | grep httpd

Result:

httpd
httpd-core
httpd-tools
httpd-filesystem

✅ Successful


ZIP Validation

zip -v

✅ Successful


UNZIP Validation

unzip -v

✅ Successful


Combined Validation

rpm -qa | egrep 'httpd|zip|unzip'

Result:

httpd packages found
zip package found
unzip package found

✅ Software successfully inherited from Custom Image


Validation Summary

Validation Item Status
DRG Created ✅
Hub VCN Attached ✅
Spoke VCN Attached ✅
Route Tables Configured ✅
Security Lists Configured ✅
ICMP Connectivity ✅
SSH Connectivity ✅
Custom Image Created ✅
Spoke VM Created ✅
Apache Validation ✅
Zip Validation ✅
Unzip Validation ✅
Software Inheritance Verified ✅

Bidirectional connectivity between the Hub and Spoke VCNs was successfully established and validated using ICMP (Ping), TCP (Telnet), and SSH connectivity tests through the DRG." 🚀

✅ Spoke VM → Hub VM ICMP Working ✅ Hub VM → Spoke VM ICMP Working ✅ DRG Routing Working in Both Directions ✅ Security Lists Correctly Configured ✅ Bidirectional Connectivity Verified


Conclusion

Successfully implemented a Hub-and-Spoke architecture using OCI DRG Version 2. Established secure connectivity between Hub and Spoke VCNs, validated routing and security configurations, resolved connectivity issues using Network Path Analyzer, and verified successful software inheritance by creating a Custom Image from a hardened Bastion Server and deploying a private application server from that image.

This implementation demonstrates OCI networking, routing, DRG connectivity, custom image management, troubleshooting, and validation of software inheritance in a secure private environment.

⚠️ **GitHub.com Fallback** ⚠️