差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

下次修改
前次修改
tech:debian_net_tips [2020/07/18 16:35] – 建立 jonathan_tsaitech:debian_net_tips [2022/01/23 21:38] (目前版本) jonathan
行 1: 行 1:
 +====== Debin Wi-Fi 網路介面設定 ======
 +因為設備有 wifi 網卡與 Ethernet 網卡, 安裝時只有自動抓到有線網卡, 現在想要啟動 wifi 網卡來使用
 +  * 設定環境 PVE 7.1 (debian_version : 11.2 Bullseye)
 +  * 預計連上 SSID : **ichiayi** WiFi AP
 +
 +===== 設定程序 =====
 +  - 安裝相關網路工具套件 <code sh>apt install iw wireless-tools wpasupplicant</code>
 +  - 確認 wifi 網卡名稱 <code sh>
 +ls -lt /sys/class/net/| grep -v virtual</code>結果類似以下<cli>
 +root@nuc:~# ls -lt /sys/class/net/| grep -v virtual
 +total 0
 +lrwxrwxrwx 1 root root    0 Jan 23 13:06 wlp0s20f3 -> ../../devices/pci0000:00/0000:00:14.3/net/wlp0s20f3
 +-rw-r--r-- 1 root root 4096 Jan 23 13:06 bonding_masters
 +lrwxrwxrwx 1 root root    0 Jan 23 13:06 eno1 -> ../../devices/pci0000:00/0000:00:1f.6/net/eno1
 +</cli>所以 wifi 網卡名稱就是 **wlp0s20f3**
 +  - 用 WiFi AP 的 SSID/密碼 產生連上 psk<cli>
 +root@nuc:~# wpa_passphrase ichiayi **ichiayi_password**
 +network={
 +        ssid="ichiayi"
 +        #psk="**ichiayi_password**"
 +        psk=1dfdf**************************************************1087dcd52
 +}
 +</cli>
 +  - 建立 WPA 認證相關設定檔案<code sh>
 +mkdir -p /etc/wpa_supplicant
 +vi /etc/wpa_supplicant/wpa_supplicant.conf 
 +</code>內容類似如下:<file>
 +#
 +# File: wpa_supplicant.conf
 +#
 +ctrl_interface=/var/run/wpa_supplicant
 +ctrl_interface_group=root
 +network={
 +        ssid="ichiayi"
 +        proto=WPA2
 +        key_mgmt=WPA-PSK
 +        psk=1dfdf**************************************************1087dcd52
 +}
 +</file>
 +  - 編輯 interfaces 網路介面設定<code sh>vi /etc/network/interfaces</code>內容類似以下<file>
 +:
 +auto wlp0s20f3
 +iface wlp0s20f3 inet dhcp
 +        pre-up wpa_supplicant -B -Dwext -iwlp0s20f3 -c/etc/wpa_supplicant/wpa_supplicant.conf
 +        post-down killall -q wpa_supplicant
 +:
 +</file>
 +  - 啟動 wpa_supplicant 服務<cli>
 +systemctl restart wpa_supplicant
 +</cli>
 +  - 重啟網路服務<cli>
 +systemctl restart networking.service
 +</cli>
 +  - 驗證是否正常連上 WiFi AP<cli>
 +wpa_cli -i wlp0s20f3 status
 +</cli>如果正確連上應該類似以下的訊息<cli>
 +root@nuc:~# wpa_cli -i wlp0s20f3 status
 +bssid=28:6c:07:68:fe:89
 +freq=0
 +ssid=ichiayi
 +id=0
 +mode=station
 +wifi_generation=5
 +pairwise_cipher=CCMP
 +group_cipher=TKIP
 +key_mgmt=WPA2-PSK
 +wpa_state=COMPLETED
 +ip_address=192.168.31.251
 +address=04:ea:56:87:58:34
 +uuid=14ea0bcc-c7f5-592c-ba49-159bbe31e49d
 +</cli>
 +  - 使用 ip addr show wlp0s20f3 就可看到目前的設定<cli>
 +root@nuc:~# ip addr show wlp0s20f3
 +3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
 +    link/ether 04:ea:56:87:58:34 brd ff:ff:ff:ff:ff:ff
 +    inet 192.168.31.251/24 brd 192.168.31.255 scope global dynamic wlp0s20f3
 +       valid_lft 39290sec preferred_lft 39290sec
 +    inet6 fe80::6ea:56ff:fe87:5834/64 scope link 
 +       valid_lft forever preferred_lft forever
 +</cli>
 +
 +<note>
 +  * 如果有修改 /etc/wpa_supplicant/wpa_supplicant.conf 需要執行 reconfig 來生效<cli>
 +root@nuc:~# wpa_cli -i wlp0s20f3 reconfig
 +OK
 +root@nuc:~# wpa_cli -i wlp0s20f3 status
 +bssid=62:a4:4c:67:26:74
 +freq=0
 +ssid=ichiayi_n56u_5G
 +id=0
 +:
 +</cli>
 +</note>
 +
 +<WRAP center round alert 60%>
 +**針對在 PVE 環境將 WiFi 網卡加入 Bridge 並沒有設定成功**
 +  * 目前似乎是 **bridging does not work with WiFi** (主要是 VM 要使用 WiFi Bridge 的問題)
 +  * 找尋的相關資料如下: 
 +    * https://unix.stackexchange.com/questions/363332/how-do-i-configure-a-network-interface-bridge-from-wifi-to-ethernet-with-debian
 +    * https://pve.proxmox.com/wiki/WLAN
 +    * https://forum.proxmox.com/threads/wlan-doesnt-stay-in-bridge.49978/
 +    * https://blog.csdn.net/qq_19905867/article/details/114118476
 +    * https://www.reddit.com/r/Proxmox/comments/pttmr2/can_i_use_proxmox_with_only_wifi_broken_ethernet/
 +</WRAP>
 +
 +===== 參考網址 =====
 +  * https://wiki.debian.org/NetworkConfiguration#Setting_up_an_Ethernet_Interface
 +  * https://wiki.debian.org/WiFi
 +  * http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch13_:_Linux_Wireless_Networking#.XxKqtygzZPY
 +  * https://codeleading.com/article/88945302379/
 +
 +{{tag>pve network}}