Communitygithub.com

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

UniFi、pfSense/OPNsense、MikroTikを使用して、IoT、ゲスト、信頼済み、サーバートラフィックをVLANでセグメント化します。スイッチトランク設定、ファイアウォールルール、ワイヤレスSSIDマッピングを含みます。

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

このスキルは、ホームネットワークをVLANで分離し、IoTデバイス、ゲスト、信頼済みデバイス間の通信を遮断する方法を提供します。UniFi Dream Machine、pfSense/OPNsense、MikroTikを対象とし、VLAN作成からスイッチポートのトランク/アクセス設定、ファイアウォールルール、SSIDマッピングまでを網羅します。具体的な設定例(例:3ベッドルーム住宅の構成)やアンチパターン(例:ファイアウォールルールなしのVLAN作成)を示し、セキュリティ向上に重点を置いています。ルールの追加は既存の保護を削除せず、変更はメンテナンスウィンドウで行い、各ステップ後のセグメント間接続を確認するよう推奨しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/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、ラズパイ、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、ラズパイ、セルフホスト
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アクセスポイントとマネージドスイッチを使用した一般的なホームラボ:

シナリオ: 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="Block IoT to Trusted"

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

# トランクポート: 複数の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/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.

関連スキル