---
id: ccna-troubleshoot-layers
title: "Chẩn đoán mạng theo tầng"
track: troubleshooting
trackTitle: "Chẩn đoán theo tầng"
order: 1
level: core
status: published
estimatedMinutes: 40
prerequisites:
  - ccna-acl-segmentation
next: case-hybrid-no-route
reviewedAgainst: 2026-10-29
sources:
  - title: "DevOps — Công cụ chẩn đoán mạng"
    url: /devops?lesson=networking-cli-tools
---

# Chẩn đoán mạng theo tầng

Cùng tinh thần troubleshooting WAN trên router: một bước một lớp. Lệnh chi tiết: bài **Công cụ chẩn đoán mạng** bên DevOps (`/devops?lesson=networking-cli-tools`).

## Để làm gì

Runbook ngắn: dừng ở lớp fail đầu tiên, ghi output, rồi mới sửa một chỗ.

## Gồm những gì

DNS → L3 → L4 → L7. Trong cluster thêm `kubectl get endpoints` và curl từ pod khác.

<div class="net-flow">
<div class="net-step" style="--layer:#dbeafe"><b>DNS</b><span>dig +short</span></div>
<div class="net-arrow">→</div>
<div class="net-step" style="--layer:#fef3c7"><b>L3</b><span>ping gateway, traceroute</span></div>
<div class="net-arrow">→</div>
<div class="net-step" style="--layer:#dcfce7"><b>L4</b><span>nc -vz</span></div>
<div class="net-arrow">→</div>
<div class="net-step" style="--layer:#e0e7ff"><b>L7</b><span>curl -v</span></div>
</div>

Mỗi bước trả lời một câu: tên ra IP chưa? IP tới được không? Port mở không? TLS/HTTP trả gì?

```bash
dig +short api.example.com
ping -c 2 GATEWAY
traceroute -n TARGET
nc -vz TARGET 443
curl -sv --connect-timeout 5 https://api.example.com/healthz
```

`ping` fail không chứng minh web chết — nhiều chỗ chặn ICMP. Port 443 mới là test gần user hơn.

## Checklist

- [ ] Ghi lại bước fail đầu tiên (copy terminal).
- [ ] Một thay đổi config, chạy lại cùng chuỗi lệnh.

## Thẻ ôn

### ccna-troubleshoot-layers-order
kind: decide
cue: "502" + "chưa biết reachability"

Q: User báo 502 — nhảy thẳng vào Ingress?

A: Nếu chưa chắc path tới backend: DNS/L3/L4 trước; 502 là HTTP nhưng có thể do upstream không tới được.

### ccna-troubleshoot-layers-one-change
kind: command
cue: "nhiều rule firewall"

Q: Ba rule có thể sai — sửa thế nào?

A: Một rule, test lại, rồi rule tiếp.

## Tiếp theo

[Tình huống hybrid](../cases/01-hybrid-no-route.md)
