Mục Tiêu Buổi Học
- So sánh vSS và vDS — hiểu sự khác biệt và khi nào chọn loại nào
- Tạo Standard vSwitch với nhiều Port Groups và cấu hình VLAN
- Triển khai Distributed vSwitch (vDS) quản lý tập trung
- Cấu hình LACP (802.3ad) cho link aggregation
- Thiết lập Network I/O Control (NIOC) đảm bảo QoS
- Áp dụng security hardening cho Port Groups
LÝ THUYẾT — MODULE 4
4.1 Standard vSwitch (vSS) vs Distributed vSwitch (vDS)
| Tính năng | vSS | vDS |
|---|---|---|
| Phạm vi cấu hình | Per-host | Tập trung tại vCenter |
| Port Mirroring | Không | Có |
| NetFlow | Không | Có |
| LACP (802.3ad) | Không | Có |
| Network I/O Control | Không | Có |
| Private VLAN | Không | Có |
| Traffic Shaping | Ingress chỉ | Ingress + Egress |
| Rollback/Recovery | Không | Có |
| Yêu cầu license | Essentials+ | Enterprise Plus |
Kiến Trúc vSwitch
Physical Network (Trunk/Access Port)
│
Physical NIC (vmnic)
│
┌─────▼──────────────────────────────┐
│ vSwitch (vSS/vDS) │
│ ┌─────────┐ ┌─────────────────┐ │
│ │ Uplinks │ │ Port Groups │ │
│ │(vmnics) │ │ ┌───────────┐ │ │
│ │ │ │ │Management │ │ │
│ │ vmnic0 │ │ ├───────────┤ │ │
│ │ vmnic1 │ │ │VM Network │ │ │
│ └─────────┘ │ ├───────────┤ │ │
│ │ │ vMotion │ │ │
│ │ └───────────┘ │ │
└───────────────┴─────────────────┴──┘
VLAN Modes trong vSphere
| Mode | VLAN ID | Trunk to VM | Use case |
|---|---|---|---|
| No VLAN | 0 | No | Single network |
| VLAN | 1-4094 | No | VM dùng 1 VLAN |
| VLAN Trunking | 4095 | Yes | VM cần nhiều VLANs |
| Private VLAN | — | Yes | vDS only |
vDS 8.0 — Thông Số Quan Trọng
- Max ports per vDS: 60,000 (vSphere 8.0)
- Port binding types: Static (default), Dynamic, Ephemeral
- Network I/O Control: vSphere 8.0 dùng NIOC v3
- NSX: sản phẩm riêng biệt (không bao gồm trong vSphere license) — cần license NSX riêng cho advanced network virtualization
NIC Teaming Policies
- Route based on originating virtual port (default): simple, no 802.3ad required
- Route based on IP hash: cần 802.3ad/LACP trên physical switch
- Route based on source MAC hash: đơn giản, không cần config switch
- Use explicit failover order: active/standby, cho Fault Tolerance
LAB THỰC HÀNH — MODULE 4
Lab 4.1 — Tạo Standard vSwitch với Nhiều Port Groups
Trên ESXi Host Client hoặc vSphere Client:
1. Tạo vSwitch mới:
Host → Configure → Networking → Virtual Switches
→ Add Standard Virtual Switch
Name: vSwitch1
Uplink: vmnic1 (dành cho VM traffic)
MTU: 1500
2. Tạo Port Groups:
a) VM-Production (VLAN 100):
Name: PG-Production
VLAN ID: 100
b) VM-Development (VLAN 200):
Name: PG-Development
VLAN ID: 200
c) DMZ (VLAN 300):
Name: PG-DMZ
VLAN ID: 300
3. Cấu hình Security Policy trên Port Group:
PG-Production:
Promiscuous Mode: Reject
MAC Address Changes: Reject ← security best practice
Forged Transmits: Reject ← security best practice
4. Cấu hình NIC Teaming (Active/Standby):
vSwitch1 → Edit Settings → Teaming and Failover
Active: vmnic1
Standby: vmnic2
Network Failure Detection: Link status only
Lab 4.2 — Tạo Distributed Virtual Switch (vDS)
Yêu cầu: vCenter + Enterprise Plus license
1. Tạo vDS:
vSphere Client → Networking → New Distributed Switch
Name: vDS-Production
Version: 8.0.0
Number of Uplinks: 2
Create default port group: vDS-Production-DVUplinks
2. Add Hosts và Uplinks:
Right-click vDS → Add and Manage Hosts
→ Add Hosts
Chọn: ESXi-01, ESXi-02, ESXi-03
Assign Physical Adapters:
ESXi-01: vmnic2 → Uplink 1, vmnic3 → Uplink 2
ESXi-02: vmnic2 → Uplink 1, vmnic3 → Uplink 2
ESXi-03: vmnic2 → Uplink 1, vmnic3 → Uplink 2
Migrate VMkernel:
Migrate vmk0 (Management) → giữ trên vSwitch0
Tạo mới vmk1 (vMotion) → trên vDS
3. Tạo Distributed Port Groups:
Right-click vDS → New Distributed Port Group
a) DPG-VM-Production:
VLAN Type: VLAN
VLAN ID: 100
Port binding: Static
b) DPG-vMotion:
VLAN Type: VLAN
VLAN ID: 10
✓ Override port policies: Enabled
Network I/O Control: Enabled
4. Cấu hình LACP (802.3ad):
vDS → Configure → LACP
→ New LAG (Link Aggregation Group)
Name: LAG-ESXi01
Number of ports: 2
Mode: Active
Load balancing: Source and destination IP and MAC
Lab 4.3 — Network I/O Control (NIOC)
Mục tiêu: Đảm bảo bandwidth cho vMotion không ảnh hưởng VM traffic
vDS → Configure → Resource Allocation → System Traffic Traffic Type | Shares | Limit --------------------|--------|------- vMotion | 50 | 4 Gbps Management | 50 | 1 Gbps vSAN | 100 | Unlimited Virtual Machine | 100 | Unlimited
ỨNG DỤNG DOANH NGHIỆP — MODULE 4
Các pattern thiết kế mạng ảo hóa thực tế tại doanh nghiệp — từ vDS architecture, LACP/802.3ad, VLAN design đến NIOC và network documentation.
1. vDS Design cho Enterprise — Tách biệt Traffic Types
Mô hình 2 vDS tiêu chuẩn — vDS-Infrastructure cho management/vMotion/storage và vDS-VM-Traffic cho workload VMs.
### TOPOLOGY — Dual vDS Enterprise Design ┌─────────────────────────────────────────────────────────────────┐ │ ESXi Host (4 NICs) │ │ │ │ vmnic0 ────┐ vmnic2 ────┐ │ │ ├── vDS-Infrastructure ├── vDS-VM-Traffic │ │ vmnic1 ────┘ (Mgmt+vMotion+Storage) ├── (VM Workloads) │ │ vmnic3 ────┘ LACP Active/Active │ │ │ │ vDS-Infrastructure Port Groups: │ │ DPG-Management VLAN 10 vmk0 10.100.10.x/24 │ │ DPG-vMotion VLAN 20 vmk1 10.100.20.x/24 │ │ DPG-vSAN VLAN 30 vmk2 10.100.30.x/24 │ │ DPG-iSCSI-A VLAN 40 vmk3 10.100.40.x/24 │ │ DPG-iSCSI-B VLAN 41 vmk4 10.100.41.x/24 │ │ │ │ vDS-VM-Traffic Port Groups: │ │ DPG-VLAN100-Production VLAN 100 │ │ DPG-VLAN200-Development VLAN 200 │ │ DPG-VLAN300-DMZ VLAN 300 │ │ DPG-VLAN400-Management VLAN 400 │ └─────────────────────────────────────────────────────────────────┘ ### TẠI SAO tách 2 vDS: ✓ Fault isolation: vấn đề VM traffic không ảnh hưởng vMotion/storage ✓ QoS: NIOC áp dụng riêng biệt cho từng traffic type ✓ Security: quản lý NIC teaming policy độc lập ✓ License: vDS cần Enterprise Plus license (1 vDS per host max = không giới hạn port groups)
2. LACP / 802.3ad Port Channel Configuration
LACP cho phép aggregate bandwidth nhiều NIC — nhưng phải cấu hình đồng bộ cả physical switch và vDS.
Điều kiện bắt buộc để dùng LACP trên vDS
- Physical switch phải hỗ trợ LACP (802.3ad) và được cấu hình Port Channel trước
- vDS version 5.1+ — chỉ hỗ trợ trên vDS (không có trên vSS)
- NIC Teaming Policy phải là "Route based on IP hash" khi dùng LACP
- Số NIC trong LAG phải bằng số port trong Port Channel trên switch
### PowerCLI — Tạo LACP LAG trên vDS
Connect-VIServer vcsa-hn-prod.hoatranlab.io.local
# 1. Lấy vDS object
$vds = Get-VDSwitch "vDS-VM-Traffic"
# 2. Tạo LAG (Link Aggregation Group)
$lag = $vds | New-VDLacpGroup -Name "LAG-VM-Traffic" `
-Uplink 2 `
-Mode Active `
-LoadBalancingMode LoadBalanceIP
# 3. Gán LAG vào Port Group (thay vì dùng uplinks thường)
Get-VDPortgroup "DPG-VLAN100-Production" | Set-VDUplinkTeamingPolicy `
-ActiveUplinkPort $lag.Name
# 4. Assign NIC vào LAG trên từng host
$vmhost = Get-VMHost "esxi-hn-r01-01.hoatranlab.io.local"
$vmhostnetworkadapter = $vmhost | Get-VMHostNetworkAdapter -Physical | Where{$_.Name -in "vmnic2","vmnic3"}
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $vmhostnetworkadapter -DistributedSwitchUplinkPort "lag-uplink1","lag-uplink2"
Write-Host "LACP LAG configured. Verify with: Get-VDLacpGroup -VDSwitch $($vds.Name)"
### Cisco Switch — Port Channel configuration (phía physical switch) ! Cấu hình trên switch trước khi bật LACP trên vDS interface GigabitEthernet1/0/1 description ESXi-HN-R01-01 vmnic2 switchport mode trunk switchport trunk allowed vlan 100,200,300,400 channel-group 1 mode active ! LACP active spanning-tree portfast trunk interface GigabitEthernet1/0/2 description ESXi-HN-R01-01 vmnic3 switchport mode trunk switchport trunk allowed vlan 100,200,300,400 channel-group 1 mode active spanning-tree portfast trunk interface Port-channel1 description vDS-VM-Traffic ESXi-HN-R01-01 switchport mode trunk switchport trunk allowed vlan 100,200,300,400
3. VLAN Tagging Design Matrix
Ma trận phân bổ VLAN chuẩn cho môi trường doanh nghiệp — tham khảo khi thiết kế hạ tầng mới.
| VLAN ID | Tên / Mục đích | Subnet | Port Group | vmknic | Traffic Type |
|---|---|---|---|---|---|
| 10 | ESXi Management | 10.100.10.0/24 | DPG-Management | vmk0 | Management |
| 20 | vMotion | 10.100.20.0/24 | DPG-vMotion | vmk1 | vMotion |
| 30 | vSAN | 10.100.30.0/24 | DPG-vSAN | vmk2 | vSAN |
| 40/41 | iSCSI-A / iSCSI-B | 10.100.40–41.0/24 | DPG-iSCSI-A/B | vmk3/4 | Storage |
| 100 | VM Production | 10.100.100.0/24 | DPG-Prod | — | VM Traffic |
| 200 | VM Development | 10.100.200.0/24 | DPG-Dev | — | VM Traffic |
| 300 | DMZ / Exposed | 10.100.150.0/24 | DPG-DMZ | — | DMZ |
4. NIOC — Network I/O Control Traffic Shaping Policy
NIOC đảm bảo bandwidth ưu tiên cho traffic quan trọng khi NIC bị overloaded — tránh vMotion bị chậm vì VM traffic.
| Traffic Type | Shares | Reservation | Limit | Lý do |
|---|---|---|---|---|
| vSAN | High (100) | 2 Gbps | — | vSAN rebuild cần bandwidth tối đa |
| vMotion | High (100) | 1 Gbps | — | vMotion nhanh → giảm stun time |
| Management | Normal (50) | 100 Mbps | — | Đảm bảo quản trị không bị block |
| VM Traffic | Normal (50) | — | — | Best effort, dùng phần còn lại |
| iSCSI/NFS | High (100) | 1 Gbps | — | Storage latency nhạy cảm với bandwidth |
### PowerCLI — Cấu hình NIOC Traffic Shaping trên vDS $vds = Get-VDSwitch "vDS-Infrastructure" # Bật NIOC $vds | Set-VDSwitch -Nioc $true # Set Shares cho vMotion traffic $vds | Get-VDTrafficShapingPolicy -Direction Egress Set-VDNetworkResourcePool -VDSwitch $vds -Key "vmotion" -NumSharesNormalMode 100 # Set Reservation cho vSAN (2 Gbps = 2000 Mbps) Set-VDNetworkResourcePool -VDSwitch $vds -Key "vsan" -Reservation 2000
5. NIC Teaming Policy — Active/Standby vs IP Hash
Chọn đúng teaming policy là quan trọng — sai policy gây mất kết nối hoặc không tận dụng được bandwidth.
| Policy | Dùng khi | Cần physical switch config? | Ưu điểm | Nhược điểm |
|---|---|---|---|---|
| Active/Standby | Management, vMotion | Không | Đơn giản, failover tốt | Không tận dụng bandwidth standby |
| Route by Port ID | VM Traffic (default) | Không | Load distribution tốt, failover nhanh | 1 VM chỉ dùng 1 NIC |
| IP Hash (LACP) | VM Traffic bandwidth cao | Có (Port Channel) | Aggregate bandwidth, 1 VM nhiều NIC | Phức tạp, cần switch config |
| Route by VLAN | Multi-VLAN workloads | Không | Phân tách VLAN trên NIC khác nhau | Ít linh hoạt |
6. Network Documentation Template
Tài liệu hóa thiết kế mạng vSphere — bắt buộc cho handover, audit và troubleshooting sau này.
### NETWORK DESIGN DOCUMENT — vSphere Infrastructure ### Version: 1.0 | Date: 2025-01 | Author: Network Team ## 1. PHYSICAL INFRASTRUCTURE Switch Model: Cisco Catalyst 9300 (2 units, stacked) Switch Firmware: 17.9.3 Port Config: Trunk, allowed VLANs 10,20,30,40,41,100,200,300,400 ## 2. vDS CONFIGURATION vDS Name: vDS-Infrastructure vDS Version: 8.0.0 MTU: 9000 (Jumbo Frames — enabled for vSAN/iSCSI) Uplinks: vmnic0 (Active), vmnic1 (Standby) NIOC: Enabled — v3 vDS Name: vDS-VM-Traffic vDS Version: 8.0.0 MTU: 1500 Uplinks: vmnic2+vmnic3 (LACP LAG, Active/Active) NIOC: Enabled ## 3. PORT GROUPS [vDS-Infrastructure] DPG-Management VLAN 10 vmk0 Mgmt+Provisioning enabled DPG-vMotion VLAN 20 vmk1 vMotion enabled DPG-vSAN VLAN 30 vmk2 vSAN enabled DPG-iSCSI-A VLAN 40 vmk3 Active: vmnic0 only (iSCSI best practice) DPG-iSCSI-B VLAN 41 vmk4 Active: vmnic1 only [vDS-VM-Traffic] DPG-VLAN100-Prod VLAN 100 Production VMs DPG-VLAN200-Dev VLAN 200 Development VMs DPG-VLAN300-DMZ VLAN 300 DMZ/Internet-facing VMs ## 4. SECURITY POLICY (applied to all port groups) Promiscuous Mode: Reject MAC Changes: Reject Forged Transmits: Reject NetFlow: Enabled → collector: 10.100.10.200:9995
Best Practice — vDS Security Hardening
- Reject Promiscuous Mode trên tất cả Port Groups — trừ security appliances (IDS/IPS)
- Reject MAC Changes và Forged Transmits — ngăn MAC spoofing
- Enable Private VLAN (PVLAN) cho tenant isolation trong môi trường multi-tenant
- Bật NetFlow trên vDS export sang SIEM để phân tích east-west traffic
- Dùng Distributed Port Group Profiles để enforce policy nhất quán