Communitygithub.com

網路介面健康檢查

診斷路由器、交換機和 Linux 主機上的介面錯誤、丟棄、CRC、雙工不匹配、翻動、速度協商問題及計數器趨勢。當介面出現錯誤、丟棄、CRC、翻動或雙工/速度不匹配時使用。

網路介面健康檢查 是什麼?

此技能「網路介面健康檢查」專門用於診斷和排查網路介面層面的問題,例如封包遺失、延遲尖峰、間歇性連通性問題,以及由實體鏈路、交換機端口、線纜、光收發器、雙工設定或擁塞引起的計數器異常。它支援路由器和交換機(透過 CLI 命令如 `show interfaces` 和 `show logging`)以及 Linux 主機(透過 `ip -s link` 和 `ethtool`)。該技能提供了常見計數器(如 CRC、輸入/輸出錯誤、丟棄、碰撞)的參考表及其典型原因,並用於診斷流程,例如檢查計數器趨勢、核對鏈路兩端、檢查記錄中的翻動事件。它還包括一個安全的 Python 解析器範例,可以正確地將介面區塊分割,以避免資料錯位。此外,它還列出了常見的反模式(如清除計數器前未保存基準、只檢查鏈路一端、混用自動協商與固定雙工/速度),並建議配合其他技能使用。總而言之,此技能幫助開發者和網路工程師系統性地收集證據,在更換硬體或變更配置前驗證假設,從而縮小問題範圍。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/network-interface-health

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

網路介面健康檢查 是做什麼的?

當網路症狀可能由實體鏈路、交換機端口、線纜、光收發器、雙工設定或擁塞介面引起時,使用此技能。

使用時機

  • 主機或 VLAN 出現封包遺失、延遲尖峰或間歇性連通性問題。
  • 交換機或路由器介面顯示 CRC、短包、長包、丟棄、重置或翻動。
  • 需要在更換硬體前比較鏈路兩端的數據。
  • 變更窗口需要在事前/事後提供介面計數器證據。
  • 監控報告 ifInErrors、ifOutErrors 或 ifOutDiscards 呈上升趨勢。

運作原理

介面計數器是證據,但趨勢比絕對數字更重要。先捕獲基準線,等待一個測量間隔,再捕獲一次,然後比較增量。

show interfaces <interface>
show interfaces <interface> status
show logging | include <interface>|changed state|line protocol

在 Linux 主機上:

ip -s link show <interface>
ethtool <interface>
ethtool -S <interface>

計數器參考

計數器含義常見原因
CRC接收到的幀校驗和失敗線纜不良、光纖髒污、光學元件故障、雙工不匹配
input errors接收端聚合錯誤檢查子計數器後再下結論
runts小於最小乙太網幀大小的幀雙工不匹配、碰撞域、網卡故障
giants大於預期 MTU 的幀MTU 不匹配或巨型幀邊界
input drops裝置無法接收入站封包突發流量、超額訂閱、CPU 路徑、佇列壓力
output drops輸出佇列丟棄封包擁塞、QoS 策略、上行鏈路頻寬不足
resets介面硬體重置翻動、保持連線、驅動程式、光學元件、電源
collisions乙太網碰撞計數器半雙工或協商不匹配

診斷流程

CRC 或輸入錯誤

  1. 確認計數器正在增加,而不僅僅是歷史數據。
  2. 檢查鏈路兩端。接收端錯誤通常指向到達該端的信號問題,而不一定是報告錯誤的端口。
  3. 更換跳線或清潔/更換光纖和光學元件。
  4. 確認兩端的速度/雙工設定相符。
  5. 檢查日誌中同一時間戳附近的翻動事件。

丟棄

  1. 區分輸入丟棄和輸出丟棄。
  2. 將介面速率與容量進行比較。
  3. 檢查 QoS 策略、佇列計數器以及鏈路是否為超額訂閱的上行鏈路。
  4. 將佇列調整視為次要手段。首先證明鏈路是否擁塞。

雙工和速度

在兩端都支援自動協商的現代乙太網鏈路上,建議使用自動協商。如果一端必須設定為固定值,則需明確配置兩端並記錄原因。切勿在一端使用固定速度/雙工,另一端使用自動協商。

show interfaces <interface> | include duplex|speed

安全解析器範例

將每個介面區塊從一個標題切片到下一個標題。不要使用任意的字元視窗;大型介面區塊可能導致計數器遺漏或分配錯誤的端口。

import re
from typing import Any

HEADER_RE = re.compile(
    r"^(?P<name>\S+) is (?P<status>(?:administratively )?down|up), "
    r"line protocol is (?P<protocol>up|down)",
    re.I | re.M,
)
ERROR_RE = re.compile(r"(?P<input>\d+) input errors, (?P<crc>\d+) CRC", re.I)
DROP_RE = re.compile(r"(?P<output>\d+) output errors", re.I)
DUPLEX_RE = re.compile(r"(?P<duplex>Full|Half|Auto)-duplex,\s+(?P<speed>[^,]+)", re.I)

def parse_show_interfaces(raw: str) -> list[dict[str, Any]]:
    headers = list(HEADER_RE.finditer(raw))
    interfaces = []
    for index, header in enumerate(headers):
        end = headers[index + 1].start() if index + 1 < len(headers) else len(raw)
        block = raw[header.start():end]
        errors = ERROR_RE.search(block)
        drops = DROP_RE.search(block)
        duplex = DUPLEX_RE.search(block)
        interfaces.append({
            "name": header.group("name"),
            "status": header.group("status"),
            "protocol": header.group("protocol"),
            "duplex": duplex.group("duplex") if duplex else "unknown",
            "speed": duplex.group("speed").strip() if duplex else "unknown",
            "input_errors": int(errors.group("input")) if errors else 0,
            "crc_errors": int(errors.group("crc")) if errors else 0,
            "output_errors": int(drops.group("output")) if drops else 0,
        })
    return interfaces

範例

一個交換機端口上的 CRC

  1. 捕獲本地端口的計數器。
  2. 捕獲連接的遠端端口的計數器。
  3. 在更改路由或防火牆規則前更換線纜或光學元件。
  4. 僅在記錄基準線後才清除計數器。
  5. 在固定間隔後重新檢查。

網際網路慢但區域網路正常

  1. 檢查 WAN 介面的丟棄/錯誤。
  2. 檢查 LAN 上行鏈路的利用率和輸出丟棄。
  3. 如果 WAN 鏈路乾淨但吞吐量仍然很低,檢查閘道 CPU。
  4. 在指責上游服務之前,比較有線和無線測試結果。

反模式

  • 在保存基準線之前清除計數器。
  • 只檢查鏈路的一端。
  • 沒有時間窗口假設所有歷史 CRC 都是活躍問題。
  • 在一端混用自動協商,另一端使用固定速度/雙工。
  • 在檢查擁塞之前將輸出丟棄視為線纜問題。

相關內容

  • 代理:network-troubleshooter
  • 技能:network-config-validation
  • 技能:homelab-network-setup

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能