Communitygithub.com

網路介面健康檢查

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

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

此技能「網路介面健康檢查」專門用於診斷網路設備(如路由器、交換機和 Linux 主機)上的實體鏈路問題。它透過分析介面計數器(如 CRC、輸入錯誤、輸出丟棄等)的趨勢,而不是僅看絕對數值,來識別問題根源,例如電纜故障、光纖髒污、雙工不匹配或鏈路擁塞。該技能提供了清晰的診斷流程,幫助使用者逐步排查 CRC 錯誤、丟包以及雙工/速度問題,並強調避免常見的反模式,例如在記錄基線前清除計數器或僅檢查鏈路一端。支援的平台包括 Cisco 設備(使用 show 命令)和 Linux 主機(使用 ip 和 ethtool 命令),並提供了一個安全的 Python 解析器範例,用於從 show interfaces 輸出中提取關鍵計數器。此技能與 network-troubleshooter 代理及 homelab-network-setup 技能配合使用,可構成完整的網路故障排除方案。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/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低於乙太網路最小尺寸的幀雙工不匹配、碰撞域、NIC 故障
giants大於預期 MTU 的幀MTU 不匹配或巨型框架邊界
input drops裝置無法接收入站封包突發流量、超額訂閱、CPU 路徑、佇列壓力
output drops出口佇列丟棄封包擁塞、QoS 策略、上行鏈路容量不足
resets介面硬體重置抖動、存活性檢測、驅動程式、光纖收發器、電源
collisions乙太網路碰撞計數器半雙工或協商不匹配

診斷流程

CRC 或輸入錯誤

  1. 確認計數器正在遞增,而不僅僅是歷史數據。
  2. 檢查鏈路的兩端。接收端錯誤通常指向到達該端的信號,不一定是報告錯誤的連接埠。
  3. 更換跳線或清潔/更換光纖和光纖收發器。
  4. 確認兩端的 speed/duplex 設定一致。
  5. 檢查日誌中相同時間戳附近的抖動事件。

丟棄

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

雙工和速度

在現代乙太網路鏈路中,當雙方都支援時,優先使用自動協商。如果必須固定一側,則應明確配置兩側並記錄原因。切勿在一側混合固定 speed/duplex 而在另一側使用自動協商。

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 都是活動問題。
  • 在一側混合自動協商,在另一側混合固定 speed/duplex。
  • 在檢查擁塞之前,將輸出丟棄視為電纜問題。

另請參閱

  • 代理: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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相關技能