---
id: ccna-acl-segmentation
title: "ACL, NSG và NetworkPolicy"
track: segmentation
trackTitle: "ACL, NSG và NetworkPolicy"
order: 1
level: core
status: published
estimatedMinutes: 35
prerequisites:
  - ccna-hybrid-routing
next: ccna-troubleshoot-layers
reviewedAgainst: 2026-10-29
sources:
  - title: "Kubernetes Network Policies"
    url: https://kubernetes.io/docs/concepts/services-networking/network-policies/
---

# ACL, NSG và NetworkPolicy

Trên IOS là extended ACL; trên cloud là NSG, NACL, rule firewall — cùng kiểu suy nghĩ: **rule nào khớp trước**, **stateful hay không**, **inbound hay outbound**.

## Để làm gì

`dig` ra IP đúng mà `curl` treo — biết nhìn L4 trước, không sửa DNS.

## Gồm những gì

Extended ACL (IOS) map sang cloud SG và NetworkPolicy. NACL stateless cần nhớ chiều return.

| Chỗ | Stateful? |
| --- | --- |
| Azure NSG | Có |
| AWS NACL | Không |
| NetworkPolicy | L4 filter pod |

<div class="net-flow">
<div class="net-step" style="--layer:#dbeafe"><b>Client</b><span>:443 out</span></div>
<div class="net-arrow">→</div>
<div class="net-step" style="--layer:#fef3c7"><b>NSG</b><span>443 in?</span></div>
<div class="net-arrow">→</div>
<div class="net-step" style="--layer:#dcfce7"><b>VM / Pod</b></div>
</div>

```bash
nc -vz api.example.com 443
curl -v --connect-timeout 5 https://api.example.com/
```

Test từ **cùng đường** với user (VPN, jump box, laptop ngoài).

## Checklist

- [ ] Một rule một lần, chạy lại `nc`/`curl` sau mỗi lần.
- [ ] NACL: mở cả chiều reply nếu stateless.

## Thẻ ôn

### ccna-acl-segmentation-dns-tcp
kind: trap
cue: "dig OK" + "curl timeout"

Q: Sửa bản ghi DNS trước có hợp lý?

A: Không — thử TCP/port và rule firewall trước.

### ccna-acl-segmentation-first-match
kind: default
cue: "deny trước allow sau"

Q: Deny rộng phía trên, allow hẹp phía dưới — traffic tới allow?

A: Không nếu deny khớp trước.

## Tiếp theo

[Chẩn đoán theo tầng](../troubleshooting/01-layers.md)
