Files
notes/projects/gg/avahi_mdns-reflector/20250714-esxi-networking.md
Petar Cubela 252a91dbcc ]
2025-07-15 15:36:24 +02:00

3.3 KiB

You're absolutely correct. In VMware ESXi, the "VLAN ID" field in the "Add Port Group" wizard is only for Access VLANs (single VLAN). To configure a trunk port group (multiple VLANs), you need to manually edit the port group settings after creation. Here's the step-by-step guide to configure a trunk port group with multiple VLANs:


Step-by-Step: Configure Trunk Port Group in ESXi

1. Create the Port Group (Access Mode)

  1. Go to vSphere Client > Networking > Switches > vSwitches.
  2. Select the vSwitch you want to use.
  3. Click Add Port Group.
  4. Enter a Name (e.g., MGMT_VLAN).
  5. Select VLAN Type: Access (this is the default).
  6. Enter the VLAN ID for the management VLAN (e.g., 10).
  7. Click OK.

⚠️ Note: This creates an Access VLAN (single VLAN). To enable trunking, you must edit the port group manually.


2. Edit the Port Group to Enable Trunking

  1. Right-click the port group (e.g., MGMT_VLAN) and select Edit Settings.
  2. Under VLAN Settings, change VLAN Type to Trunk.
  3. In the Tagged VLANs field, enter the VLAN IDs you want to allow (e.g., 10,20,30).
    • Important: Separate VLAN IDs with commas (no spaces).
  4. Click OK.

Example: If your management VLAN is 10 and you need mDNS traffic on VLANs 20 and 30, enter 10,20,30 in the Tagged VLANs field.


3. Assign the VM to the Port Group

  1. Go to the VM's settings.
  2. Under Network Adapter, select the port group you configured (MGMT_VLAN).
  3. Ensure the VM is assigned to the correct VLANs (the port group will handle the tagging).

Key Notes

  • Trunking is not available in the "Add Port Group" wizard. You must manually edit the port group to enable trunking.
  • Physical Switch Configuration: Ensure the physical switch port connected to the ESXi host is configured as a trunk with the same VLANs (e.g., 10,20,30).
  • VM Configuration: The VM will receive an IP address from the untagged VLAN (e.g., VLAN 10) and will have access to the tagged VLANs (e.g., 20,30) via the trunk port group.

Why This Works

  • Trunking allows the VM to communicate on multiple VLANs via a single physical interface.
  • The untagged VLAN (e.g., 10) is used for management or default traffic.
  • The tagged VLANs (e.g., 20,30) are used for specific services (like mDNS).

Alternative: Use Command Line (PowerCLI)

If you prefer using the command line, you can configure trunking with PowerCLI:

# Connect to vCenter
Connect-VIServer -Server vcenter.example.com

# Get the vSwitch and port group
$vs = Get-VirtualSwitch -Name "vSwitch0"
$pg = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "MGMT_VLAN"

# Set the port group to Trunk with VLANs 10,20,30
Set-VMHostNetworkAdapter -VMHost $vmhost -NetworkAdapter $pg -VlanId 10,20,30

Summary

  • Trunk port groups in ESXi require manual editing after creation.
  • Use the Tagged VLANs field to specify multiple VLANs (e.g., 10,20,30).
  • Ensure the physical switch is also configured as a trunk with the same VLANs.

Let me know if you need help verifying the switch configuration or troubleshooting VLAN tagging! 🛠️