11.1 Layered Network Security: Security Lists, NSGs & Private Access to Services
Key Takeaways
Security Lists provide coarse subnet-level packet filtering applied to all attached VNICs, whereas Network Security Groups (NSGs) implement granular micro-segmentation directly at the VNIC level.
A subnet can have up to 5 security lists with up to 200 ingress and 200 egress rules each, while a VNIC can join up to 5 NSGs and each NSG holds up to 120 rules.
Stateful security rules automatically allow bidirectional response traffic via connection tracking, whereas stateless rules skip connection tracking, which Oracle suggests for very high-volume traffic.
NSG rules can use another NSG as the source or destination, so new instances added to a tier are covered without changing CIDR blocks.
A service gateway reaches Oracle services privately, and on-premises networks can use it through transit routing, but only a private endpoint gives a service its own private IP address in your subnet.
8.1 Layered Network Security: Security Lists, NSGs & Private Access to Services
Subnet-Level Filtering vs. VNIC Micro-Segmentation
In Oracle Cloud Infrastructure, network packet filtering can be enforced at two distinct logical boundaries: the Subnet boundary via Security Lists, or the Virtual Network Interface Card (VNIC) boundary via Network Security Groups (NSGs).
Security Lists (Subnet-Level)
Security Lists are assigned to entire subnets. When a Security List is attached to a subnet, its ingress and egress rules apply uniformly to every single VNIC provisioned within that subnet. An architect can associate up to 5 Security Lists with a single subnet.
While simple to configure for homogenous workloads, Security Lists impose significant design limitations:
- No Intra-Subnet Isolation: If a subnet contains both web servers and database instances, Security Lists cannot prevent a compromised web server from attacking the database on port 1521, because all instances inherit the same rules.
- Subnet Sprawl: To achieve tier-by-tier isolation using Security Lists, architects are forced to carve VCNs into numerous small subnets (e.g., Web Subnet, App Subnet, DB Subnet, Management Subnet), creating routing overhead and address space fragmentation.
Network Security Groups (VNIC-Level Micro-Segmentation)
Network Security Groups (NSGs) decouple security policies from network topology. An NSG consists of ingress and egress security rules applied directly to individual VNICs, regardless of which subnet the VNIC resides in. An architect can attach up to 5 NSGs to a single VNIC.
NSGs provide decisive architectural advantages:
- Micro-Segmentation: Compute instances, load balancers, and database systems residing in the exact same subnet can belong to distinct NSGs with entirely different security postures.
- Simplified Subnet Architecture: Workloads can reside within large, consolidated subnets (e.g., a single
/22subnet across an entire Availability Domain), with security boundaries defined logically via NSGs.
Using NSGs as Rule Sources and Destinations
The most useful capability of network security groups is that a rule can reference another NSG (or the same NSG) instead of a CIDR block. In a traditional Security List, the source or destination of a rule must be a static CIDR block (e.g., 10.0.1.0/24) or an OCI Service CIDR label.
In contrast, an NSG rule can specify another NSG as its source or destination:
- Application Tier Rule: Ingress rule in
DB-Tier-NSGallowing TCP port 1521 where the source isApp-Tier-NSG. - Dynamic Autoscaling: When an autoscaling instance pool launches new application servers, each new VM's VNIC is automatically attached to
App-Tier-NSG. The database instances immediately accept connections from the new VM without requiring any manual IP updates or CIDR modifications. - Zero Hardcoded IPs: Eliminates operational dependencies on static IP assignments and protects against IP address re-use vulnerabilities.
Stateful vs. Stateless Filtering & Connection Tracking Limits
Both Security Lists and NSGs allow configuring rules as either Stateful (the default) or Stateless:
Stateful Rules
- Connection Tracking: When a packet matches a stateful ingress rule, the hypervisor's virtual switch records the session in an internal connection tracking table. Return response traffic is automatically permitted, regardless of egress rules.
- Use Cases: Standard web applications, database queries, API services, and general enterprise workloads where bi-directional communication is required.
Stateless Rules
- No Connection Tracking: The hypervisor bypasses the state tracking table entirely. Every packet is evaluated independently. To permit communication, the architect must write explicit matching rules in both directions (ingress and egress), including specifying the client ephemeral port range (typically TCP/UDP ports 32768–65535).
- Use Cases: High-performance computing (HPC), big data streaming (billions of concurrent connections), and DDoS mitigation. Stateless rules eliminate hypervisor state table memory exhaustion and deliver maximum packet-per-second (PPS) throughput with minimum hypervisor latency.
Operational Quotas & Scale Limits
- Security Lists: Up to 5 security lists per subnet and up to 300 per VCN; each security list holds up to 200 ingress and 200 egress rules.
- Network Security Groups: A VNIC can belong to up to 5 NSGs; each NSG holds up to 120 rules (ingress and egress combined). These limits cannot be increased.
Defense-in-Depth: Combining Security Lists and NSGs
OCI evaluates Security Lists and NSGs in parallel using a union of permissive rules model. If a packet is allowed by ANY attached Security List rule OR ANY attached NSG rule, the packet is accepted.
Enterprise architectures implement a layered defense-in-depth model:
- Layer 1: Security Lists for Subnet Hygiene: Use a baseline subnet Security List to enforce organization-wide hygiene. Rules allow OCI internal infrastructure traffic (DHCP, OCI DNS resolver on
169.254.169.254:53), administrative bastion SSH from management subnets, and ICMP Type 3 Code 4 (Path MTU Discovery). - Layer 2: NSGs for Application Micro-Segmentation: Use NSGs attached to specific workload VNICs to restrict business application traffic (e.g., HTTPS port 443, microservice gRPC ports, Oracle SQLNet port 1521).
PaaS Private Connectivity: Private Endpoints vs. Service Gateways
By default, OCI Platform-as-a-Service (PaaS) offerings—such as Autonomous Database, OCI Streaming, OCI Analytics Cloud, and OCI Data Integration—reside within the secure Oracle Services Network and present public IP addresses. Enterprise security policies mandate that databases and message brokers never expose public endpoints.
Architects must select between two private access mechanisms:
1. Service Gateway (SGW)
- Mechanics: A virtual gateway on the VCN boundary that routes traffic privately to the Oracle Services Network using Service CIDR labels (e.g.,
All REGION Services in Oracle Services NetworkorOCI REGION Object Storage). - Traffic Flow: Packets remain entirely within Oracle's private network fabric and never traverse the public internet.
- On-Premises Access: On-premises networks connected through a DRG can also reach Oracle services through the VCN's service gateway, a transit routing pattern Oracle calls private access to Oracle services.
- What it does not do: The service still uses its public service endpoint. The service gateway changes the path, not the address, so the service is not placed in your subnet and cannot carry your NSGs.
2. Private Endpoints (PE)
- Mechanics: A Private Endpoint projects the PaaS service directly into a customer-specified private subnet within the VCN. OCI allocates a Virtual Network Interface Card (VNIC) and assigns a genuine private RFC 1918 IP address (e.g.,
10.0.3.15) from the subnet to the service. - Full Transit Routing & Hybrid Access: Because the PaaS resource possesses a native private IP inside the customer subnet, traffic can reach it from:
- Local compute instances in the VCN.
- Remote on-premises data centers via FastConnect or IPsec VPN terminated at a DRG v2.
- Peered VCNs across the region or cross-region via RPC.
- Name Resolution: The service's hostname resolves to the private endpoint IP inside the VCN, so applications keep using the normal TLS connection string. On-premises clients need DNS forwarding to the VCN resolver to resolve the same name.
- NSGs on the endpoint: You can attach NSGs to the private endpoint and allow only specific application tiers. For example, an Autonomous AI Database with a private endpoint can allow port 1522 only from the application NSG.
Architectural Comparison: Security & Private Access Mechanisms
| Feature / Dimension | Security Lists | Network Security Groups (NSGs) | Service Gateway (SGW) | Private Endpoints (PE) |
|---|---|---|---|---|
| Enforcement Point | Subnet boundary (all VNICs inherit) | VNIC boundary (per-instance assignment) | VCN edge gateway | Dedicated VNIC inside private subnet |
| Granularity | Coarse; broadcast domain level | Granular; workload micro-segmentation | Broad; all PaaS or Object Storage | Resource-specific (individual database/stream) |
| Rule Targets | IPv4/IPv6 CIDR, Service CIDRs | CIDRs, Service CIDRs, Other NSGs | Service CIDR labels | Customer subnet RFC 1918 Private IP |
| Dynamic Scaling | Requires updating CIDR ranges | NSGs can be rule sources and destinations | Automatic route table updates | Dynamic Private DNS zone mapping |
| Hybrid Access | Enforces rules on hybrid traffic | Enforces rules on hybrid traffic | Yes, through transit routing (private access to Oracle services) | Yes, routed to the private IP over FastConnect or VPN |
| Connection Tracking | Supports stateful and stateless | Supports stateful and stateless | N/A (Gateway routing) | Supports NSGs attached directly to PE VNIC |
On-premises analysts reach OCI over FastConnect and must query a new Autonomous AI Database. Security policy says the database must have no public endpoint at all, and only the analytics subnet and the on-premises network may connect. A junior engineer proposes using a service gateway. What should the architect choose and why?
A service gateway, because it gives the database a private IP address inside the VCN
An internet gateway with IPSec, because Autonomous AI Database cannot use FastConnect
A private endpoint with an NSG, because a service gateway keeps the public endpoint
A service gateway, because on-premises traffic cannot use transit routing through a VCN
An architect is designing a multi-tier web application hosted within a single VCN subnet (10.0.1.0/24) to conserve address space. The subnet contains public load balancers, web application compute instances, and backend database instances. Corporate security governance mandates that web instances can only accept traffic from the load balancer on port 443, database instances can only accept traffic from web instances on port 1521, and all instances must accept SSH on port 22 exclusively from a corporate bastion subnet. How should the architect implement this security architecture without deploying additional subnets?
A baseline security list for bastion SSH, plus Web and DB NSGs whose rules use NSGs as sources
Three security lists on the subnet, one per port, with alias tags on each instance
A third-party firewall appliance in the same subnet, with all OCI security lists and NSGs disabled
Stateless subnet rules plus CIDR-based route rules in the VCN's route table for each tier
Sections you finish are checked off in the contents.