LAB 38 ‐ Create the hub VCN manually - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki

VCN Manual Setup: Public Subnet, Security Configuration, Internet Gateway, Route Table, and Instance Deployment

This lab demonstrates how to manually configure a VCN from scratch by creating and integrating all the required networking components, including a Public Subnet, Security List, Internet Gateway, Route Table, and Compute Instance. Once the setup is complete, connectivity tests are performed to validate the network configuration and ensure the instance is accessible.

📌 Important Architectural Note: Resource Lifecycle Management

  • Deletion (Bottom-Up Approach): When destroying the infrastructure, always follow a bottom-up approach (delete from the most dependent resource to the independent one).
    • Sequence: Compute Instance ➡️ Subnets ➡️ Custom Security Lists / Route Tables ➡️ Internet Gateway ➡️ VCN.
  • Creation (Top-Down Approach): When provisioning the infrastructure from scratch, always follow a top-down approach (create independent foundational resources first so they can be attached to subsequent ones).
    • Sequence: VCN ➡️ Internet Gateway ➡️ Custom Security List ➡️ Custom Route Table (with rules) ➡️ Public Subnet ➡️ Compute Instance.

Create a Custom VCN

Since the VCN that was automatically created by OCI has been deleted, we will now create our own custom VCN.

  1. Navigate to Networking → Virtual Cloud Networks (VCN) and click Create VCN.
  1. Enter the VCN Name and IPv4 CIDR Block, then click Create VCN to provision the Virtual Cloud Network.

Add tag also

  1. As shown below, the hub-network VCN has been successfully created.
  1. Now, we will add all the networking components required for the server to communicate within and outside the VCN.

Create Networking Components Create a Custom Internet Gateway Create a Custom Route Table (RT) Create a Custom Security List (SL) Create a Custom Internet Gateway

  1. The first step is to create a custom Internet Gateway, which will enable internet connectivity for resources deployed within the VCN.
  1. After creating the Internet Gateway, the next step is to create a Custom Security List (SL). The Security List acts as a virtual firewall and controls the inbound (Ingress) and outbound (Egress) traffic for resources within the subnet.

Navigate to Networking → Virtual Cloud Networks (VCN) → hub-network → Security Lists, and click Create Security List. Enter the required details and create the Security List.

Create a Custom Route Table (RT)

After creating the Custom Security List, the next step is to create a Custom Route Table (RT). A Route Table defines how traffic is routed from the subnet to destinations inside or outside the VCN.

  1. Navigate to Networking → Virtual Cloud Networks (VCN) → hub-network → Route Tables, and click Create Route Table. Provide the required details and create the Route Table.

custom RT has been created.

Once created, you can add route rules to direct traffic through the appropriate gateway, such as the Internet Gateway.

The route rule has been successfully added to the custom route table, and the custom route table is now configured to route traffic according to the specified destination and target.

Create a Public Subnet

After creating the Internet Gateway, Security List, and Route Table, the next step is to create a Public Subnet.

  1. Navigate to hub-network VCN → Subnets, and click Create Subnet. Provide the required subnet details and proceed with the subnet creation. Once created, the subnet can be associated with the appropriate Route Table and Security List to enable public connectivity.

public subnet has been created successfully now.

Configure Security Rules and Validate the VCN

Next, we need to add the required Ingress and Egress security rules to the Security List so that traffic from the source can reach the server and the server can communicate with external networks.

  1. Adding Ingress and Egress security rules

Ingress and Egress security rules has been defined

Once the security rules are configured:

Create a compute instance in the public subnet. Verify that the instance is associated with the correct Security List and Route Table. Test network connectivity to validate that the VCN has been configured correctly.

This validation can be performed using connectivity tests such as ping, SSH, or telnet (for specific ports), depending on the security rules that have been configured.

We have successfully completed the VCN setup, created an instance, and verified the configuration by logging in to the server.