Ngân hàng đề — Google Cloud Professional Cloud Network Engineer

Tìm thấy 247 câu.

Câu 111
Your company has defined a resource hierarchy that includes a parent folder with subfolders for each department. Each department defines their respective project and VPC in the assigned folder and has the appropriate permissions to create Google Cloud firewall rules. The VPCs should not allow traffic to flow between them. You need to block all traffic from any source, including other VPCs, and delegate only the intra-VPC firewall rules to the respective departments. What should you do?
  1. A Create a VPC firewall rule in each VPC to block traffic from any source, with priority 0.
  2. B Create a VPC firewall rule in each VPC to block traffic from any source, with priority 1000.
  3. C Create two hierarchical firewall policies per department's folder with two rules in each: a high-priority rule that matches traffic from the private CIDRs assigned to the respective VPC and sets the action to allow, and another lower-priority rule that blocks traffic from any other source.
  4. D Create two hierarchical firewall policies per department's folder with two rules in each: a high-priority rule that matches traffic from the private CIDRs assigned to the respective VPC and sets the action to goto_next, and another lower-priority rule that blocks traffic from any other source.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi này thuộc lĩnh vực Google Cloud Networking, cụ thể là quản lý VPC firewall rules và Hierarchical Firewall Policies (HFWP) trong môi trường resource hierarchy (cấu trúc phân cấp tài nguyên).

  • Bối cảnh: Công ty có một parent folder chứa các subfolder cho từng phòng ban (department). Mỗi phòng ban tạo project và VPC riêng trong subfolder của mình, đồng thời có quyền tạo Google Cloud firewall rules chỉ dành cho intra-VPC (giao tiếp nội bộ trong cùng VPC).
  • Yêu cầu chính:
    • Block tất cả traffic từ bất kỳ nguồn nào (any source), bao gồm traffic từ các VPC khác (inter-VPC traffic).
    • Delegate (ủy quyền) chỉ các firewall rules intra-VPC cho từng phòng ban, nghĩa là họ có thể tự quản lý rules nội bộ VPC mà không ảnh hưởng đến traffic từ ngoài.
    • Đảm bảo VPCs không cho phép traffic flow giữa chúng (không có kết nối peering hoặc route giữa các VPC).
  • Thách thức: Sử dụng VPC firewall rules thông thường chỉ kiểm soát traffic ingress/egress tại mức VPC, không hiệu quả để block toàn bộ external traffic một cách phân cấp. Cần giải pháp ở mức folder/project hierarchy để áp dụng policy chung, đồng thời cho phép rules cục bộ xử lý intra-VPC.
  • Giải pháp lý tưởng: Sử dụng Hierarchical Firewall Policies gắn ở mức folder, với quy tắc ưu tiên cao cho traffic nội bộ VPC (sử dụng goto_next để chuyển tiếp đến VPC rules), và quy tắc chặn tất cả traffic còn lại.

📘 Tài liệu tham khảo (cập nhật đến 2026):

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Create two hierarchical firewall policies per department's folder with two rules in each: a high-priority rule that matches traffic from the private CIDRs assigned to the respective VPC and sets the action to goto_next, and another lower-priority rule that blocks traffic from any other source.

Lý do:

  • 🛠️ Hierarchical Firewall Policies (HFWP) được áp dụng ở mức folder, tự động kế thừa xuống projects/VPCs con, override các VPC firewall rules ở mức ingress/egress.
  • Quy tắc 1 (high-priority, ví dụ pri 1000): Match source CIDR của VPC tương ứng (traffic intra-VPC), action goto_next → Chuyển tiếp đến các VPC firewall rules thông thường (do department quản lý), đảm bảo delegate intra-VPC rules mà không block nhầm.
  • Quy tắc 2 (lower-priority, ví dụ pri 2000): Deny all traffic từ nguồn khác (bao gồm other VPCs, internet, on-prem) → Block hoàn toàn inter-VPC và external traffic.
  • Ưu điểm: An toàn, phân cấp rõ ràng, không cần sửa VPC rules. Nếu peered VPCs, policy này vẫn block cross-VPC.

❌ Giải thích tất cả các phương án (đúng/sai)

  • [SAI] Create a VPC firewall rule in each VPC to block traffic from any source, with priority 0.

    • ❌ Sai vì: Priority 0 là cao nhất ( đánh giá đầu tiên), rule deny any source sẽ block toàn bộ traffic, bao gồm cả intra-VPC (traffic từ source CIDR nội bộ VPC). Không delegate được rules cho department, vì tất cả bị chặn ngay. VPC rules không hiệu quả block external nếu có routes/peering ngoài dự kiến.
  • [SAI] Create a VPC firewall rule in each VPC to block traffic from any source, with priority 1000.

    • ❌ Sai vì: Priority 1000 là thấp (đánh giá sau các rules cao hơn). Nếu department tạo rules pri thấp hơn (ví dụ 500 allow internal), rule deny này không block được. Không ngăn inter-VPC/external traffic đáng tin cậy, và không dùng hierarchy để quản lý phân cấp.
  • [SAI] Create two hierarchical firewall policies per department's folder with two rules in each: a high-priority rule that matches traffic from the private CIDRs assigned to the respective VPC and sets the action to allow, and another lower-priority rule that blocks traffic from any other source.

    • ❌ Sai vì: Quy tắc high-priority dùng allow từ VPC CIDR sẽ allow toàn bộ intra-VPC traffic mà không kiểm tra VPC rules (bỏ qua delegation). Department không thể tinh chỉnh intra-rules (ví dụ deny cụ thể giữa subnets). Chỉ goto_next mới chuyển tiếp đúng để VPC rules xử lý.
  • [ĐÚNG] Create two hierarchical firewall policies per department's folder with two rules in each: a high-priority rule that matches traffic from the private CIDRs assigned to the respective VPC and sets the action to goto_next, and another lower-priority rule that blocks traffic from any other source.

    • ✅ Đúng như giải thích ở phần trên: Kết hợp hoàn hảo block external/inter-VPC + delegate intra-VPC qua goto_next. Phù hợp best practices GCP 2026.

🛡️ Lưu ý triển khai: Gắn HFWP ở subfolder (Ingress policy), source_ranges = VPC CIDR cho rule 1, source_ranges=0.0.0.0/0 cho rule 2 deny. Test với gcloud compute firewall-rules.

Câu 112
You have two Google Cloud projects in a perimeter to prevent data exfiltration. You need to move a third project inside the perimeter; however, the move could negatively impact the existing environment. You need to validate the impact of the change. What should you do?
  1. A Enable Firewall Rules Logging inside the third project.
  2. B Modify the existing VPC Service Controls policy to include the new project in dry run mode.
  3. C Monitor the Resource Manager audit logs inside the perimeter.
  4. D Enable VPC Flow Logs inside the third project, and monitor the logs for negative impact.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi này thuộc chủ đề VPC Service Controls (VPC-SC) trong Google Cloud Platform (GCP), cụ thể là về Service Perimeter dùng để ngăn chặn data exfiltration (rò rỉ dữ liệu ra ngoài).

  • Tình huống: Bạn có hai project đã nằm trong một perimeter (rào chắn dịch vụ) để bảo vệ dữ liệu. Bây giờ, bạn muốn di chuyển project thứ ba vào perimeter này, nhưng lo ngại tác động tiêu cực đến môi trường hiện tại (ví dụ: chặn các kết nối hợp lệ, ảnh hưởng ứng dụng).
  • Yêu cầu: Xác thực (validate) tác động của thay đổi trước khi áp dụng thực tế, mà không gây gián đoạn.
  • Mục tiêu chính: Sử dụng cơ chế test an toàn để kiểm tra policy mà không enforce ngay lập tức. Đây là best practice trong VPC-SC để tránh downtime hoặc block traffic không mong muốn.

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Modify the existing VPC Service Controls policy to include the new project in dry run mode.

Lý do 🛠️:

  • VPC-SC hỗ trợ dry run mode (chế độ thử nghiệm) cho phép thêm project mới vào perimeter mà KHÔNG enforce policy ngay. Hệ thống sẽ log các vi phạm tiềm năng (violations) vào VPC-SC audit logs, giúp bạn phân tích tác động (như traffic bị block) trước khi kích hoạt enforced mode.
  • Điều này an toàn 100%, không ảnh hưởng môi trường hiện tại, và phù hợp validate impact khi mở rộng perimeter.
  • Theo docs GCP 2026, dry-run là recommended way để test changes lớn như thêm project.

📋 Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên tính phù hợp với yêu cầu validate impact khi thêm project vào perimeter.

  • ❌ Enable Firewall Rules Logging inside the third project.
    Sai vì: Firewall Rules Logging chỉ ghi log traffic qua firewall rules (allow/deny packets), không liên quan trực tiếp đến VPC-SC perimeter violations. Nó không simulate hoặc test policy perimeter, nên không validate được impact data exfiltration hoặc service access khi thêm project. Chỉ hữu ích cho network troubleshooting chung, không phải VPC-SC.

  • ✅ Modify the existing VPC Service Controls policy to include the new project in dry run mode.
    Đúng vì: Như đã giải thích ở trên, dry-run mode chính là công cụ chuẩn của VPC-SC để test thêm project mà chỉ log violations (không block thực tế). Bạn có thể monitor Policy Violations logs để xem impact tiêu cực, sau đó mới enforce. Hoàn hảo cho scenario này!

  • ❌ Monitor the Resource Manager audit logs inside the perimeter.
    Sai vì: Resource Manager audit logs chỉ ghi thay đổi resource (tạo/sửa/xóa project, folder), không capture runtime violations của VPC-SC như data access attempts. Nó không giúp validate tác động mạng/dữ liệu khi thêm project, chỉ theo dõi admin actions.

  • ❌ Enable VPC Flow Logs inside the third project, and monitor the logs for negative impact.
    Sai vì: VPC Flow Logs ghi network traffic chi tiết (src/dst IP, ports), hữu ích debug connectivity nhưng KHÔNG detect VPC-SC policy violations (như API calls bị block do perimeter). Không simulate thay đổi perimeter, nên không dự đoán chính xác impact khi di chuyển project.

Kết luận tổng quát 🎯: Dry-run mode là unique feature của VPC-SC dành riêng cho test perimeter changes, các option khác chỉ là logging network chung (không target data exfiltration protection). Luôn dùng dry-run trước khi enforce để zero-risk validation!

Câu 113
You are configuring an HA VPN connection between your Virtual Private Cloud (VPC) and on-premises network. The VPN gateway is named VPN_GATEWAY_1. You need to restrict VPN tunnels created in the project to only connect to your on-premises VPN public IP address: 203.0.113.1/32. What should you do?
  1. A Configure a firewall rule accepting 203.0.113.1/32, and set a target tag equal to VPN_GATEWAY_1.
  2. B Configure the Resource Manager constraint constraints/compute.restrictVpnPeerIPs to use an allowList consisting of only the 203.0.113.1/32 address.
  3. C Configure a Google Cloud Armor security policy, and create a policy rule to allow 203.0.113.1/32.
  4. D Configure an access control list on the peer VPN gateway to deny all traffic except 203.0.113.1/32, and attach it to the primary external interface.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào việc cấu hình kết nối HA VPN (High Availability VPN) giữa Virtual Private Cloud (VPC) trên Google Cloud và mạng on-premises. VPN gateway được đặt tên là VPN_GATEWAY_1. Yêu cầu chính là hạn chế các VPN tunnels được tạo trong project chỉ kết nối được với địa chỉ IP công khai của VPN on-premises: 203.0.113.1/32.

🛠️ Mục tiêu cụ thể: Ngăn chặn việc tạo VPN tunnels kết nối đến các IP peer khác ngoài địa chỉ được chỉ định. Đây là biện pháp bảo mật tổ chức (organization-level) để kiểm soát peer IP addresses khi thiết lập Cloud VPN tunnels, tránh rủi ro kết nối không mong muốn. Trong Google Cloud, HA VPN sử dụng hai tunnels (active/passive hoặc active/active) để đảm bảo tính sẵn sàng cao, nhưng cần cơ chế chính sách để restrict peer IPs từ cấp project hoặc organization.

📘 Kiến thức liên quan (cập nhật đến 2026): Theo tài liệu GCP mới nhất (Google Cloud Networking Documentation, phiên bản 2024-2026), Cloud VPN hỗ trợ Organization Policy constraints để kiểm soát các tài nguyên mạng, đặc biệt là constraints/compute.restrictVpnPeerIPs cho phép sử dụng allowList hoặc denyList để giới hạn remote peer IP addresses. Điều này áp dụng khi tạo VPN tunnels qua Cloud Router hoặc trực tiếp.

Nguồn tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Configure the Resource Manager constraint constraints/compute.restrictVpnPeerIPs to use an allowList consisting of only the 203.0.113.1/32 address.

Lý do chọn 🏆:

  • Constraint này được thiết kế chính xác để hạn chế địa chỉ IP peer (remote VPN endpoint) khi tạo VPN tunnels trong project hoặc organization. Bằng cách đặt allowList chỉ chứa 203.0.113.1/32, mọi nỗ lực tạo tunnel với peer IP khác sẽ bị từ chối ngay từ cấp policy, không phụ thuộc vào firewall hay cấu hình thủ công.
  • Đây là cách tự động và bắt buộc (enforced), áp dụng cho tất cả users/projects con, phù hợp với yêu cầu "restrict VPN tunnels created in the project". Không ảnh hưởng đến traffic đã established, chỉ kiểm soát lúc tạo.

📋 Giải thích tất cả các phương án (đúng/sai)

  • Phương án 1: Configure a firewall rule accepting 203.0.113.1/32, and set a target tag equal to VPN_GATEWAY_1.
    ❌ Sai vì: Firewall rules chỉ kiểm soát traffic flow (ingress/egress) sau khi tunnel đã được thiết lập, không ngăn chặn việc tạo VPN tunnels với peer IP không mong muốn. Target tag trên VPN gateway chỉ áp dụng cho traffic đến instance/gateway, không restrict peer IP lúc setup. Sử dụng firewall sẽ không giải quyết yêu cầu cốt lõi.

  • Phương án 2: Configure the Resource Manager constraint constraints/compute.restrictVpnPeerIPs to use an allowList consisting of only the 203.0.113.1/32 address.
    ✅ Đúng vì: Như giải thích ở trên, đây là Organization Policy constraint chuyên biệt (ra mắt từ 2022, cập nhật 2026 hỗ trợ IPv6 peers). Nó enforce allowList để chỉ cho phép peer IP cụ thể, ngăn tạo tunnels với IP khác ngay từ API/UI/CLI. Hoàn hảo cho kiểm soát organization-wide mà không cần can thiệp thủ công.

  • Phương án 3: Configure a Google Cloud Armor security policy, and create a policy rule to allow 203.0.113.1/32.
    ❌ Sai vì: Google Cloud Armor là công cụ L7 DDoS protection và WAF cho Load Balancers (HTTP/S), không áp dụng cho IPsec VPN tunnels (Layer 3). Nó không kiểm soát việc tạo tunnels hoặc peer IPs, mà chỉ filter traffic web/app. Áp dụng vào đây sẽ vô hiệu và không liên quan.

  • Phương án 4: Configure an access control list on the peer VPN gateway to deny all traffic except 203.0.113.1/32, and attach it to the primary external interface.
    ❌ Sai vì: "Peer VPN gateway" là thiết bị on-premises (không phải GCP), nên không thể cấu hình ACL từ Google Cloud. Hơn nữa, yêu cầu là restrict tunnels tạo trong project GCP, không phải traffic trên peer side. ACL trên peer chỉ kiểm soát traffic local, không ngăn tạo tunnel từ GCP side.

🧠 Tóm tắt insight: Sử dụng Organization Policies là best practice cho governance mạng trong GCP, đặc biệt với multi-project setups. Nếu triển khai, dùng gcloud org-policies set-policy để apply constraint! 🚀

Câu 114
Your company has recently installed a Cloud VPN tunnel between your on-premises data center and your Google Cloud Virtual Private Cloud (VPC). You need to configure access to the Cloud Functions API for your on-premises servers. The configuration must meet the following requirements:

•Certain data must stay in the project where it is stored and not be exfiltrated to other projects.
•Traffic from servers in your data center with RFC 1918 addresses do not use the internet to access Google Cloud APIs.
•All DNS resolution must be done on-premises.
•The solution should only provide access to APIs that are compatible with VPC Service Controls.

What should you do?
  1. A 1. Create an A record for private.googleapis.com using the 199.36.153.8/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Remove the default internet gateway from the VPC where your Cloud VPN tunnel terminates.
  2. B 1. Create an A record for restricted.googleapis.com using the 199.36.153.4/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Configure your on-premises firewalls to allow traffic to the restricted.googleapis.com addresses.
  3. C 1. Create an A record for restricted.googleapis.com using the 199.36.153.4/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Remove the default internet gateway from the VPC where your Cloud VPN tunnel terminates.
  4. D 1. Create an A record for private.googleapis.com using the 199.36.153.8/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Configure your on-premises firewalls to allow traffic to the private.googleapis.com addresses.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi xoay quanh việc cấu hình truy cập an toàn từ máy chủ on-premises (sử dụng địa chỉ RFC 1918) đến Cloud Functions API trên Google Cloud qua Cloud VPN tunnel kết nối với VPC. Các yêu cầu chính bao gồm:

  • Dữ liệu phải ở nguyên project, không được exfiltrate (rò rỉ) sang project khác → Sử dụng VPC Service Controls (VPC-SC) để kiểm soát biên giới dịch vụ.
  • Traffic từ on-premises không đi qua internet để truy cập Google APIs → Sử dụng Private Google Access hoặc Private Services Access với IP private.
  • Tất cả DNS resolution thực hiện on-premises → Tạo DNS records (A và CNAME) trên on-premises DNS server.
  • Chỉ cho phép APIs tương thích với VPC-SC → Sử dụng endpoint restricted.googleapis.com (dành riêng cho Restricted APIs trong VPC-SC), không dùng private.googleapis.com (dành cho Private APIs thông thường).

Giải pháp cần route traffic qua VPN tunnel, cấu hình DNS on-premises, và kiểm soát firewall để đảm bảo private routing mà không phụ thuộc internet gateway của VPC.
📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng là phương án thứ 2:

  1. Create an A record for restricted.googleapis.com using the 199.36.153.4/30 address range.
  2. Create a CNAME record for *.googleapis.com that points to the A record.
  3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
  4. Configure your on-premises firewalls to allow traffic to the restricted.googleapis.com addresses.

Lý do:

  • 🛠️ Sử dụng restricted.googleapis.com (199.36.153.4/30) để truy cập Restricted APIs (bao gồm Cloud Functions) qua VPC-SC, đảm bảo dữ liệu không exfiltrate và chỉ tương thích VPC-SC.
  • DNS on-premises (A + CNAME wildcard) resolve đúng IP private, traffic route qua VPN (không internet).
  • Firewall on-premises cho phép traffic đến restricted.googleapis.com → Kiểm soát chặt chẽ từ on-premises, không cần thay đổi VPC (như remove gateway).
  • Hoàn hảo khớp tất cả yêu cầu, theo best practices Google Cloud mới nhất (2026).

❌ Phân tích tất cả các phương án

Dưới đây là phân tích chi tiết từng phương án, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể:

  • Phương án 1 (SAI):

    1. Create an A record for private.googleapis.com using the 199.36.153.8/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Remove the default internet gateway from the VPC where your Cloud VPN tunnel terminates.
      Lý do sai: ❌ Sử dụng private.googleapis.com (199.36.153.8/30) chỉ cho Private APIs thông thường, không hỗ trợ VPC-SC (không ngăn exfiltrate dữ liệu). Remove internet gateway của VPC là không cần thiết và có thể phá vỡ traffic khác trong VPC; kiểm soát phải từ on-premises.
  • Phương án 2 (ĐÚNG): (Như đã giải thích ở trên) ✅ Hoàn chỉnh, an toàn, khớp yêu cầu.

  • Phương án 3 (SAI):

    1. Create an A record for restricted.googleapis.com using the 199.36.153.4/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Remove the default internet gateway from the VPC where your Cloud VPN tunnel terminates.
      Lý do sai: ❌ Dùng đúng restricted.googleapis.com (tốt cho VPC-SC), nhưng remove internet gateway không giải quyết yêu cầu (traffic on-premises không phụ thuộc gateway VPC) và có thể gây outage cho các dịch vụ khác trong VPC. Nên dùng firewall on-premises thay vì thay đổi VPC.
  • Phương án 4 (SAI):

    1. Create an A record for private.googleapis.com using the 199.36.153.8/30 address range.
    2. Create a CNAME record for *.googleapis.com that points to the A record.
    3. Configure your on-premises routers to use the Cloud VPN tunnel as the next hop for the addresses you used in the A record.
    4. Configure your on-premises firewalls to allow traffic to the private.googleapis.com addresses.
      Lý do sai: ❌ private.googleapis.com không tương thích VPC-SC (không ngăn exfiltrate, không dành cho Restricted APIs như Cloud Functions trong ngữ cảnh này). Firewall đúng vị trí nhưng endpoint sai → Không đáp ứng "chỉ APIs compatible with VPC-SC".

🧠 Tóm tắt key takeaway: Ưu tiên restricted.googleapis.com cho VPC-SC + kiểm soát on-premises để private, zero-trust access!

Câu 115
You need to configure a Google Kubernetes Engine (GKE) cluster. The initial deployment should have 5 nodes with the potential to scale to 10 nodes. The maximum number of Pods per node is 8. The number of services could grow from 100 to up to 1024. How should you design the IP schema to optimally meet this requirement?
  1. A Configure a /28 primary IP address range for the node IP addresses. Configure a /25 secondary IP range for the Pods. Configure a /22 secondary IP range for the Services.
  2. B Configure a /28 primary IP address range for the node IP addresses. Configure a /25 secondary IP range for the Pods. Configure a /21 secondary IP range for the Services.
  3. C Configure a /28 primary IP address range for the node IP addresses. Configure a /28 secondary IP range for the Pods. Configure a /21 secondary IP range for the Services.
  4. D Configure a /28 primary IP address range for the node IP addresses. Configure a /24 secondary IP range for the Pads. Configure a /22 secondary IP range for the Services.
Xem giải thích

🧩 Giải thích chi tiết nội dung câu hỏi

Câu hỏi yêu cầu thiết kế schema IP (phạm vi địa chỉ IP) tối ưu cho một cụm Google Kubernetes Engine (GKE) VPC-native (sử dụng alias IP). Cụm ban đầu có 5 node, có thể mở rộng lên 10 node, mỗi node tối đa 8 Pod, và số lượng Services có thể tăng từ 100 lên 1024.

  • Primary IP range: Dành cho địa chỉ IP của các node (máy ảo Compute Engine).
  • Secondary IP range cho Pods: Dành cho địa chỉ IP của các Pod (mỗi node được cấp một phần từ range này).
  • Secondary IP range cho Services: Dành cho Cluster IP của các Kubernetes Services (chia sẻ chung).

Mục tiêu là tối ưu (optimal): Đủ lớn để hỗ trợ quy mô, tuân thủ quy định kích thước range của GKE, tránh lãng phí IP, và hỗ trợ autoscaling. GKE có quy tắc nghiêm ngặt về kích thước CIDR (xem tài liệu tham khảo bên dưới):

  • Primary range cho node: Tối thiểu /28 (hỗ trợ ~11 node).
  • Pods secondary: Prefix length 9 đến 24 (tức /24 là nhỏ nhất, 256 IP; không cho phép /25 trở lên prefix vì quá nhỏ).
  • Services secondary: Prefix length 15 đến 28 (hỗ trợ lên hàng nghìn Services).
  • Tổng Pod cần: 10 node × 8 Pod = 80 Pod → cần ít nhất ~100 IP (có overhead), nhưng phải ≥ /24.
  • Services: 1024 → cần ít nhất /22 (1024 IP).

📘 Tài liệu tham khảo (cập nhật mới nhất 2024-2026):

✅ Đáp án đúng: Configure a /28 primary IP address range for the node IP addresses. Configure a /24 secondary IP range for the Pads. Configure a /22 secondary IP range for the Services.

Lý do lựa chọn 🛠️:

  • /28 cho nodes (16 IP): Đủ cho 10 node (GKE hỗ trợ tối đa ~11 node), là kích thước tối thiểu tối ưu, tiết kiệm IP.
  • /24 cho Pods (256 IP): Là kích thước nhỏ nhất được phép cho Pods secondary range (prefix=24), đủ cho 80 Pod + overhead. Với max 8 Pod/node, GKE flexible allocation cấp CIDR nhỏ hơn /24/node (ví dụ /27), nên tổng /24 đủ dùng và tối ưu.
  • /22 cho Services (1024 IP): Chính xác cho 1024 Services, tối ưu không dư thừa.
  • Tổng thể: Tuân thủ quy tắc GKE, hỗ trợ scale, không lãng phí (không dùng range lớn hơn cần thiết như /21 Services).

❌ Giải thích tất cả các phương án

  • [SAI] Configure a /28 primary IP address range for the node IP addresses. Configure a /25 secondary IP range for the Pods. Configure a /22 secondary IP range for the Services.
    ❌ Sai vì Pods secondary range /25 (128 IP, prefix=25) vi phạm quy định GKE: Phải có prefix length ≤24 (tức ≥256 IP). 128 IP không đủ chứa phân bổ per-node CIDR (dù chỉ 80 Pod cần, nhưng GKE không cho phép). Nodes và Services ok, nhưng Pods invalid.

  • [SAI] Configure a /28 primary IP address range for the node IP addresses. Configure a /25 secondary IP range for the Pods. Configure a /21 secondary IP range for the Services.
    ❌ Sai tương tự phương án đầu: Pods /25 không được phép (prefix 25 >24). Services /21 (2048 IP) quá lớn, không tối ưu dù hợp lệ (prefix=21 trong 15-28). Nodes ok.

  • [SAI] Configure a /28 primary IP address range for the node IP addresses. Configure a /28 secondary IP range for the Pods. Configure a /21 secondary IP range for the Services.
    ❌ Sai nặng vì Pods /28 (16 IP, prefix=28) quá nhỏ và invalid: Không đủ cho 80 Pod (chỉ ~16 Pod), prefix >24 vi phạm quy định. Services /21 dư thừa, không tối ưu.

Tóm lại, chỉ phương án cuối cùng tối ưu và hợp lệ hoàn toàn theo best practices GKE! 🚀

Câu 116
You are migrating a three-tier application architecture from on-premises to Google Cloud. As a first step in the migration, you want to create a new Virtual Private Cloud (VPC) with an external HTTP(S) load balancer. This load balancer will forward traffic back to the on-premises compute resources that run the presentation tier. You need to stop malicious traffic from entering your VPC and consuming resources at the edge, so you must configure this policy to filter IP addresses and stop cross-site scripting (XSS) attacks. What should you do?
  1. A Create a Google Cloud Armor policy, and apply it to a backend service that uses an unmanaged instance group backend.
  2. B Create a hierarchical firewall ruleset, and apply it to the VPC's parent organization resource node.
  3. C Create a Google Cloud Armor policy, and apply it to a backend service that uses an internet network endpoint group (NEG) backend.
  4. D Create a VPC firewall ruleset, and apply it to all instances in unmanaged instance groups.
Xem giải thích

🧩 Phân tích chi tiết câu hỏi

Câu hỏi mô tả tình huống:
Bạn đang di chuyển một kiến trúc ứng dụng ba tầng (three-tier application) từ on-premises sang Google Cloud. Bước đầu tiên là tạo một VPC mới kèm external HTTP(S) load balancer. Load balancer này sẽ chuyển tiếp (forward) lưu lượng truy cập quay trở lại các tài nguyên compute on-premises đang chạy tầng presentation (giao diện người dùng).

Yêu cầu chính:

  • Ngăn chặn lưu lượng độc hại (malicious traffic) từ việc xâm nhập vào VPC và tiêu tốn tài nguyên tại edge (cạnh mạng, tức là trước khi vào VPC).
  • Cụ thể: Lọc địa chỉ IP và chặn tấn công cross-site scripting (XSS).

🛠️ Ý nghĩa kỹ thuật:

  • Đây là mô hình hybrid cloud: Presentation tier vẫn ở on-premises, load balancer GCP làm frontend.
  • Cần giải pháp WAF (Web Application Firewall) hoạt động tại L7 (HTTP/S), lọc traffic trước khi vào VPC (at the edge).
  • Google Cloud Armor là dịch vụ WAF chính thức của GCP, tích hợp với external HTTP(S) LB, hỗ trợ chính sách lọc IP, XSS, v.v.
  • Backend không phải VM GCP mà là external/on-premises, nên cần Network Endpoint Group (NEG) loại internet NEG để chỉ định IP external làm backend.

(Kiến thức cập nhật đến 2026: Theo tài liệu GCP mới nhất, Cloud Armor v2.x hỗ trợ đầy đủ NEG backends cho external LB, bao gồm internet NEG cho on-premises hybrid setups. Không thay đổi lớn từ 2024-2026.)

📘 Tài liệu tham khảo:


✅ Đáp án đúng

Create a Google Cloud Armor policy, and apply it to a backend service that uses an internet network endpoint group (NEG) backend.

Lý do lựa chọn (chi tiết):

  • Google Cloud Armor policy là giải pháp WAF lý tưởng để lọc IP (IP allow/deny lists) và chặn XSS (pre-configured rulesets như OWASP). Nó hoạt động tại edge của external HTTP(S) LB, ngăn traffic độc hại trước khi vào VPC, tiết kiệm tài nguyên.
  • Backend là on-premises, không phải VM GCP → Sử dụng internet NEG (loại NEG chỉ IP external/on-premises ports) gắn vào backend service của LB.
  • LB → Backend service (với Cloud Armor) → Internet NEG → On-premises: Hoàn hảo cho hybrid migration, traffic được filter L7 tại GCP edge.
  • ✅ Đúng 100% với yêu cầu "stop malicious traffic from entering your VPC and consuming resources at the edge".

🧩 Giải thích tất cả các phương án

  • ❌ [SAI] Create a Google Cloud Armor policy, and apply it to a backend service that uses an unmanaged instance group backend.
    Phương án này dùng Cloud Armor (đúng về WAF/filter), nhưng backend là unmanaged instance group → Chỉ áp dụng cho VM instances trong GCP (không phải on-premises). Không phù hợp hybrid setup, traffic vẫn phải đi qua VPC đến instances GCP thay vì forward về on-prem. Không giải quyết được yêu cầu external backend.

  • ❌ [SAI] Create a hierarchical firewall ruleset, and apply it to the VPC's parent organization resource node.
    Hierarchical firewall ruleset (tính năng Organization Policies cho VPC firewall) chỉ lọc L3/L4 traffic (IP/port), không hỗ trợ XSS (L7 attack). Nó áp dụng cho VPC/VMs, không phải tại edge LB, nên traffic độc hại vẫn vào VPC trước khi bị chặn. Không tích hợp với HTTP(S) LB.

  • ✅ [ĐÚNG] Create a Google Cloud Armor policy, and apply it to a backend service that uses an internet network endpoint group (NEG) backend.
    (Đã giải thích chi tiết ở phần đáp án đúng ở trên). Hoàn hảo cho external LB + on-premises backend + edge filtering.

  • ❌ [SAI] Create a VPC firewall ruleset, and apply it to all instances in unmanaged instance groups.
    VPC firewall ruleset chỉ lọc L3/L4 (không chặn XSS), và áp dụng cho instances trong unmanaged instance groups (VMs GCP). Không có instances on-premises trong VPC, và không filter tại edge LB → Traffic độc hại vẫn tiêu tốn băng thông vào VPC trước. Không phải giải pháp WAF.

Câu 117
You just finished your company’s migration to Google Cloud and configured an architecture with 3 Virtual Private Cloud (VPC) networks: one for Sales, one for Finance, and one for Engineering. Every VPC contains over 100 Compute Engine instances, and now developers using instances in the Sales VPC and the Finance VPC require private connectivity between each other. You need to allow communication between Sales and Finance without compromising performance or security. What should you do?
  1. A Configure an HA VPN gateway between the Finance VPC and the Sales VPC.
  2. B Configure the instances that require communication between each other with an external IP address.
  3. C Create a VPC Network Peering connection between the Finance VPC and the Sales VPC.
  4. D Configure Cloud NAT and a Cloud Router in the Sales and Finance VPCs.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả tình huống sau khi hoàn tất việc di chuyển (migration) hệ thống của công ty lên Google Cloud Platform (GCP). Kiến trúc bao gồm 3 Virtual Private Cloud (VPC) networks riêng biệt:

  • Một VPC cho bộ phận Sales (Bán hàng),
  • Một VPC cho bộ phận Finance (Tài chính),
  • Một VPC cho bộ phận Engineering (Kỹ thuật).

Mỗi VPC chứa hơn 100 Compute Engine instances (máy ảo). Yêu cầu cụ thể là cho phép giao tiếp private (riêng tư) giữa các instances trong Sales VPC và Finance VPC, mà không ảnh hưởng đến hiệu suất (performance) hoặc bảo mật (security).

📌 Mục tiêu chính: Kết nối nội bộ giữa hai VPC (Sales và Finance) một cách an toàn, nhanh chóng, sử dụng địa chỉ IP private, tránh lộ ra internet. Không liên quan đến Engineering VPC hoặc kết nối on-premises. Đây là kịch bản điển hình về inter-VPC connectivity trong GCP, ưu tiên giải pháp native, low-latency và secure-by-default.

(Kiến thức cập nhật đến 2026: VPC Peering vẫn là giải pháp chuẩn cho inter-VPC private connectivity trong GCP, hỗ trợ Shared VPC và cross-project peering theo tài liệu GCP mới nhất - không có thay đổi lớn từ VPC Global v2.x).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Create a VPC Network Peering connection between the Finance VPC and the Sales VPC.

Lý do 🛠️:

  • VPC Network Peering là giải pháp tối ưu nhất để kết nối hai VPC riêng biệt trong cùng project hoặc cross-project, cho phép giao tiếp private-to-private qua địa chỉ IP nội bộ (RFC 1918), không qua internet nên đảm bảo hiệu suất cao (low latency, high bandwidth) và bảo mật tuyệt đối (không expose public IP).
  • Hỗ trợ transitive routing hạn chế (chỉ trực tiếp giữa peered VPCs), phù hợp với yêu cầu chỉ Sales ↔ Finance.
  • Dễ triển khai, chi phí thấp (chỉ tính theo traffic), không cần thiết bị trung gian như VPN gateway.
  • Tuân thủ nguyên tắc least privilege và zero-trust trong GCP networking.

📘 Giải thích tất cả các phương án (đúng/sai)

  • ❌ Configure an HA VPN gateway between the Finance VPC and the Sales VPC.
    Sai vì: HA VPN (High Availability VPN) được thiết kế cho kết nối site-to-site giữa on-premises và GCP VPC, sử dụng IPsec tunnel qua internet hoặc Cloud Interconnect. Sử dụng giữa hai VPC nội bộ GCP sẽ phức tạp hóa không cần thiết, giảm hiệu suất (latency cao do encryption), tăng chi phí và không private thực sự (vẫn có overhead tunnel). Không phải giải pháp native cho inter-VPC.

  • ❌ Configure the instances that require communication between each other with an external IP address.
    Sai vì: Gán external IP (public IP) sẽ expose instances ra internet, dẫn đến rủi ro bảo mật cao (dễ bị tấn công DDoS, unauthorized access) và hiệu suất kém (traffic phải route qua internet gateway). Vi phạm yêu cầu "private connectivity" và "without compromising security". Chỉ dùng khi cần public access, không phù hợp inter-VPC.

  • ✅ Create a VPC Network Peering connection between the Finance VPC and the Sales VPC.
    Đúng vì: Như giải thích ở phần đáp án trên. Đây là best practice của GCP cho intra-region hoặc cross-region peering (tùy auto-mode/custom-mode VPC), hỗ trợ lên đến hàng TBps throughput, firewall rules riêng biệt để kiểm soát traffic.

  • ❌ Configure Cloud NAT and a Cloud Router in the Sales and Finance VPCs.
    Sai vì: Cloud NAT dùng để instances private IP outbound đến internet (source NAT), kết hợp Cloud Router cho dynamic routing (BGP). Không hỗ trợ inbound inter-VPC private traffic; chỉ giúp egress/ingress internet. Sẽ không kết nối được Sales ↔ Finance privately, thậm chí làm phức tạp thêm mà không giải quyết vấn đề.

🔗 Tài liệu tham khảo (Google Cloud Docs - cập nhật 2026)

Hy vọng phân tích này giúp bạn ôn thi chứng chỉ Professional Cloud Network Engineer! 🚀 Nếu cần ví dụ config Terraform/CLI, hãy hỏi thêm.

Câu 118
You have provisioned a Partner Interconnect connection to extend connectivity from your on-premises data center to Google Cloud. You need to configure a Cloud Router and create a VLAN attachment to connect to resources inside your VPC. You need to configure an Autonomous System number (ASN) to use with the associated Cloud Router and create the VLAN attachment.

What should you do?
  1. A Use a 4-byte private ASN 4200000000-4294967294.
  2. B Use a 2-byte private ASN 64512-65535.
  3. C Use a public Google ASN 15169.
  4. D Use a public Google ASN 16550.
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi tập trung vào việc cấu hình kết nối Partner Interconnect trong Google Cloud để mở rộng kết nối từ data center on-premises đến Google Cloud. Cụ thể:

  • Bạn đã provision một kết nối Partner Interconnect (kết nối qua đối tác của Google).
  • Nhiệm vụ: Cấu hình Cloud Router (router ảo trong Google Cloud để quản lý BGP) và tạo VLAN attachment (để gắn kết nối vật lý vào VPC).
  • Yêu cầu chính: Chọn ASN (Autonomous System Number) phù hợp để sử dụng với Cloud Router liên kết, nhằm thiết lập session BGP giữa on-premises và VPC. 📘 Bối cảnh kỹ thuật: Partner Interconnect sử dụng BGP để trao đổi route. Cloud Router của bạn cần ASN riêng (không trùng với Google), và Google sử dụng ASN cố định 16550 ở phía họ. Kiến thức dựa trên tài liệu Google Cloud cập nhật đến 2024-2026 (không thay đổi lớn ở phiên bản mới).

✅ Đáp án đúng

Use a 4-byte private ASN 4200000000-4294967294.
Lý do lựa chọn: Theo tài liệu chính thức Google Cloud, khi cấu hình Cloud Router cho VLAN attachment trong Partner Interconnect/Dedicated Interconnect, bạn PHẢI sử dụng private ASN ở phía customer (Cloud Router của bạn). Phạm vi 4-byte private ASN (4200000000–4294967294) là khuyến nghị chính xác, hỗ trợ BGP peering ổn định mà không xung đột với ASN công khai của Google (16550 hoặc 15169). Điều này đảm bảo route exchange đúng giữa on-premises và VPC mà không vi phạm quy tắc BGP.
🛠️ Nguồn tham khảo:

❌ Giải thích tất cả các phương án

Dưới đây là phân tích chi tiết từng lựa chọn (giữ nguyên văn bản gốc). Lưu ý: Chỉ private ASN mới đúng cho Cloud Router; không dùng ASN của Google để tránh loop BGP hoặc từ chối peering.

  • Use a 4-byte private ASN 4200000000-4294967294.
    ✅ Đúng. Đây là phạm vi private 4-byte ASN chuẩn theo RFC 6996 và khuyến nghị của Google cho Cloud Router trong Interconnect. Hỗ trợ scale lớn (hàng triệu route), không xung đột public ASN. Lý tưởng cho production.

  • Use a 2-byte private ASN 64512-65535.
    ❌ Sai. Phạm vi gần đúng (Google khuyến nghị 64512–65534), nhưng bao gồm 65535 (reserved ASN theo RFC 7300, không dùng cho private peering). Có nguy cơ lỗi BGP session nếu chọn 65535, nên không chính xác hoàn toàn. Ưu tiên 4-byte để tránh issue.

  • Use a public Google ASN 15169.
    ❌ Sai. 15169 là ASN công khai của Google dùng cho một số dịch vụ peering (như Google Public Peering), KHÔNG dùng cho Cloud Router trong Interconnect. Sử dụng sẽ gây xung đột BGP vì trùng ASN Google side (16550), dẫn đến peering thất bại.

  • Use a public Google ASN 16550.
    ❌ Sai. 16550 là ASN cố định của Google ở phía họ cho tất cả Dedicated/Partner Interconnect. Cấm sử dụng cho Cloud Router của bạn (gây duplicate ASN, BGP không thiết lập được). Docs Google cảnh báo rõ: "Do not configure your router to use Google's ASN (16550)".

🧩 Tóm tắt key takeaway: Luôn dùng private ASN cho Cloud Router (ưu tiên 4-byte), Google's ASN chỉ ở phía họ. Nếu config sai ASN, VLAN attachment peering sẽ down! Kiểm tra bằng lệnh gcloud compute routers describe sau setup.

Câu 119
You are configuring a new application that will be exposed behind an external load balancer with both IPv4 and IPv6 addresses and support TCP pass-through on port 443. You will have backends in two regions: us-west1 and us-east1. You want to serve the content with the lowest possible latency while ensuring high availability and autoscaling. Which configuration should you use?
  1. A Use global SSL Proxy Load Balancing with backends in both regions.
  2. B Use global TCP Proxy Load Balancing with backends in both regions.
  3. C Use global external HTTP(S) Load Balancing with backends in both regions.
  4. D Use Network Load Balancing in both regions, and use DNS-based load balancing to direct traffic to the closest region.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào việc cấu hình một ứng dụng mới trên Google Cloud Platform (GCP), được expose qua external load balancer hỗ trợ cả IPv4 và IPv6 (dual-stack). Ứng dụng cần TCP pass-through trên port 443 (tức là load balancer không terminate kết nối SSL/TLS mà chỉ forward traffic TCP nguyên vẹn đến backend).

Các yêu cầu chính:

  • Backends nằm ở hai regions: us-west1 và us-east1 (multi-region setup).
  • Mục tiêu: Phục vụ nội dung với latency thấp nhất có thể (ưu tiên region gần client nhất), đồng thời đảm bảo high availability (tính sẵn sàng cao qua multi-region) và autoscaling (tự động scale backend groups như MIG - Managed Instance Groups).

🛠️ Bối cảnh kỹ thuật: Đây là tình huống cần Layer 4 load balancing (TCP pass-through, không xử lý L7 như HTTP), hỗ trợ IPv6, và global distribution mà không dùng global LB (vì global LB một số loại không hỗ trợ IPv6 hoặc pass-through đúng cách). Giải pháp phải tận dụng DNS-based global load balancing để route traffic đến region gần nhất, giảm latency.

📘 Kiến thức cập nhật (GCP 2026): Theo tài liệu GCP mới nhất (Cloud Load Balancing updates đến 2026), Network Load Balancing (NLB) hỗ trợ dual-stack IPv4/IPv6 đầy đủ, TCP/UDP pass-through trên mọi port, và kết hợp với Cloud DNS geolocation cho multi-region low-latency.

Nguồn tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use Network Load Balancing in both regions, and use DNS-based load balancing to direct traffic to the closest region.

Lý do 🏆:

  • Network Load Balancing (NLB) là regional LB loại Layer 4, hỗ trợ IPv4/IPv6 dual-stack, TCP pass-through trên port 443 (không terminate SSL), và tích hợp autoscaling với backend services (như MIG).
  • Deploy một NLB riêng ở mỗi region (us-west1 và us-east1) đảm bảo high availability (mỗi region độc lập, failover tự nhiên nếu một region down).
  • DNS-based load balancing (sử dụng Cloud DNS với policy geolocation hoặc EDNS client subnet) sẽ resolve IP của NLB gần client nhất, giảm latency tối đa (client US West → us-west1, US East → us-east1).
  • Hoàn hảo cho yêu cầu: low latency, HA, autoscaling, mà không cần global LB phức tạp.

📋 Giải thích tất cả các phương án

  • ❌ [SAI] Use global SSL Proxy Load Balancing with backends in both regions.
    Lý do sai: Global SSL Proxy LB là Layer 4 SSL termination (terminate SSL/TLS tại LB, không phải pass-through TCP nguyên vẹn). Nó không hỗ trợ TCP pass-through thuần trên port 443 mà yêu cầu SSL certificate tại LB. Ngoài ra, không hỗ trợ IPv6 dual-stack frontend (chỉ IPv4). Không phù hợp multi-region pass-through.

  • ❌ [SAI] Use global TCP Proxy Load Balancing with backends in both regions.
    Lý do sai: Global TCP Proxy LB hỗ trợ TCP proxy (Layer 4), multi-region backends, nhưng không hỗ trợ IPv6 addresses trên frontend (dual-stack chỉ IPv4 đến 2026). Nó cũng proxy traffic (không pure pass-through như NLB), và không tối ưu latency bằng DNS geo-routing (traffic luôn qua proxy endpoints global cố định).

  • ❌ [SAI] Use global external HTTP(S) Load Balancing with backends in both regions.
    Lý do sai: Đây là Layer 7 HTTP(S) LB, yêu cầu terminate SSL tại LB (không TCP pass-through). Nó xử lý HTTP features (path-based routing), không phù hợp TCP raw trên 443. Hỗ trợ IPv6 nhưng không phải pass-through, và overhead L7 làm tăng latency nhẹ.

  • ✅ [ĐÚNG] Use Network Load Balancing in both regions, and use DNS-based load balancing to direct traffic to the closest region.
    (Đã giải thích chi tiết ở phần trên – lý tưởng nhất cho tất cả yêu cầu! 🚀)

Câu 120
In your project my-project, you have two subnets in a Virtual Private Cloud (VPC): subnet-a with IP range 10.128.0.0/20 and subnet-b with IP range 172.16.0.0/24. You need to deploy database servers in subnet-a. You will also deploy the application servers and web servers in subnet-b. You want to configure firewall rules that only allow database traffic from the application servers to the database servers. What should you do?
  1. A Create network tag app-server and service account sa-db@my-project.iam.gserviceaccount.com. Add the tag to the application servers, and associate the service account with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-rule \
    --action allow \
    --direction ingress \
    --rules top:3306 \
    --source-tags app-server \
    --target-service-accounts sa-db@my-
    project.iam.gserviceaccount.com
  2. B Create service accounts sa-app@my-project.iam.gserviceaccount.com and sa-db@my-project.iam.gserviceaccount.com. Associate service account sa-app with the application servers, and associate the service account sa-db with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-ru
    --allow TCP:3306 \
    --source-service-accounts sa-app@democloud-idp-
    demo.iam.gserviceaccount.com \
    --target-service-accounts sa-db@my-
    project.iam.gserviceaccount.com
  3. C Create service accounts sa-app@my-project.iam.gserviceaccount.com and sa-db@my-project.iam.gserviceaccount.com. Associate the service account sa-app with the application servers, and associate the service account sa-db with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-ru
    --allow TCP:3306 \
    --source-ranges 10.128.0.0/20 \
    --source-service-accounts sa-app@my-
    project.iam.gserviceaccount.com \
    --target-service-accounts sa-db@my-
    project.iam.gserviceaccount.com
  4. D Create network tags app-server and db-server. Add the app-server tag to the application servers, and add the db-server tag to the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-rule \
    --action allow \
    --direction ingress \
    --rules tcp:3306 \
    --source-ranges 10.128.0.0/20 \
    --source-tags app-server \
    --target-tags db-server
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi xoay quanh việc cấu hình quy tắc tường lửa (firewall rules) trong Google Cloud VPC để kiểm soát lưu lượng truy cập cơ sở dữ liệu (database traffic, giả sử cổng 3306 cho MySQL). Cụ thể:

  • Môi trường: Project my-project có VPC với 2 subnet:
    • Subnet-a: Dải IP 10.128.0.0/20 – nơi triển khai database servers.
    • Subnet-b: Dải IP 172.16.0.0/24 – nơi triển khai application servers và web servers.
  • Yêu cầu: Chỉ cho phép lưu lượng từ application servers (subnet-b) đến database servers (subnet-a) qua cổng 3306. Không cho phép từ web servers hoặc các nguồn khác.
  • Mục tiêu: Sử dụng lệnh gcloud compute firewall-rules create để tạo quy tắc ingress (vào), allow TCP:3306, đảm bảo tính chính xác, an toàn và tuân thủ nguyên tắc least privilege (quyền hạn tối thiểu).
  • Kiến thức cập nhật (GCP 2026): Firewall rules hỗ trợ source-service-accounts và target-service-accounts để kiểm soát dựa trên service account gắn với VM instances, thay vì IP ranges hoặc tags (hiệu quả hơn vì SA unique per project và dễ quản lý IAM). Không phụ thuộc AWS vì đây là GCP thuần túy. 📘

✅ Đáp án đúng: Lựa chọn thứ 2

Lý do chọn:

  • Tạo service accounts sa-app@my-project.iam.gserviceaccount.com (gắn cho application servers) và sa-db@my-project.iam.gserviceaccount.com (gắn cho database servers).
  • Quy tắc firewall sử dụng --source-service-accounts sa-app (chỉ nguồn từ app servers có SA này, ở subnet-b) và --target-service-accounts sa-db (chỉ áp dụng cho db servers có SA này, ở subnet-a).
  • Ưu điểm: Chính xác, không lộ IP ranges (tránh hardcode subnet), dễ scale (thêm VM chỉ cần gắn SA đúng), tuân thủ IAM best practices. Lệnh syntax đúng: --allow TCP:3306.
  • Lưu ý nhỏ: Text lệnh có lỗi format copy-paste (sa-app@democloud-idp-demo có thể là demo project, nhưng logic vẫn khớp my-project).

Lệnh đầy đủ (giữ nguyên):

Create service accounts sa-app@my-project.iam.gserviceaccount.com and sa-db@my-project.iam.gserviceaccount.com. Associate service account sa-app with the application servers, and associate the service account sa-db with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-ru
--allow TCP:3306 
--source-service-accounts sa-app@democloud-idp-demo.iam.gserviceaccount.com 
--target-service-accounts sa-db@my-
project.iam.gserviceaccount.com

🛠️ Phân tích tất cả các phương án

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi sai sót được chỉ rõ lý do kỹ thuật dựa trên GCP Firewall docs (phiên bản mới nhất 2026).

  • ❌ Phương án 1 (SAI):

    Create network tag app-server and service account sa-db@my-project.iam.gserviceaccount.com. Add the tag to the application servers, and associate the service account with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-rule 
    --action allow 
    --direction ingress 
    --rules top:3306 
    --source-tags app-server 
    --target-service-accounts sa-db@my-
    project.iam.gserviceaccount.com
    

    Giải thích sai:

    • Syntax lỗi: --rules top:3306 không hợp lệ (phải là --rules tcp:3306 hoặc --allow tcp:3306).
    • Kết hợp source-tags (app-server trên app servers) với target-service-accounts là được hỗ trợ, nhưng không nhất quán và kém an toàn (tags dễ duplicate cho web servers cùng subnet-b).
    • Không chỉ rõ subnet-b, có thể leak traffic nếu tag lan sang web servers.
  • ✅ Phương án 2 (ĐÚNG): (Đã giải thích ở trên – hoàn hảo về logic và syntax).

  • ❌ Phương án 3 (SAI):

    Create service accounts sa-app@my-project.iam.gserviceaccount.com and sa-db@my-project.iam.gserviceaccount.com. Associate the service account sa-app with the application servers, and associate the service account sa-db with the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-ru
    --allow TCP:3306 
    --source-ranges 10.128.0.0/20 
    --source-service-accounts sa-app@my-
    project.iam.gserviceaccount.com 
    --target-service-accounts sa-db@my-
    project.iam.gserviceaccount.com
    

    Giải thích sai:

    • --source-ranges 10.128.0.0/20 là dải IP của subnet-a (DB servers), không phải subnet-b (app servers ở 172.16.0.0/24). Điều này cho phép traffic từ DB subnet vào chính DB (self-traffic) hoặc sai nguồn.
    • Thừa --source-service-accounts + --source-ranges làm quy tắc lỏng lẻo, không chính xác yêu cầu "chỉ từ application servers".
  • ❌ Phương án 4 (SAI):

    Create network tags app-server and db-server. Add the app-server tag to the application servers, and add the db-server tag to the database servers. Run the following command: gcloud compute firewall-rules create app-db-firewall-rule 
    --action allow 
    --direction ingress 
    --rules tcp:3306 
    --source-ranges 10.128.0.0/20 
    --source-tags app-server 
    --target-tags db-server
    

    Giải thích sai:

    • --source-ranges 10.128.0.0/20 sai hoàn toàn (lại là subnet-a/DB, app servers ở subnet-b).
    • Source-tags app-server + target-tags db-server đúng về tags, nhưng kết hợp source-ranges sai làm quy tắc không match app servers.
    • Tags kém granular hơn SA (dễ misapply cho web servers cùng subnet-b), không khuyến khích cho security-sensitive như DB access.

📘 Tài liệu tham khảo

Kết luận: Phương án 2 là optimal cho Network Engineer, đảm bảo zero-trust access! 🚀