Build Network Security Group rules with CIDR and NSG source references.
Last verified: May 2026
Build NSG ingress and egress security rules with CIDR, NSG source/destination references.
Required Fields
compartmentIdvcnIddisplayNamesecurityRulesOutput will appear here...Your team is replacing flat security list rules with NSG-based segmentation for a 50-instance production VCN. The builder generates 4 NSGs (web, app, db, mgmt) with NSG-reference rules between tiers (web → app → db). The transformation: instead of CIDR-based rules that need updates whenever IPs change, you now have rules that automatically include new instances based on NSG membership. Adding a new app server: just attach it to the app-tier NSG. The rules apply automatically.
Network Security Groups (NSGs) in OCI provide VNIC-level security rules that are more granular than subnet-level security lists. Unlike security lists that apply to all VNICs in a subnet, NSGs can be attached to specific VNICs — individual compute instances, load balancers, or database systems. Each NSG contains up to 120 ingress and egress rules, and a VNIC can belong to up to five NSGs. This builder helps you construct NSG rules with correct source/destination types (CIDR, NSG, or service), protocol settings, and stateful/stateless flags.
The builder constructs OCI Network Security Group rules with: direction (INGRESS/EGRESS), protocol number (6=TCP, 17=UDP, 1=ICMP, 'all'), source or destination type (CIDR_BLOCK / NETWORK_SECURITY_GROUP / SERVICE_CIDR_BLOCK), source/destination value, port ranges (TCP/UDP only), ICMP type and code (ICMP only), stateful flag, and description. Output is oci CLI commands and Terraform oci_core_network_security_group_security_rule resources.
NSG-to-NSG references (rather than CIDR-based rules) are the killer OCI feature. Define a 'web-tier' NSG and an 'app-tier' NSG, then create a rule on app-tier NSG saying 'allow port 8080 from web-tier NSG'. Add new web instances to the NSG and they automatically get access — no rule changes needed.
OCI's 5-NSG-per-VNIC limit is enforced strictly. Plan NSG composition carefully: 1 baseline NSG for common rules + 1-2 application-specific NSGs is typical. Don't try to use NSGs as fine-grained access tokens — that pattern hits the limit fast.
Always name NSGs with a clear scheme like '{env}-{tier}-nsg' (e.g., prod-web-nsg, prod-app-nsg). When you have 30+ NSGs across compartments, finding the right one in dropdowns becomes a real productivity drag without naming discipline.
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.