🏠hoatranlab.io.vn 💬Zalo: 0917516878 📞0917516878 ✉️[email protected]

Phase 4: Networking & SDN Fabric

Bài 4.1: Bridge + VLAN trunking cho VM

Lý thuyết cốt lõi

Linux Bridge trong Proxmox giống vSwitch:

  • Access mode: VM gán tag VLAN X → chỉ thấy traffic tag X
  • Trunk mode: VM nhận tất cả VLAN (dùng cho firewall VM/router VM)

Config VM VLAN:

# VM ID 100 gán vào vmbr1, VLAN tag 10
qm set 100 --net0 virtio,bridge=vmbr1,tag=10

# VM ID 101 là trunk (không tag, nhận all VLAN)
qm set 101 --net0 virtio,bridge=vmbr1,trunks=10;20;30

Bài tập thực hành

Scenario: 3 VLAN — 10 (prod), 20 (dev), 30 (mgmt). Tạo 3 VM ở 3 VLAN khác nhau, ping qua firewall VM trunk.

# VM 100: prod (VLAN 10)
qm set 100 --net0 virtio,bridge=vmbr1,tag=10

# VM 200: dev (VLAN 20)
qm set 200 --net0 virtio,bridge=vmbr1,tag=20

# VM 300: firewall/router trunk
qm set 300 --net0 virtio,bridge=vmbr1,trunks=10;20;30

Kết quả đầu ra

Từ VM 100, ping VM 200 qua firewall VM 300:

$ ping -c 3 192.168.20.50
PING 192.168.20.50 (192.168.20.50) 56(84) bytes of data.
64 bytes from 192.168.20.50: icmp_seq=1 ttl=63 time=0.5 ms

Bài 4.2: SDN Fabric với OpenFabric (VE 9 mới)

Lý thuyết cốt lõi

SDN (Software-Defined Networking) trong VE 9 cho phép:

  • Zone (VXLAN/VLAN/QinQ) → VNet → Subnet
  • Fabric mới VE 9: underlay routing dùng OpenFabric hoặc OSPF (FRR backend)
  • Tự động setup Ceph network full-mesh không cần L2 switch

Use case Fabric:

  • Ceph cluster network 3-node full-mesh (mỗi node nối trực tiếp 2 node còn lại)
  • Không cần switch riêng cho Ceph → tiết kiệm port 25 GbE

Topology full-mesh 3-node:

pve01 ──25G── pve02
  │             │
  25G           25G
  │             │
  pve03 ────────┘

Bài tập thực hành

Tạo Fabric qua Web GUI: Datacenter → SDN → Fabrics → Add OpenFabric.

Hoặc CLI:

# Config FRR + frr-pythontools (đã cài sẵn VE 9)
apt install frr-pythontools

# Đi vào /etc/pve/sdn/fabrics.cfg (tự sync giữa node)
cat > /etc/pve/sdn/fabrics.cfg <<'EOF'
openfabric: ceph-fabric
    area 0.0.0.0
    hello-interval 3
EOF

# Apply
pvesh set /cluster/sdn
systemctl restart frr

Kết quả đầu ra

$ vtysh -c 'show openfabric neighbor'
Area ceph-fabric:
  L2 Adjacencies:
  System Id           Interface   State        Hold   SNPA
  pve02.10203040      eno4        Up           28     XXXX.XXXX.XXXX
  pve03.10203040      eno5        Up           27     XXXX.XXXX.XXXX

Troubleshooting

  • Neighbor không up: check interface ip link, MTU cả 2 phía phải match (thường 9000)
  • Loop routing: kiểm tra area ID giống nhau giữa các node
  • FRR crash: journalctl -u frr -n 50

Ứng dụng thực tế

Tình huống: Khách hàng muốn HCI 3-node nhưng ngân sách không có switch 25 GbE.

Giải pháp: Mỗi node cắm 2 NIC 25G direct tới 2 node còn lại, dùng OpenFabric → tự routing. Tiết kiệm ~5000 USD switch.


Bài 4.3: Firewall nftables (VE 9 default)

Lý thuyết cốt lõi

VE 9 migrate từ iptables → nftables. Tất cả rule viết trên Web GUI được dịch ra nftables.

3 level firewall:

  1. Datacenter: áp cho toàn cluster
  2. Node: áp cho host Proxmox
  3. VM/CT: áp cho từng guest

Enable firewall:

# Per VM
qm set 100 --net0 virtio,bridge=vmbr1,firewall=1

# Datacenter
pvesh set /cluster/firewall/options --enable 1

Config file: /etc/pve/firewall/cluster.fw, /etc/pve/nodes/<node>/host.fw, /etc/pve/firewall/<vmid>.fw

Bài tập thực hành

Tạo rule chặn SSH từ Internet, chỉ cho phép từ VLAN mgmt:

# /etc/pve/firewall/cluster.fw
[OPTIONS]
enable: 1
policy_in: DROP
policy_out: ACCEPT

[RULES]
IN SSH(ACCEPT) -source 10.0.30.0/24 -log nolog
IN HTTPS(ACCEPT) -dest 10.0.0.0/24 -log nolog
IN ICMP(ACCEPT) -log nolog

Reload:

pve-firewall reload
pve-firewall status
nft list ruleset | head -40

Kết quả đầu ra

$ pve-firewall status
Status: enabled/running
Inbound default: DROP
Outbound default: ACCEPT

Troubleshooting

  • Rule không có hiệu lực: check enable: 1 trong section [OPTIONS]
  • Lock mình khỏi Web GUI: khẩn cấp → SSH vào node, pve-firewall stop hoặc chỉnh file /etc/pve/firewall/cluster.fw rồi pve-firewall reload
  • VM không ra Internet: thêm rule OUT ACCEPT ở VM firewall hoặc tắt VM firewall

Ứng dụng thực tế

Khách hàng compliance PCI-DSS yêu cầu log tất cả connection tới VM database:

[RULES]
IN ACCEPT -p tcp -dport 3306 -source 10.0.20.0/24 -log info
IN DROP -p tcp -dport 3306 -log warning

Log lưu /var/log/syslog → ship qua SIEM (Splunk/Graylog).