Communitygithub.com

ネットワーク構成検証

ルーターやスイッチの設定変更前チェック:危険なコマンド、重複アドレス、サブネットオーバーラップ、未定義参照、管理プレーンリスク、IOSセキュリティ衛生状態を検出します。構成投入前に使用します。

ネットワーク構成検証 とは?

このスキルは、ネットワーク機器の設定変更や自動化スクリプトの実行前に、構成ファイルを多層的に検証するためのものです。Cisco IOS/IOS-XE スタイルのスニペットを想定して設計されており、危険コマンドの検出、重複IPアドレスやサブネットオーバーラップの発見、ACLやルートマップなどの未定義参照の特定、管理プレーン(VTY)のセキュリティチェック、NTPやログ設定などの運用衛生状態の確認を行います。Regexによる軽量なプリフライトチェックを提供し、Netmiko、NAPALM、Ansibleなどの自動化ツールと組み合わせて使用することで、構成投入前に致命的な問題を防ぐことができます。ただし、最終的な承認はネットワークエンジニアが行う必要があり、完全なパーサーではない点に注意が必要です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/network-config-validation

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

ネットワーク構成検証 は何をしますか?

このスキルは、変更ウィンドウ前や自動化処理が本番機器に影響を与える前に、ネットワーク構成をレビューするために使用します。

使用タイミング

  • 展開前に Cisco IOS または IOS-XE スタイルのスニペットをレビューする場合。
  • スクリプトやテンプレートから生成された構成を監査する場合。
  • 危険なコマンド、重複IPアドレス、サブネットオーバーラップを検索する場合。
  • ACL、ルートマップ、プレフィックスリスト、ラインポリシーが参照されているが定義されていない場合を確認する場合。
  • ネットワーク自動化のための軽量プリフライトスクリプトを構築する場合。

仕組み

構成検証は、完全なパーサーではなく、階層的な証拠として扱います。正規表現チェックはプリフライト警告に有用ですが、最終承認にはネットワークエンジニアによるインテント、プラットフォーム構文、ロールバック手順のレビューが依然として必要です。

以下の順序で検証します:

  1. 破壊的なコマンド。
  2. 認証情報と管理プレーンの露出。
  3. 重複アドレスと重複サブネット。
  4. ACL、ルートマップ、プレフィックスリスト、インターフェースへの未定義参照。
  5. NTP、タイムスタンプ、リモートロギング、バナーなどの運用衛生状態。

危険コマンドの検出

import re

DANGEROUS_PATTERNS: list[tuple[re.Pattern[str], str]] = [
    (re.compile(r"\breload\b", re.I), "再起動によりダウンタイムが発生"),
    (re.compile(r"\berase\s+(startup|nvram|flash)", re.I), "永続ストレージを消去"),
    (re.compile(r"\bformat\b", re.I), "デバイスのファイルシステムをフォーマット"),
    (re.compile(r"\bno\s+router\s+(bgp|ospf|eigrp)\b", re.I), "ルーティングプロセスを削除"),
    (re.compile(r"\bno\s+interface\s+\S+", re.I), "インターフェース設定を削除"),
    (re.compile(r"\baaa\s+new-model\b", re.I), "認証動作を変更"),
    (re.compile(r"\bcrypto\s+key\s+(zeroize|generate)\b", re.I), "デバイスのSSHキーを変更"),
]

def find_dangerous_commands(lines: list[str]) -> list[dict[str, str | int]]:
    findings = []
    for line_number, line in enumerate(lines, start=1):
        stripped = line.strip()
        for pattern, reason in DANGEROUS_PATTERNS:
            if pattern.search(stripped):
                findings.append({
                    "line": line_number,
                    "command": stripped,
                    "reason": reason,
                })
    return findings

重複IPとサブネットオーバーラップ

import ipaddress
import re
from collections import Counter

IP_ADDRESS_RE = re.compile(
    r"^\s*ip address\s+"
    r"(?P<ip>\d{1,3}(?:\.\d{1,3}){3})\s+"
    r"(?P<mask>\d{1,3}(?:\.\d{1,3}){3})\b",
    re.I | re.M,
)

def extract_interfaces(config: str) -> list[dict[str, str]]:
    results = []
    current = None
    for line in config.splitlines():
        if line.startswith("interface "):
            current = line.split(maxsplit=1)[1]
            continue
        match = IP_ADDRESS_RE.match(line)
        if current and match:
            ip = match.group("ip")
            mask = match.group("mask")
            network = ipaddress.ip_interface(f"{ip}/{mask}").network
            results.append({"interface": current, "ip": ip, "network": str(network)})
    return results

def find_duplicate_ips(config: str) -> list[str]:
    ips = [entry["ip"] for entry in extract_interfaces(config)]
    counts = Counter(ips)
    return sorted(ip for ip, count in counts.items() if count > 1)

def find_subnet_overlaps(config: str) -> list[tuple[str, str]]:
    networks = [ipaddress.ip_network(entry["network"]) for entry in extract_interfaces(config)]
    overlaps = []
    for index, left in enumerate(networks):
        for right in networks[index + 1:]:
            if left.overlaps(right):
                overlaps.append((str(left), str(right)))
    return overlaps

管理プレーンチェック

VTYブロックをセクションごとに解析し、アクセスクラスのチェックが無関係な行にまたがらないようにします。

import re

def iter_blocks(config: str, starts_with: str) -> list[str]:
    blocks = []
    current: list[str] = []
    for line in config.splitlines():
        if line.startswith(starts_with):
            if current:
                blocks.append("\n".join(current))
            current = [line]
            continue
        if current:
            if line and not line.startswith(" "):
                blocks.append("\n".join(current))
                current = []
            else:
                current.append(line)
    if current:
        blocks.append("\n".join(current))
    return blocks

def check_vty_blocks(config: str) -> list[str]:
    issues = []
    for block in iter_blocks(config, "line vty"):
        if re.search(r"transport\s+input\s+.*telnet", block, re.I):
            issues.append("VTYでTelnetが許可されています。SSHのみに制限してください。")
        if not re.search(r"\baccess-class\s+\S+\s+in\b", block, re.I):
            issues.append("VTYブロックにインバウンドアクセスクラスのソース制限がありません。")
        if not re.search(r"\bexec-timeout\s+\d+\s+\d+\b", block, re.I):
            issues.append("VTYブロックに明示的なexec-timeoutがありません。")
    return issues

セキュリティ衛生チェック

SECURITY_PATTERNS = [
    (re.compile(r"\bsnmp-server community\s+(public|private)\b", re.I),
     "デフォルトのSNMPコミュニティが設定されています"),
    (re.compile(r"\bsnmp-server community\s+\S+", re.I),
     "SNMPv2コミュニティ文字列が設定されています。SNMPv3 authPrivを推奨"),
    (re.compile(r"\bip ssh version 1\b", re.I),
     "SSHバージョン1が有効です"),
    (re.compile(r"\benable password\b", re.I),
     "enableパスワードが設定されています。enable secretを使用してください"),
    (re.compile(r"\busername\s+\S+\s+password\b", re.I),
     "ローカルユーザーにpasswordの代わりにsecretを使用していません"),
]

BEST_PRACTICE_PATTERNS = [
    (re.compile(r"\bntp server\b", re.I), "NTPサーバ"),
    (re.compile(r"\bservice timestamps\b", re.I), "ログタイムスタンプ"),
    (re.compile(r"\blogging\s+\S+", re.I), "ログ出力先またはバッファ"),
    (re.compile(r"\bsnmp-server group\s+\S+\s+v3\s+priv\b", re.I), "SNMPv3 authPrivグループ"),
    (re.compile(r"\bbanner\s+(login|motd)\b", re.I), "ログインバナー"),
]

def check_security(config: str) -> list[str]:
    return [message for pattern, message in SECURITY_PATTERNS if pattern.search(config)]

def check_missing_hygiene(config: str) -> list[str]:
    return [
        f"{description}が欠落しています"
        for pattern, description in BEST_PRACTICE_PATTERNS
        if not pattern.search(config)
    ]

使用例

変更ウィンドウ前のプリフライト

  1. 貼り付ける正確なスニペットに対して危険コマンドチェックを実行します。
  2. 完全な候補構成に対して重複IPとサブネットオーバーラップチェックを実行します。
  3. 参照されているすべてのACL、ルートマップ、プレフィックスリストが存在することを確認します。
  4. 管理プレーンの変更前にロールバックコマンドと帯域外アクセスを確認します。

自動化のプリフライト

Netmiko、NAPALM、Ansible、またはベンダーAPI自動化が生成構成をプッシュする前に、検証をブロッキングゲートとして使用します。危険コマンドと認証情報はフェイルクローズ(閉鎖)とします。変更範囲外のベストプラクティスギャップについては警告します。

アンチパターン

  • 正規表現検証をデバイスパーサーとして扱うこと。
  • ドライランdiffなしで生成構成を適用すること。
  • 監視要件としてSNMPv2コミュニティ文字列を推奨すること。
  • 誤って無関係なセクションにまたがる可能性のある正規表現でVTYブロックをチェックすること。
  • カウンターやログを読む代わりにACLを無効にしてファイアウォールの動作をテストすること。

関連項目

  • エージェント: network-config-reviewer
  • エージェント: network-troubleshooter
  • スキル: network-interface-health

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.

関連スキル