Communitygithub.com

网络接口健康诊断

诊断路由器、交换机和Linux主机上的接口错误、丢包、CRC校验错误、双工不匹配、端口抖动、速率协商问题及计数器趋势。当接口出现错误、丢包、CRC、抖动或双工/速率不匹配时使用。

网络接口健康诊断 是什么?

此技能专门用于诊断网络接口层面的问题,如物理链路、交换机端口、线缆、光模块、双工设置或拥塞导致的症状。它适用于主机或VLAN出现丢包、延迟尖峰、间歇性可达性,或交换机/路由器接口显示CRC、短帧、巨帧、丢包、重置或抖动的情况。技能强调计数器趋势比绝对值更重要,要求先捕获基线,等待测量间隔后再次捕获并比较增量。它支持Cisco IOS风格的交换机和路由器命令(如`show interfaces`)以及Linux主机命令(`ip -s link show`、`ethtool`)。技能提供了详细的计数器参考表、针对CRC/输入错误、丢包、双工/速率的诊断流程,以及一个安全的解析器示例,用于将show interfaces输出按接口块切分。它明确列出了反模式,如清除计数器前未保存基线、只看链路一端、混合使用自动协商与固定设置等。

兼容平台~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. 确认两侧的速度/双工设置一致。
  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都是当前活动问题。
  • 在一端使用自动协商,另一端使用固定速率/双工。
  • 在检查拥塞之前,将输出丢包视为线缆问题。

参见

  • Agent: network-troubleshooter
  • Skill: network-config-validation
  • Skill: 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.

相关技能