Communitygithub.com

ホームラボVLANセグメンテーション

ホームネットワークをIoT、ゲスト、信頼済みデバイス、サーバー用にVLANで分割する方法。UniFi、pfSense/OPNsense、MikroTikを使用したスイッチトランク設定、ファイアウォールルール、ワイヤレスSSIDマッピングを含みます。ホームネットワークをUniFi、pfSense/OPNsense、またはMikroTik上でIoT、ゲスト、信頼済み、サーバーVLANに分割する際に使用します。

ホームラボVLANセグメンテーション とは?

このスキルは、ホームラボ環境でネットワークを論理的に分離するためのVLANセグメンテーションの包括的なガイドです。UniFi、pfSense/OPNsense、MikroTikといった主要なネットワークプラットフォームをサポートし、IoTデバイス、ゲスト、サーバー、管理用にそれぞれ独立したVLANを作成して、セキュリティを大幅に向上させます。具体的な設定例として、スイッチのトランクポートとアクセスポートの設定、SSIDからVLANへのマッピング、そして各プラットフォームごとのファイアウォールルールが詳細に説明されています。このスキルは、VLANを初めて導入するユーザーにも、既存のネットワークをより安全に再構成したい経験者にも役立ち、インターVLANルーティングのトラブルシューティングにも対応します。また、Pi-holeをサーバーVLANに配置したり、VLAN間のDNSアクセスを許可するなど、ベストプラクティスも含まれており、一般的なアンチパターン(ファイアウォールルールなしのVLAN作成や、管理VLANと同じネイティブVLANの使用)を避ける方法も示しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/homelab-vlan-segmentation

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

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

ドキュメント

ホームラボVLANセグメンテーション は何をしますか?

ホームネットワークを分離されたVLANに分割し、IoTデバイス、ゲスト、メインPC同士が通信できないようにする方法。ホームネットワークにとって最も影響力のあるセキュリティアップグレードです。

ここに示すファイアウォールルールはすべて、セグメント間に分離を追加するものです。既存の保護を削除することはありません。メンテナンスウィンドウで変更を適用し、各ステップの後にセグメント間の接続性を確認してから次のステップに進んでください。

使用するタイミング

  • ホームネットワークに初めてVLANを設定する場合
  • IoTデバイス(スマート電球、カメラ、テレビ)を信頼済みデバイスから分離する場合
  • ホームデバイスにアクセスできないゲストWi-Fiネットワークを作成する場合
  • VLANの仕組みを理解していない人に説明する場合
  • トランクポート、アクセスポート、SSIDからVLANへのマッピングを設定する場合
  • pfSense/OPNsense/UniFiでインターVLANルーティングやファイアウォールルールの問題をトラブルシューティングする場合

仕組み

VLANなし – フラットネットワーク:
  すべてのデバイスが192.168.1.0/24上
  スマートTV(潜在的なマルウェア)→ NAS、PC、すべてに到達可能

VLANあり:
  VLAN 10 — 信頼済み    192.168.10.0/24  (PC、スマートフォン、ノートPC)
  VLAN 20 — IoT        192.168.20.0/24  (スマートTV、電球、カメラ)
  VLAN 30 — サーバー    192.168.30.0/24  (NAS、Pi、VM)
  VLAN 40 — ゲスト      192.168.40.0/24  (訪問者Wi-Fi)
  VLAN 99 — 管理        192.168.99.0/24  (スイッチ/APのWeb UI)

  スマートTV → 192.168.10.0/24 および 192.168.30.0/24 へのアクセスをブロック
  ゲスト → インターネットのみ、ホームデバイスは見えない

VLAN設計テンプレート

VLAN  名前        サブネット             ゲートウェイ         目的
10    信頼済み     192.168.10.0/24     192.168.10.1    PC、スマートフォン、ノートPC
20    IoT         192.168.20.0/24     192.168.20.1    スマートホームデバイス
30    サーバー     192.168.30.0/24     192.168.30.1    NAS、Pi、セルフホステッド
40    ゲスト       192.168.40.0/24     192.168.40.1    訪問者Wi-Fi
99    管理         192.168.99.0/24     192.168.99.1    ネットワーク機器のWeb UI

例

UniFi APとマネージドスイッチを使用した典型的なホームラボ:

シナリオ: 3ベッドルームの家、UniFi Dream Machine + UniFi 8ポートスイッチ + 2台のAP

VLAN 10 — 信頼済み    192.168.10.0/24   MacBook、iPhone、iPad
VLAN 20 — IoT        192.168.20.0/24   Nestサーモスタット、Philips Hue、Ringドアベル、スマートTV
VLAN 30 — サーバー    192.168.30.0/24   Synology NAS (192.168.30.10)、Pi-hole (192.168.30.2)
VLAN 40 — ゲスト      192.168.40.0/24   訪問者Wi-Fi — インターネットのみ

SSID → VLANマッピング:
  "Home"      → VLAN 10 (WPA2、強力なパスワード、信頼済みデバイスのみ)
  "IoT"       → VLAN 20 (WPA2、個別のパスワード、設定のためにルーターに印刷)
  "Guest"     → VLAN 40 (WPA2、自由に共有できるシンプルなパスワード)

スイッチポートの動作:
  ポート1  → ルーターへのトランク (タグ付きVLAN 10,20,30,40,99)
  ポート2  → APへのトランク (タグ付きVLAN 10,20,40; APがSSIDごとのタグ付けを処理)
  ポート3  → アクセスVLAN 30 (NAS — タグなし、VLAN認識不要)
  ポート4  → アクセスVLAN 30 (Pi-hole — タグなし)
  ポート5–8 → アクセスVLAN 10 (有線ワークステーション)

ファイアウォールルールの適用 (すべてのルールは分離を追加し、既存の保護を削除しません):
  IoT → 信頼済み: ブロック
  IoT → サーバー: 192.168.30.2:53 (Pi-hole DNS許可) 以外はブロック
  IoT → インターネット: 許可
  ゲスト → ローカルネットワーク: ブロック
  ゲスト → インターネット: 許可
  信頼済み → すべて: 許可

UniFi設定

UniFiコントローラーでネットワークを作成

設定 → ネットワーク → 新しいネットワークを作成

各VLANについて:
  名前: IoT
  目的: コーポレート (DHCP + ルーティングを提供)
  VLAN ID: 20
  ネットワーク: 192.168.20.0/24
  ゲートウェイIP: 192.168.20.1
  DHCP: 有効
  DHCP範囲: 192.168.20.100 – 192.168.20.254

SSIDをVLANにマッピング (UniFi)

設定 → WiFi → 新しいWiFiを作成

  名前: IoT-Network
  パスワード: <個別のパスワード>
  ネットワーク: IoT  ← ここでVLANを選択
  # このSSIDに接続するすべてのデバイスはVLAN 20に配置されます

  名前: Guest
  パスワード: <ゲストパスワード>
  ネットワーク: Guest
  ゲストポリシー: 有効  ← ゲスト同士も分離します

UniFiファイアウォールルール (トラフィックルール)

設定 → トラフィック & セキュリティ → トラフィックルール

# IoTが信頼済みVLANにアクセスするのをブロック
  アクション: ブロック
  カテゴリ: ローカルネットワーク
  送信元: IoT (192.168.20.0/24)
  宛先: 信頼済み (192.168.10.0/24)

# IoTがインターネットのみにアクセスできるようにする
  アクション: 許可
  送信元: IoT
  宛先: インターネット

# ゲストがすべてのローカルネットワークにアクセスするのをブロック
  アクション: ブロック
  送信元: ゲスト
  宛先: ローカルネットワーク

pfSense / OPNsense設定

VLANを作成

インターフェース → 割り当て → VLAN → 追加

  親インターフェース: em1 (LAN NIC)
  VLANタグ: 20
  説明: IoT

# 各VLANに対して繰り返し、その後各VLANをインターフェースに割り当て:
インターフェース → 割り当て → 追加
  作成したVLANを選択 → 追加をクリック
  インターフェースを有効化し、IPをゲートウェイアドレスに設定 (192.168.20.1/24)

各VLANのDHCP

サービス → DHCPサーバー → VLANインターフェースを選択

  DHCPを有効化
  範囲: 192.168.20.100 ~ 192.168.20.254
  DNSサーバー: 192.168.30.2  ← Pi-holeのIP(ある場合)

ファイアウォールルール (pfSense/OPNsense)

# ルールは上から下へ処理され、最初に一致したルールが適用されます。

# IoTインターフェース (VLAN 20) 上:
  ルール1: IoT → Pi-hole DNSを許可  ← RFC1918ブロックルールの前に配置必須
    プロトコル: UDP/TCP
    送信元: IoTネット
    宛先: 192.168.30.2 ポート53
    アクション: 許可

  ルール2: IoT → RFC1918 (すべてのプライベートIP範囲) をブロック
    プロトコル: any
    送信元: IoTネット
    宛先: RFC1918 (192.168.0.0/16、10.0.0.0/8、172.16.0.0/12)
    アクション: ブロック

  ルール3: IoT → インターネットを許可
    プロトコル: any
    送信元: IoTネット
    宛先: any
    アクション: 許可

# 信頼済みインターフェース (VLAN 10) 上:
  すべてを許可 (信頼済みデバイスはすべてにアクセス可能)
    送信元: 信頼済みネット
    宛先: any
    アクション: 許可

# 特定のローカルサービスを必要とするIoTデバイス向けの追加例外:
  ルール2 (RFC1918ブロック) の前に挿入:
    プロトコル: TCP
    送信元: IoTネット
    宛先: 192.168.30.x ポート8123  ← Home Assistant
    アクション: 許可

MikroTik設定

# ステップ1: VLANフィルタリングが有効なブリッジを作成
/interface bridge
add name=bridge vlan-filtering=yes

# ステップ2: 物理ポートをブリッジに追加
# ルーター/アップリンクへのトランクポート (すべてのVLANにタグ付け)
/interface bridge port
add bridge=bridge interface=ether1 frame-types=admit-only-vlan-tagged

# 信頼済みデバイス用のアクセスポート (タグなしVLAN 10)
/interface bridge port
add bridge=bridge interface=ether2 pvid=10 frame-types=admit-only-untagged-and-priority-tagged

# IoTデバイス用のアクセスポート (タグなしVLAN 20)
/interface bridge port
add bridge=bridge interface=ether3 pvid=20 frame-types=admit-only-untagged-and-priority-tagged

# ステップ3: どのVLANがどのポートで許可されるかを定義
/interface bridge vlan
add bridge=bridge tagged=ether1 untagged=ether2 vlan-ids=10
add bridge=bridge tagged=ether1 untagged=ether3 vlan-ids=20

# ステップ4: ブリッジ上にVLANインターフェースを作成 (ゲートウェイIP)
/interface vlan
add interface=bridge name=vlan10 vlan-id=10
add interface=bridge name=vlan20 vlan-id=20

# ステップ5: ゲートウェイIPを割り当て
/ip address
add interface=vlan10 address=192.168.10.1/24
add interface=vlan20 address=192.168.20.1/24

# ステップ6: DHCPプールとサーバー
/ip pool
add name=pool-trusted ranges=192.168.10.100-192.168.10.254
add name=pool-iot ranges=192.168.20.100-192.168.20.254

/ip dhcp-server
add interface=vlan10 address-pool=pool-trusted name=dhcp-trusted
add interface=vlan20 address-pool=pool-iot name=dhcp-iot

/ip dhcp-server network
add address=192.168.10.0/24 gateway=192.168.10.1
add address=192.168.20.0/24 gateway=192.168.20.1

# ステップ7: ファイアウォール — IoTが信頼済みVLANにアクセスするのをブロック
/ip firewall filter
add chain=forward src-address=192.168.20.0/24 dst-address=192.168.10.0/24 \
    action=drop comment="IoTから信頼済みへのアクセスをブロック"

スイッチのトランクポートとアクセスポート

# トランクポート: 複数のVLANを運ぶ (タグ付き) — スイッチ間、スイッチとルーター間、スイッチとAP間を接続
# アクセスポート: 1つのVLANを運ぶ (タグなし) — エンドデバイス (PC、カメラ、NAS) に接続

# ルーターに接続するマネージドスイッチポートはトランクにすべき:
  許可VLAN: 10, 20, 30, 40, 99

# PCに接続するポートはアクセスポートにすべき:
  VLAN: 10 (信頼済み)
  タグ付けなし — PCはVLANを認識せず、気にする必要もありません

# APに接続するポートはトランクである必要があります:
  APが各SSIDからのトラフィックを正しいVLAN IDでタグ付けします
  許可VLAN: 10, 20, 40  (APが提供するSSID)

アンチパターン

# 悪い例: ファイアウォールルールを追加せずにVLANを作成する
# ファイアウォールルールがないVLANはセキュリティを提供しません — インターVLANルーティングはデフォルトで開かれています
# 良い例: VLANを作成した直後に明示的なブロックルールを追加する

# 悪い例: Pi-holeをIoT VLANに配置する
# IoTデバイスは到達できますが、信頼済みデバイスは到達できません (追加ルールなし)
# 良い例: Pi-holeをサーバーVLANに配置し、すべてのVLANがポート53に到達できるルールを追加する

# 悪い例: ネイティブVLANと管理VLANが同じ
# タグなしトラフィックが管理VLANに到達すると、VLANホッピング攻撃が可能になります
# 良い例: 専用の未使用VLANをネイティブとして使用 (例: VLAN 999)、管理トラフィックはタグ付きのままにする

# 悪い例: IoT SSIDと信頼済みSSIDで同じWi-Fiパスワードを使用
# パスワードを知った人は誰でもIoTデバイスを間違ったセグメントに接続できます

ベストプラクティス

  • 4つのVLANから始める: 信頼済み、IoT、サーバー、ゲスト — 必要に応じて追加
  • Pi-holeはサーバーVLAN (192.168.30.x) に配置する
  • すべてのVLANからPi-holeのIPへのDNS (ポート53) を許可するファイアウォールルールを追加する — RFC1918ブロックルールの前に
  • ルールを変更するたびに分離をテストする: IoT VLANから信頼済みデバイスにpingを試みる — 失敗するはず
  • スイッチとAPのWeb UIには管理VLANを使用し、アクセスを信頼済みVLANのみに制限する
  • VLAN設計を表に文書化する (VLAN ID、名前、サブネット、目的)

関連スキル

  • homelab-network-setup
  • homelab-pihole-dns
  • homelab-wireguard-vpn

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.

関連スキル