Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

Cách lấy danh sách bảo mật mạng (Network Security List / Security Lists) trong OCI/Azure

Security List là gì? (Oracle Cloud Infrastructure - OCI)

Security List trong OCI là tập hợp các quy tắc (rules) kiểm soát traffic ingress (vào) và egress (ra) áp dụng cho tất cả VNIC trong một Subnet. Mỗi Subnet có thể gán tối đa 5 Security Lists.

Network Security Group (NSG) là gì?

Đặc điểmSecurity List (OCI)Network Security Group - NSG (OCI/Azure)
Áp dụng choCả Subnet (tất cả VNIC)Nhóm VNIC cụ thể (chọn lọc)
Độ chi tiết (Granularity)Coarse-grainedFine-grained
StatefulCó (mặc định)Có (mặc định)
Số lượng rule tối đaTùy quota tenancyOCI: 1200/NSG | Azure: 200 mặc định, 1000 với support ticket
Ưu tiênRule priority (thấp hơn = ưu tiên cao hơn)Priority number (thấp hơn = ưu tiên cao hơn)

Ingress vs Egress

  • Ingress: Traffic vào VNIC/Subnet (ví dụ: cho phép TCP 443 từ Internet vào Web Server)
  • Egress: Traffic ra khỏi VNIC/Subnet (ví dụ: cho phép Server truy cập Internet cập nhật package)

Cấu trúc Rule (OCI & Azure)


// OCI Security List Rule
{
  "direction": "INGRESS",           // hoặc EGRESS
  "protocol": "6",                  // TCP=6, UDP=17, ICMP=1, All=all
  "source": "0.0.0.0/0",            // CIDR source (INGRESS) hoặc destination (EGRESS)
  "sourceType": "CIDR_BLOCK",       // CIDR_BLOCK, SERVICE, NETWORK_SECURITY_GROUP
  "tcpOptions": {                   // nếu TCP/UDP
    "destinationPortRange": { "min": 443, "max": 443 }
  },
  "isStateless": false,             // true = stateless (cần rule 2 chiều)
  "description": "Allow HTTPS from Internet"
}

Mặc định của Security List (OCI)

  • Mặc định: DENY ALL (chặn tất cả ingress & egress)
  • Phải thêm rule ALLOW rõ ràng cho traffic cần thiết
  • Rule ưu tiên thấp hơn (số lớn hơn) được đánh giá sau

Tạo Security List / NSG

OCI Console

  1. Menu → Networking → Virtual Cloud Networks → Chọn VCN
  2. Resources → Security Lists → Create Security List
  3. Nhập Name, Compartment, Thêm Ingress/Egress Rules
  4. Create → Gán vào Subnet (Subnet → Edit → Security Lists)

Azure Portal (NSG)

  1. Search "Network Security Groups" → Create
  2. Subscription, Resource Group, Name, Region
  3. Create → Vào NSG → Inbound/Outbound security rules → Add
  4. Gán NSG vào Subnet hoặc Network Interface (NIC)

Application Security Group (ASG) - Azure

ASG cho phép gom nhóm VM theo ứng dụng (ví dụ: "WebTier", "AppTier", "DBTier") và viết rule NSG tham chiếu ASG thay vì IP/CIDR – dễ quản trị khi scale out/in.

Best Practices

  • Ưu tiên NSG hơn Security List (OCI) – linh hoạt, granular hơn
  • Naming convention: nsg-[env]-[app]-[tier] (vd: nsg-prod-web-fe)
  • Default deny → Explicit allow (least privilege)
  • Tách rule theo protocol/port rõ ràng, có description
  • Dùng Service Tags (Azure) / Service CIDR (OCI) thay vì hardcode IP cloud provider
  • Audit định kỳ: nsgs without rules, overly permissive rules (0.0.0.0/0 trên port 22/3389)
  • Log flow (NSG Flow Logs Azure / VCN Flow Logs OCI) → SIEM

Tóm tắt: Lấy danh sách Security List/NSG

Nền tảngCLI Command
OCIoci network security-list list --compartment-id --vcn-id
Azureaz network nsg list --resource-group --output table
AWS (Security Group)aws ec2 describe-security-groups --region