Click for a free read!

Proxmox VE 03 - 無線網卡設置

yfwang

6 min readJul 12, 2023

由於主機在房間,網路線無法拉進去,因此使用 AX210 無線網卡,但會出現 PVE 網段與路由器不同,且要將網路分給各 VM 這兩個障礙 ... 這篇是個人的解決方法與紀錄。

Outline

網路架構圖

由於 PVE 的 wifi 使用 NAT 而不能使用 bridge,因此需要透過軟路由開啟 DHCP 伺服器分配 IP,且網段與主路由器不同,建議還是以有線為最佳解,速度快又不用做設置。文件的設置參數建議參照以下網路架構圖:

安裝 wifi

開啟 PVE 節點的命令列,安裝 wifi 連線模組

apt install wpasupplicant

啟動網卡,並連接 wifi 獲取 psk 密鑰

ifup wlp2s0
wpa_passphrase "wifi name" "wifi pwd"

輸出 wifi 資訊,記住 psk 密鑰

network={
ssid="wifi name"
#psk="wifi pwd" //註解
psk=2c************************76 //psk
}

編輯 /etc/network/interfaces,修改以 wifi 設備 wlp2s0 為主,並穿至 vmbr0

auto lo
iface lo inet loopback
iface enp0s31f6 inet manual
auto wlp2s0
iface wlp2s0 inet static
address 192.168.50.165/24
gateway 192.168.50.1
wpa-ssid PinWifi
wpa-psk 2c************************76
up route add -net 0.0.0.0/0 gw 192.168.50.1 metric 0 wlp2s0
down route del -net 0.0.0.0/0 gw 192.168.50.1 metric 0 wlp2s0
auto vmbr0
iface vmbr0 inet static
address 10.10.10.1/24
bridge-ports none
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up bash /root/iptables.config.sh
post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o wlp2s0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o wlp2s0 -j MASQUERADE
#address 192.168.50.165/24
#gateway 192.168.50.1
#bridge-ports enp0s31f6

編輯 /root/iptables.config.sh,這是將 NAS 的 DSM 與 smb port 映射到 PVE 的 IP 上,因此輸入 192.168.50.165:5001 即可進入 NAS。(但我 smb 失敗… 還好有先裝 ZeroTier = =)

#!/usr/bin/env bash
iptables -t nat -A PREROUTING -i wlp2s0 -p tcp --dport 5000 -j DNAT --to-destination 10.10.10.102:5000
iptables -t nat -A PREROUTING -i wlp2s0 -p tcp --dport 5001 -j DNAT --to-destination 10.10.10.102:5001
iptables -t nat -A PREROUTING -i wlp2s0 -p tcp --dport 135 -j DNAT --to-destination 10.10.10.102:135
iptables -t nat -A PREROUTING -i wlp2s0 -p udp --dport 137 -j DNAT --to-destination 10.10.10.102:137
iptables -t nat -A PREROUTING -i wlp2s0 -p udp --dport 138 -j DNAT --to-destination 10.10.10.102:138
iptables -t nat -A PREROUTING -i wlp2s0 -p tdp --dport 139 -j DNAT --to-destination 10.10.10.102:139
iptables -t nat -A PREROUTING -i wlp2s0 -p tdp --dport 445 -j DNAT --to-destination 10.10.10.102:445

安裝 ikuai

軟路由我選用 ikuai,詳細安裝過程可參考 : https://www.10bests.com/install-ikuai-on-proxmox-ve/

另外開啟單臂路由,以下是我修改後結果

連線至 ikuai

開啟 PVE 底下的 windows 虛擬機手動更改網路 IPv4

輸入 ikuai 網址 10.10.10.99,預設帳號密碼皆為 admin

修改 DNS 設置,8.8.8.8 是 Google

啟動 DHCP,分配 IP 給各虛擬機,設定參照下圖

鎖定 NAS 的 IP (靜態分配),這樣才能做 IP 映射

最後將 windows 虛擬機網路改回自動 DHCP,IP 交由軟路由分配