美文网首页
树莓派配置wifi的几种方法.md

树莓派配置wifi的几种方法.md

作者: zhf_sy | 来源:发表于2020-09-13 16:31 被阅读0次

    [TOC]

    参考:
    https://jingyan.baidu.com/article/91f5db1b9daa3e5c7f05e3e8.html
    _

    配置

    A、桌面界面配置

    B、字符图形界面配置

    shell中运行 raspi-config,选择network options,选择Wi-Fi,然后输入SSID和密码,重启系统后即可。

    C、shell界面配置

    打开/etc/wpa_supplicant/wpa_supplicant.conf增加如下内容

    network={
            ssid="[你的网络名称]"
            psk="[你的网络密码]"}
    

    psk还可以是32字节的预加密16进制数。该参数可以用wpa_passphrase生成:

    # wpa_passphrase my_ssid
     reading passphrase from stdin
    此处输入ssid的密码
    network={
            ssid="my_ssid"
            #psk="1234567890"
            psk=7c225accef682c20977c929d94e9ac56191c0a50d55c35a16cd92fcf074ecc45
    }
    

    将以上内容追加到配置文件中(/etc/wpa_supplicant/wpa_supplicant.conf)
    或者直接这样:wpa_passphrase "my_ssid" >> /etc/wpa_supplicant/wpa_supplicant.conf

    运行命令,使配置生效:wpa_cli -i wlan0 reconfigure

    # wpa_cli -i wlan0  reconfigure
    OK
    

    a、如果网络没有密码,则设置 key_mgmt=NONE

    network={
            ssid="my_ssid"
            key_mgmt=NONE
    }
    

    b、如果网络是隐藏的,需要加一个scan_ssid配置;

    network={
            ssid="my_ssid"
            psk="1234567890"
            scan_ssid=1
    }
    

    c、此外可以设置多个网络,并设置不同的优先级参数priority

    network={
            ssid="my_ssid1"
            psk="1234567890"
            priority=1
    }
    #
    network={
            ssid="my_ssid2"
            psk="1234567890"
            priority=2
    }
    

    另:

    列出可用网络

    列出所有的可用wifi网络:iwlist wlan0 scan,SSID有时候很复杂,输入不方便时很有用

    ESSID就是wifi的网络名称
    IE: IEEE 802.11i/WPA2 Version 1表示需要认证登录,使用WPA2加密

    # iwlist wlan0 scan
    wlan0  Scan completed :
              Cell 01 - Address: 70:85:40:58:4B:54
                        Channel:1
                        Frequency:2.412 GHz (Channel 1)
                        Quality=50/70  Signal level=-60 dBm  
                        Encryption key:on
                        ESSID:"CandyTime_57AD84"
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                                  24 Mb/s; 36 Mb/s; 54 Mb/s
                        Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
                        Mode:Master
                        Extra:tsf=000000006e7d2815
                        Extra: Last beacon: 30ms ago
                        IE: Unknown: 001043616E647954696D655F353741443834
                        IE: Unknown: 010882848B962430486C
                        IE: Unknown: 030101
                        IE: Unknown: 2A0100
                        IE: Unknown: 32040C121860
                        IE: IEEE 802.11i/WPA2 Version 1
                            Group Cipher : CCMP
                            Pairwise Ciphers (1) : CCMP
                            Authentication Suites (1) : PSK
                        IE: Unknown: 0B050100130000
                        IE: Unknown: 46057208010000
                        IE: Unknown: 2D1ABC091BFFFF000000000000000000000000000000000000000000
                        IE: Unknown: 3D1601080000000000000000000000000000000000000000
                        IE: Unknown: 7F080400080000000040
                        IE: Unknown: DD090010180201000C0000
                        IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
    

    查看wifi连接状态速度等

    iwconfig
    iwconfig 网卡名
    cat /proc/net/wireless

    iwconfig

    $ iwconfig
    enxb827eb5d7a4e  no wireless extensions.
    
    lo        no wireless extensions.
    
    wlan0  IEEE 802.11  ESSID:"mik"  
              Mode:Managed  Frequency:2.457 GHz  Access Point: F0:B4:29:86:4E:6D   
              Bit Rate=1 Mb/s   Tx-Power=20 dBm   
              Retry short limit:7   RTS thr=2347 B   Fragment thr:off
              Power Management:off
              Link Quality=70/70  Signal level=-24 dBm  
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:2   Missed beacon:0
    

    proc

    $ cat /proc/net/wireless
    Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE
     face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 22
    wlan0: 0000   70.  -16.  -256        0      0      0      0      2        0
    

    相关文章

      网友评论

          本文标题:树莓派配置wifi的几种方法.md

          本文链接:https://www.haomeiwen.com/subject/nuznektx.html