Debin Wi-Fi 網路介面設定

因為設備有 wifi 網卡與 Ethernet 網卡, 安裝時只有自動抓到有線網卡, 現在想要啟動 wifi 網卡來使用

  • 設定環境 PVE 7.1 (debian_version : 11.2 Bullseye)
  • 預計連上 SSID : ichiayi WiFi AP
  1. 安裝相關網路工具套件
    apt install iw wireless-tools wpasupplicant
  2. 確認 wifi 網卡名稱
    ls -lt /sys/class/net/| grep -v virtual

    結果類似以下

    [email protected]:~# 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

    所以 wifi 網卡名稱就是 wlp0s20f3

  3. 用 WiFi AP 的 SSID/密碼 產生連上 psk

    [email protected]:~# wpa_passphrase ichiayi **ichiayi_password**
    network={
            ssid="ichiayi"
            #psk="**ichiayi_password**"
            psk=1dfdf**************************************************1087dcd52
    }

  4. 建立 WPA 認證相關設定檔案
    mkdir -p /etc/wpa_supplicant
    vi /etc/wpa_supplicant/wpa_supplicant.conf 

    內容類似如下:

    #
    # 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
    }
  5. 編輯 interfaces 網路介面設定
    vi /etc/network/interfaces

    內容類似以下

    :
    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
    :
  6. 啟動 wpa_supplicant 服務

    systemctl restart wpa_supplicant

  7. 重啟網路服務

    systemctl restart networking.service

  8. 驗證是否正常連上 WiFi AP

    wpa_cli -i wlp0s20f3 status

    如果正確連上應該類似以下的訊息

    [email protected]:~# 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

  9. 使用 ip addr show wlp0s20f3 就可看到目前的設定

    [email protected]:~# 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

  • 如果有修改 /etc/wpa_supplicant/wpa_supplicant.conf 需要執行 reconfig 來生效

    [email protected]:~# wpa_cli -i wlp0s20f3 reconfig
    OK
    [email protected]:~# wpa_cli -i wlp0s20f3 status
    bssid=62:a4:4c:67:26:74
    freq=0
    ssid=ichiayi_n56u_5G
    id=0
    :

  • tech/debian_net_tips.txt
  • 上一次變更: 2022/01/23 21:38
  • jonathan