安全

vmware-nsx-security

试用

通过 21 个 MCP 工具或配套 CLI,管理 NSX-T 分布式防火墙策略、安全组、VM 标签、Traceflow 与 IDPS。

它能做什么

面向 NSX-T / NSX 4.x Policy API 的域内安全技能,提供 21 个 MCP 工具(10 个只读 + 11 个写),覆盖 DFW 策略与规则的增删改查、安全组、VM 标签、Traceflow 报文路径诊断,以及 IDPS 配置与签名状态查询。配套 `vmware-nsx-security` CLI 支持 `--dry-run` 预览和 `--target` 多 NSX Manager 切换;`init` 负责引导式写入配置与 .env(权限 600),`doctor` 用于连通性校验。列表类接口统一返回 `{items, returned, limit, total, truncated, hint}` 分页信封,调用方需先看 `truncated` 再判断是否取全。

什么时候用它

  • 用 DFW 策略与安全组落地应用层微分段
  • 为 VM 施加或审计 NSX 标签,驱动安全组成员关系
  • 运行 Traceflow 验证 DFW 规则命中链,再决定是否开启默认拒绝
  • 查看 IDPS 配置、自动更新与全局签名状态

技能文档

VMware NSX Security

Disclaimer: This is a community-maintained open-source project and is not affiliated with, endorsed by, or sponsored by VMware, Inc. or Broadcom Inc. "VMware" and "NSX" are trademarks of Broadcom. Source code is publicly auditable at github.com/vmware-skills/VMware-NSX-Security under the MIT license.

VMware NSX DFW microsegmentation and security — 21 MCP tools for distributed firewall, security groups, VM tags, Traceflow, and IDPS.

Domain-focused security skill for NSX-T / NSX 4.x Policy API. Companion skills: vmware-nsx (networking), vmware-aiops (VM lifecycle), vmware-monitor (read-only monitoring), vmware-avi (AVI/ALB/AKO), vmware-harden (compliance baselines). | vmware-pilot (workflow orchestration) | vmware-policy (audit/policy)

What This Skill Does

CategoryToolsCount
DFW Policylist, get, create, update, delete, list rules6
DFW Rulescreate, update, delete, get stats4
Security Groupslist, get, create, delete4
VM Tagslist VM tags, apply tag, remove tag3
Traceflowrun trace, get result2
IDPSlist profiles, get status2

Total: 21 tools (10 read-only + 11 write)

Quick Install

uv tool install vmware-nsx-security
vmware-nsx-security init      # guided setup: writes config + .env (chmod 600, password grep-safe), then verifies
vmware-nsx-security doctor

When to Use This Skill

  • List, create, or modify DFW security policies and rules
  • Create security groups based on VM tags, IP ranges, or segment membership
  • Apply or list NSX tags on virtual machines
  • Run Traceflow to trace a packet path and diagnose drop reasons
  • Check IDPS profile configuration, signature status, and global IDS settings
  • Implement zero-trust microsegmentation between application tiers

Use companion skills for:

  • NSX segments, gateways, NAT, routing, IPAM → vmware-nsx
  • VM lifecycle, deployment, guest ops → vmware-aiops
  • vSphere inventory, health, alarms, events → vmware-monitor
  • Storage: iSCSI, vSAN, datastores → vmware-storage
  • Tanzu Kubernetes → vmware-vks
  • Load balancing, AVI/ALB, AKO, Ingress → vmware-avi
User IntentRecommended Skill
NSX security: DFW rules, security groups, IDS/IPSvmware-nsx-security ← this skill
NSX networking: segments, gateways, NAT, routingvmware-nsx
Read-only vSphere monitoring, alarms, eventsvmware-monitor
VM lifecycle, deployment, guest opsvmware-aiops
Storage: iSCSI, vSAN, datastoresvmware-storage
Tanzu Kubernetesvmware-vks
Multi-step workflows with approvalvmware-pilot
Compliance baselines (CIS / 等保 / PCI-DSS), drift detection, LLM remediation advisorvmware-harden (uv tool install vmware-harden)
Load balancer, AVI, ALB, AKO, Ingressvmware-avi (uv tool install vmware-avi)
Audit log queryvmware-policy (vmware-audit CLI)

Common Workflows

Implement App-Tier Microsegmentation

Pre-flight (judgment — DFW changes can lock everyone out):

  • Default-allow first: the very first rule in any new policy must be ALLOW for management traffic (DNS, NTP, vCenter, SSH from jumphost). Without it, the moment you add a default-deny you blackhole your own access.
  • Tag inventory: confirm the VMs you intend to protect actually carry the tag (tag list ). A group based on a non-existent tag matches zero VMs — the policy will appear "applied" but enforce nothing.
  • Category choice: Application for app-tier microseg (rules evaluated late, after Infrastructure rules pass through). Using Emergency for routine rules will starve real incident-response capacity.
  • Stateless? Default to stateful — NSX DFW is stateful and almost no rule should be stateless. Stateless = both directions must be explicitly allowed.
  • Always start with logging enabled on new rules; disable later once verified. Silent drops are the worst kind of bug.

Steps:

  1. Tag the VMs first (see workflow below) — empty groups = no enforcement
  2. Create groups via the create_group MCP tool with tag_scope/tag_value (the tag condition is matched as "scope|tag", e.g. tier|web; note multiple criteria types — tag/IP/segment — are ORed, not ANDed)
  3. policy create app-microseg --category Application
  4. Add rules in order: ALLOW management → ALLOW intra-tier → ALLOW web→app on app-port → DROP any-any with logging
  5. Verify with traceflow (see below) before enabling default-deny

Apply NSX Tags to VMs

Judgment: tags drive group membership which drives DFW enforcement. A misspelled tag silently excludes a VM from protection. Always re-list after applying.

  1. tag list my-web-vm-01 → record the VM external ID, also see what tags already exist (avoid duplicates / typo collisions)
  2. tag apply --scope tier --value web
  3. Verify: tag list my-web-vm-01 again → confirm the new tag is present AND no unexpected ones

Trace a Packet with Traceflow

Judgment: traceflow is your verification mechanism for any DFW change. Run it before enabling deny rules and after every rule modification. Don't trust "looks right in the UI."

  1. Get source VM's logical port ID via vmware-nsx troubleshoot vm-segment
  2. traceflow run --src-ip --dst-ip --proto TCP --dst-port
  3. Inspect the DFW hit chain: which rule matched, ALLOW or DROP, and at which transport node
  4. Common failure: rule matches at category Application but is shadowed by an earlier DROP at category Environment — read the trace top-to-bottom, not just the final verdict

Check DFW Policy Hit Counts

vmware-nsx-security policy list
vmware-nsx-security rule list 
vmware-nsx-security rule stats  

Multi-Target Operations

All commands accept --target to operate against a specific NSX Manager:

# Default target
vmware-nsx-security policy list

# Specific target
vmware-nsx-security policy list --target nsx-prod
vmware-nsx-security group list --target nsx-lab

Usage Mode

ScenarioRecommendedWhy
Local/small models (Ollama, Qwen)CLI~2K tokens vs ~8K for MCP
Cloud models (Claude, GPT-4o)EitherMCP gives structured JSON I/O
Automated pipelinesMCPType-safe parameters, structured output

Running with local or small models? See references/agent-guardrails.md for explicit operating rules.

MCP Tools (21 — 10 read, 11 write)

All MCP tools accept an optional target parameter.

list_dfw_policies, list_dfw_rules, list_groups and list_idps_profiles return the family list envelope — {items, returned, limit, total, truncated, hint} — rather than a bare array. Read the rows from items and check truncated before concluding a listing is complete; a 50-row default page looks identical to a whole estate without it. total is stated only where the scan proved it: it is the real count on an unfiltered listing that stayed under the 1000-item get_all cap, and null for name-filtered listings, capped scans, and list_dfw_rules (whose fetch is bounded to the requested window). A null total with truncated: true means "there may be more" — page with offset to confirm. Errors return {error, hint} (a dict, not a one-element list).

CategoryToolTypeDescription
DFW Policylist_dfw_policiesReadList all DFW security policies with category, sequence, and rule count
get_dfw_policyReadGet policy details: category, stateful, locked, scope, tags
create_dfw_policyWriteCreate a new DFW policy with category and sequence number
update_dfw_policyWritePartial update: display_name, description, sequence_number, stateful
delete_dfw_policyWriteDelete policy — refuses if active rules exist
list_dfw_rulesReadList rules in a policy: action, sources, destinations, services
DFW Rulescreate_dfw_ruleWriteCreate rule with sources/destinations/services/action/scope
update_dfw_ruleWritePartial update rule fields
delete_dfw_ruleWriteDelete a rule from a policy
get_dfw_rule_statsReadGet packet/byte/session/hit counts and popularity_index for a rule
Security Groupslist_groupsReadList all security groups with expression count
get_groupReadGet group details: expression criteria + up to 50 effective VM members
create_groupWriteCreate group with tag/IP/segment membership criteria (tag matched as "scope|tag"; multiple criteria ORed)
delete_groupWriteDelete group — refuses if referenced by DFW rules/scopes, or if the reference scan fails
VM Tagslist_vm_tagsReadList NSX tags on a VM by display name
apply_vm_tagWriteApply a scope/value tag to a VM (additive, preserves existing tags)
remove_vm_tagWriteRemove a scope/value tag from a VM (other tags preserved; may change dynamic group membership)
Traceflowrun_traceflowWriteInject probe packet; returns operation_state + hop-by-hop observations (by resource_type) + dfw_hits
get_traceflow_resultReadCheck operation_state/observations of an existing traceflow
IDPSlist_idps_profilesReadList IDPS profiles with severity and filter criteria
get_idps_statusReadGet IDPS signature status + global IDS settings (auto_update, syslog export)

CLI Quick Reference

# DFW Policy
vmware-nsx-security policy list [--target ]
vmware-nsx-security policy get 
vmware-nsx-security policy create  --name "Display Name" --category Application [--dry-run]
vmware-nsx-security policy delete  [--dry-run]

# DFW Rules
vmware-nsx-security rule list 
vmware-nsx-security rule stats  
vmware-nsx-security rule delete   [--dry-run]

# Security Groups
vmware-nsx-security group list
vmware-nsx-security group get 
vmware-nsx-security group delete  [--dry-run]

# Tags
vmware-nsx-security tag list 
vmware-nsx-security tag apply  --scope env --value production [--dry-run]
vmware-nsx-security tag remove  --scope env --value production [--dry-run]

# Traceflow
vmware-nsx-security traceflow run  --src-ip <src-ip> --dst-ip <dst-ip>

# IDPS
vmware-nsx-security idps profiles
vmware-nsx-security idps status

# Diagnostics
vmware-nsx-security doctor [--skip-auth]

Troubleshooting

"Cannot delete policy — active rules exist"

delete_dfw_policy checks for active rules before deleting. Use vmware-nsx-security rule list to see which rules need to be removed first. Then delete each rule individually before retrying the policy deletion.

"Cannot delete group — referenced by DFW rules"

delete_group scans all policies for references to the group in rule source_groups, destination_groups, and applied-to scope, plus policy-level scope. Remove the group from those references first (via update_dfw_rule replacing the group path with 'ANY' or another group), then retry. If the error says the reference scan itself failed, deletion was aborted as a precaution — verify NSX connectivity with vmware-nsx-security doctor and retry.

"No virtual machine named ... exists in the NSX fabric inventory"

list_vm_tags looks up VMs by display name via the NSX fabric API. Common causes:

  1. Display name mismatch — the name in NSX Manager may differ from vCenter. Check vmware-monitor vm list for the exact NSX fabric display name.
  2. VM not registered — newly deployed VMs may take a minute to appear in the NSX fabric.
  3. Multiple VMs with the same name — use apply_vm_tag with the specific external_id.

Traceflow returns empty observations

  1. If operation_state is IN_PROGRESS, the trace has not finished — poll again with get_traceflow_result .
  2. Verify the src_lport_id is the correct logical port attachment UUID — not the segment port path. Get it from vmware-nsx troubleshoot vm-segment .
  3. The source VM must be powered on and connected to an NSX overlay segment.
  4. If the VM is on a VLAN-backed segment, Traceflow is not supported.
  5. NSX Manager requires the transport node hosting the source VM to be reachable. Check vmware-nsx health transport-nodes.

DFW rule stats show zero hits

A newly created rule will have zero hit counts until traffic matches it. If expected traffic still shows zero:

  1. Confirm the rule is not disabled (disabled: false in list_dfw_rules output).
  2. Check that source/destination group membership is correct using get_group.
  3. Verify rule sequence number — a lower-sequence rule with ALLOW/DROP may be matching first.

"Password not found" error

Password variable convention: VMWARE_NSX_SECURITY__PASSWORD where hyphens are replaced by underscores. For target nsx-prod: VMWARE_NSX_SECURITY_NSX_PROD_PASSWORD. Check ~/.vmware-nsx-security/.env.

invalid peer certificate: UnknownIssuer (uvx)

Corporate TLS proxy not trusted by uv's bundled cert store. Use the v1.5.15+ single-command form vmware-nsx-security mcp (no PyPI re-resolve), or export UV_NATIVE_TLS=true to make uv use the system cert store.

Safety

  • Audit logging: All write operations logged to ~/.vmware/audit.db (SQLite WAL, via vmware-policy) with timestamp, user, target, operation, parameters, and result
  • Dependency checks: delete_dfw_policy checks for active rules; delete_group checks for DFW rule references — prevents accidental cascade failures
  • Input validation: All IDs validated against safe character set (alphanumerics, hyphens, underscores, dots); all text fields sanitized to strip control characters
  • Dry-run mode: CLI write commands support --dry-run to preview API calls without executing
  • Double confirmation: CLI destructive operations (delete) require two separate confirmation prompts
  • Credential safety: Passwords loaded only from environment variables (.env file), never from config.yaml
  • No networking changes: Cannot modify segments, gateways, NAT, or routing — that scope belongs to vmware-nsx
  • Prompt injection defense: All API-sourced strings passed through _sanitize() before inclusion in tool output

Setup

uv tool install vmware-nsx-security
mkdir -p ~/.vmware-nsx-security
cp config.example.yaml ~/.vmware-nsx-security/config.yaml
# Edit config.yaml with your NSX Manager targets

# Add to ~/.vmware-nsx-security/.env (create if missing, chmod 600):
# VMWARE_NSX_SECURITY_NSX_PROD_PASSWORD=
chmod 600 ~/.vmware-nsx-security/.env

vmware-nsx-security doctor

All tools are automatically audited via vmware-policy. Audit logs: vmware-audit log --last 20

Full setup guide: see references/setup-guide.md

Architecture

User (natural language)
  |
AI Agent (Claude Code / Goose / Cursor)
  | reads SKILL.md
vmware-nsx-security CLI or MCP server (stdio transport)
  | NSX Policy API (REST/JSON over HTTPS)
NSX Manager
  |
DFW Policies / Rules / Security Groups / Tags / IDPS

The MCP server uses stdio transport (local only, no network listener). All connections to NSX Manager use HTTPS on port 443.

Audit & Safety

All operations are automatically audited via vmware-policy (@vmware_tool decorator):

  • Every tool call logged to ~/.vmware/audit.db (SQLite, framework-agnostic)
  • Policy rules enforced via ~/.vmware/rules.yaml (deny rules, maintenance windows, risk levels)
  • Risk classification: each tool tagged as low/medium/high/critical
  • View recent operations: vmware-audit log --last 20
  • View denied operations: vmware-audit log --status denied

vmware-policy is automatically installed as a dependency — no manual setup needed.

License

MIT — github.com/vmware-skills/VMware-NSX-Security

常见问题

与 vmware-nsx 的边界在哪里?
本技能只负责 DFW 策略、规则、安全组、VM 标签、Traceflow 和 IDPS;段、网关、NAT、路由、IPAM 等网络相关能力请走 vmware-nsx,负载均衡/AVI/AKO 请走 vmware-avi。
list_dfw_policies 等列表接口的返回结构怎么解读?
返回的是 `{items, returned, limit, total, truncated, hint}` 信封而非裸数组,列表行要读 `items`,结尾前务必看 `truncated`;`total` 仅在未过滤且未触达 1000 条上限时为真实计数,其余场景下可能为 `null`。
怎么安装并验证 CLI?
执行 `uv tool install vmware-nsx-security` 安装,再用 `vmware-nsx-security init` 完成引导配置(自动写入 .env 并设为 600 权限),最后用 `vmware-nsx-security doctor` 检查 NSX 连通性。

相关技能

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván559 次安装18 星标

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai22 次安装8 星标

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván855 次安装69 星标

从 AdMapix API 拉取广告创意、应用、榜单和收入预估等数据,原样返回结构化 JSON。

作者 fly0pants4.3k 次安装296 星标

zw008 的更多技能

浏览全部技能

通过 33 个 MCP 工具查询 VMware Aria Operations 的指标、告警、容量、异常与报告。

作者 zw00853 次安装

用 28 个读写工具管理 AVI 虚拟服务、AKO Ingress 与后端成员,覆盖 NSX ALB 运维场景。

作者 zw00851 次安装

用自然语言管理 vSphere Kubernetes Service 的 Supervisor 集群、命名空间与 TKC 集群生命周期。

作者 zw00851 次安装

通过 33 个 CLI/MCP 工具管理 NSX-T 网段、Tier-0/Tier-1 网关、NAT、静态路由与 IP 池。

作者 zw00850 次安装

为 VMware 多步操作设计审批流程、追踪状态、失败时自动回滚的统一编排入口。

作者 zw00824 次安装1 星标

针对 vSphere/ESXi/NSX 环境的合规扫描与基线比对,覆盖 CIS、STIG、等保 2.0 三级、PCI-DSS、IT-Grundschutz、NIS2。

作者 zw00834 次安装