Note:

Route Hub and Spoke VCN with pfSense Firewall in the Hub VCN

Introduction

Hub and spoke routing within a cloud provider can be confusing and hard to configure. To achieve this we need to configure multiple objects with different types of configuration. Network routing and network security across multiple levels inside the cloud make this confusing.

In this tutorial, we will explain how to configure a hub VCN with three-spoke VCNs. The hub VCN will contain the pfSense firewall and the connection to the internet and OCI services network. All network traffic originating from the spoke VCN that needs to communicate with other spoke VCNs or with the Internet or the OCI services network needs to pass the hub VCN for firewall inspection.

image

The following images illustrate the traffic flows.

Objectives

Task 1: Create the Hub and Spoke VCNs

Now, we will create three spoke VCNs (Spoke A, Spoke B, and Spoke C).

Task 2: Create the Subnets inside the Hub and Spoke VCNs

We have the hub and spoke VCNs in place. Now, create subnets inside the VCNs.

Create a Subnet inside Hub VCN

In the hub VCN we will create 1 private subnet and 1 public subnet.

Create a Subnet in Spoke VCN A

Create one private subnet inside the spoke VCN A.

Create a Subnet in Spoke VCN B

Create one private subnet inside the spoke VCN B.

Create Subnet inside Hub VCN C

Create one private subnet inside the spoke VCN C.

Task 3: Create a Dynamic Routing Gateway (DRG), Internet Gateway, and a NAT Gateway in the Hub VCN

Create a DRG that will be used to route traffic between the VCNs. We also need to create an internet gateway and a NAT gateway for our access to the Internet.

Task 4: Add Instances attached to different Subnets inside all VCNs

We will add various OCI Compute instances in all the VCNs so we can test out the routing flows.

Create Instance in Hub VCN

In the hub VCN, we will create a Windows compute instance that will have two main functions:

Windows Instance as Step Stone

To create a Windows instance (hub-step-stone) that can act as a stepping stone inside your OCI environment, use Deploy a Windows Instance in Oracle Cloud Infrastructure.

Note: Create the Windows stepping stone instance (hub-step-stone) before you continue with the tutorial.

The following image illustrates the visual representation of what you have created so far.

image

Create Instance in Hub VCN Spoke VCN A

In the spoke VCN A, we will create a simple Linux instance that will act as a network endpoint that we can use to test our routing flows.

Spoke A Client Instance

Create Instance in Spoke VCN B

In the Spoke VCN B, we will create a simple Linux Instance that will act as a network endpoint that we can use to test our routing flows.

Spoke B Client Instance

Create Instance in Spoke VCN C

In the Spoke VCN C, we will create a simple Linux instance that will act as a network endpoint that we can use to test our routing flows.

Spoke C Client Instance

Task 5: Add a pfSense Firewall Instance in the Hub VCN

The last instance we need for our network setup is a firewall. For example, this can be any firewall like the OCI Network Firewall. In this tutorial, we will use the pfSense firewall.

To create a pfSense instance (hub-fw) which can act as a firewall inside your OCI environment, use this tutorial.

Note: Create the pfSense instance before you continue the tutorial.

The following image illustrates the visual representation of what you have created so far.

image

Task 6: Open Firewall Rules on the Security Lists

In an OCI environment, there are multiple layers of network security. By default, all ingress network traffic is blocked for most protocols and ports. To make testing with ping possible we will open the ICMP ports on the hub and spoke VCNs so that we can allow all ICMP traffic that is coming into the VCN.

Add Ingress Rule in Hub VCN

Add Ingress Rule in Spoke VCN A

Add Ingress Rules in Spoke VCN B

Add Ingress Rules in Spoke VCN C

Task 7: Configure Routing between the different VCNs and the Internet with Hub Firewall Inspection

We already have all the required components. Now, we need to configure routing. Before we can configure routing we need to first attach the VCNs to the DRG.

After this, we will create the attachments that we need to create different VCN routing tables, DRG routing tables and to associate these routing tables to different VCNs, DRG VCN attachments, subnets, and gateways.

Task 7.1: Create VCN Attachments on DRG

Task 7.2: Create and Configure Spoke VCN Routing Tables

We need to create two types of routing tables: VCN Routing Tables and DRG Routing Tables.

Note: By default when you create a VCN, a default routing table is created.

Task 7.3: Create and Configure Hub VCN Routing Tables

Task 7.4: Create and Configure DRG Routing Tables

Task 7.5: Attach the Route Tables

Now that we have created route tables, we need to attach the route tables to the DRG, VCNs, subnets, and gateways.

Note: This is where routing is activated, so this is a careful process that needs to be thought of first and properly tested before you implement or make changes in a Production environment.

Attach the DRG Route Tables:

Let us first attach the DRG routing tables.

Attach DRG Routing Tables to the Spoke VCN Attachments

Routing Information: (DRG_RT_SPOKE_VCN_2) This DRG route table and route table attachment will make sure that all traffic that is coming from the spoke VCNs, is now routed to the hub VCN.

First, we are going to attach the ()DRG_RT_SPOKE_VCN_2) DRG Routing table to all the spoke VCN attachments.

Attach DRG Routing Tables to the Hub VCN Attachment

We will attach the ()DRG_RT_HUB_VCN_3) DRG route table to the hub VCN attachment. We are also going to attach the (VCN_HUB_RT_DRG_TRANSIT) VCN route table to the hub VCN attachment.

Routing Information: (DRG_RT_HUB_VCN_3) This DRG route table and route table attachment will make sure that all networks from the spokes are known on the DRG and learned on the DRG so that the DRG knows what networks are available on the spokes and so it knows where to route the spoke networks to.

Routing Information: (VCN_HUB_RT_DRG_TRANSIT) This VCN route table and route table attachment will make sure that all traffic is routed to the firewall in the hub.

Attach the VCN Route Tables:

Now, we are going to attach the VCN route tables even though we already started doing this for one of the VCN route tables in the previous task.

Attach VCN Routing Tables to the Hub VCN Public Subnet

Attach the (VCN_RT_HUB_PUBLIC_SUBNET) VCN route table to the the public subnet in the hub VCN.

Routing Information: (VCN_RT_HUB_PUBLIC_SUBNET) This VCN route table will route traffic that is destined for the spokes to the firewall. Traffic that is destined to the internet (all traffic other than spoke networks) to the internet gateway will also be routed by this route table.

Attach VCN Routing Tables to the Hub VCN Private Subnet

Next, we are going to attach the (VCN_RT_HUB_PRIVATE_SUBNET) VCN route table to the private subnet in the hub VCN.

Routing Information: (VCN_RT_HUB_PRIVATE_SUBNET) This VCN route table will route traffic that is destined for the spokes to the firewall. Traffic that is destined to the internet (all traffic other than spoke networks) to the NAT gateway will also be routed by this route table.

Attach VCN Routing Tables to the Hub VCN NAT Gateway

Attach the (VCN_HUB_RT_NAT_TRANSIT) VCN route table to the NAT gateway in the hub VCN.

Routing Information: (VCN_HUB_RT_NAT_TRANSIT) This VCN route table will route traffic that is destined for the spokes to the firewall.

Attach VCN Routing Tables to the Spoke VCN Private Subnets

We already configured the default spoke VCN routing tables in one of the previous tasks. The spoke (A, B, and C) private subnets will automatically use the default VCN route table and there is no need to change this. We can do a quick check.

Go to the OCI Console, navigate to Networking and Virtual cloud Networks.

Task 8: Verify the Connectivity

The routing is configured for the full environment. Now, we can test if routing is working.

Task 8.1: Connect to the Spoke Step Stone Instance with RDP

We connect to the Windows stepping stone using RDP through the internet. The traffic will be routed through the internet gateway.

image

When you are successfully connected, you will be able to see the desktop. From this desktop, we will perform some ping tests and perform management on the pfSense hub firewall.

image

Task 8.2: Ping from Hub VCN to Spoke VCN

The first ping test that we are going to do is from the hub-step-stone to the spoke VCN instances.

Task 8.3: Connect to the Spoke Instances with SSH

The ping (ICMP) is working in Task 8.2. Now, let us connect to the spoke instances with SSH because we also need to perform some connectivity tests from the spoke instances.

Issue: SSH sessions are terminated after a few seconds. We noticed that the SSH connections were dropping after approximately 10 seconds and we troubleshooted this issue on multiple levels. We checked the security lists in OCI, routing in OCI, and the firewall rules in the pfSense. Eventually, we found that the SSH drops issue is related to pfSense.

Task 8.4: Ping from Spoke VCN to Hub VCN

Now, we have a stable connection from the spokes we can perform some ping tests from the spoke VCN instances.

Task 8.5: Ping from Spoke VCN A to Spoke VCN B

Another ping test we can do is from one spoke to another spoke.

Task 8.6: Ping from Spoke VCN to the Internet

Perform some ping tests from the spoke VCN instances towards the internet.

Task 8.7: Connect from Spoke VCN to the Internet

We have done a basic ping test. Now, we need to open up the hub VCN ingress security list to allow all TCP traffic towards the internet because our firewall inspection is done by the pfSense firewall and it does not make sense to have multiple layers of firewall security unless this is the requirement.

Update the Hub VCN Security List

Go to the OCI Console, click Networking and Virtual cloud Networks.

Verify the pfSense Firewall

The software installation and upgrading or a compute instance that is based on Oracle Linux is not done through the Internet.

To install software on an Oracle Linux instance, Oracle only allows to do this from their software repositories and these are reachable using the Service Gateway.

Our next and last task is to create a service gateway and configure routing to route the traffic for the Oracle services through that new service gateway.

Task 8.8: Allow the Linux Instances to Install and Update Software using the Service Gateway

We have not configured routing for OCI services yet.

Network Visualizer

We can use the Network Visualizer tool to get a graphical view of the hub and spoke VCNs with the DRG.

image

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.