Saturday, August 2, 2025

Securing Oracle Cloud Linux Instances: Security Lists vs Network Security Groups (NSGs)

 

๐Ÿ”น Introduction

When launching Oracle Linux compute instances or database systems in Oracle Cloud Infrastructure (OCI), security is a top priority. Two critical features that control network access in OCI are:

  • ๐Ÿ”ธ Security Lists

  • ๐Ÿ”ธ Network Security Groups (NSGs)

Many admins and even some Oracle DBAs are unclear about when to use which. In this post, I’ll explain both in a simple, real-world scenario that applies directly to database environments.

๐Ÿ”น What You'll Learn

  • What are Security Lists and NSGs

  • Key differences between the two

  • Best use cases for each

  • A working example: Allowing access to Oracle DB port 1521

  • My personal recommendation as a DBA

๐Ÿ”น 1. What is a Security List?

A Security List is attached to a Subnet in OCI. All compute instances in that subnet inherit its rules.

Example Rule:
Allow Ingress TCP Port 22 from CIDR 0.0.0.0/0 (for SSH access)

๐Ÿ”น 2. What is a Network Security Group (NSG)?

An NSG is like a mini-firewall attached to a specific instance or resource, not to the whole subnet.

It gives resource-level granularity, especially useful when multiple DB or app servers are in the same subnet.

๐Ÿ”ธ Key Differences

FeatureSecurity ListNetwork Security Group (NSG)
Attached ToSubnetIndividual resources (VM, DB System)
GranularityBroad (all in subnet)Fine-grained (specific resource)
Rule ChangesAffects all in subnetOnly affects attached resource
Use CaseSimpler setupsSecure and complex architectures
Default for DB SystemsOften not editableFully supported and flexible

๐Ÿ”น 3. Real-World Use Case: Allow DB Port 1521 for a Specific App Server

๐Ÿ”ง Scenario: You want to allow only one application server to access the DB port 1521 on your Oracle Database system in OCI.

✅ Option 1: Security List Approach

  • Add Ingress Rule:

    • Protocol: TCP

    • Port: 1521

    • Source CIDR: <AppServer-IP>/32

๐Ÿ”ด Problem: Any other compute instance in the subnet can also use this rule.

✅ Option 2: NSG Approach (Recommended)

  • Create NSG: nsg-db-access

  • Add Ingress Rule:

    • Protocol: TCP

    • Port: 1521

    • Source: Another NSG (e.g., nsg-app-server)

  • Attach this NSG only to the DB instance

✔️ Advantage: Only the app server can talk to the DB. More secure and flexible.

๐Ÿ”น 4. How to Create NSGs (via Console)

  1. Go to NetworkingNetwork Security Groups → Create

  2. Name: nsg-db-access

  3. Add rule: Ingress TCP Port 1521 from nsg-app-server

  4. Attach this NSG to your DB system under its Network settings

๐Ÿ”น Best Practices

  • ✅ Use NSGs for DB systems, always

  • ✅ Create separate NSGs for App, DB, Web tiers

  • ✅ Keep Security Lists for basic subnet rules like SSH

  • ๐Ÿšซ Avoid using wide CIDR blocks (0.0.0.0/0) for database ports

๐Ÿ’ก Vignesh’s Tip

You can automate NSG rule creation using OCI CLI:

oci network nsg-rule add --nsg-id ocid1.networksecuritygroup.oc1... \ --direction INGRESS --protocol 6 --is-stateless false \ --source-type NETWORK_SECURITY_GROUP --source-id ocid1.networksecuritygroup.oc1... \ --tcp-options '{"destinationPortRange": {"min": 1521, "max": 1521}}'

This is very useful when provisioning resources via scripts or Terraform.

๐Ÿ”น Conclusion

Security Lists and NSGs both play crucial roles in OCI, but understanding their differences helps you build secure and modular cloud environments. For Oracle DBAs, using NSGs for database port control is a best practice.

No comments:

Post a Comment

Auto Shutdown and Restart of Oracle DB Systems in OCI Using Functions

  ๐Ÿ”น Introduction Oracle Cloud Infrastructure (OCI) Database Systems incur compute costs even when idle. If you're running non-producti...