zoukankan      html  css  js  c++  java
  • 树莓派配置 USB 无线网卡

    树莓派配置 USB 无线网卡来上网的过程。

    本人使用的USB无线网卡型号:EP-N8508GS(树莓派专用型号)

    一、检查 USB 无线网卡是否已经正确识别

    将无线 USB 网卡插入树莓派后启动树莓派,比较不建议热插拔,因为插入的一瞬间会有比较高的电流,如果电源输出不够可能导致树莓派重启。
    进入 shell 界面后输入命令 lsusb
    如果树莓派已经正常识别,在显示类似于如下的信息中可以看到你的USB无线网卡设备 ID 和芯片型号:

    Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
    Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    

    如上,我的 pi 已经识别 RTL8188CUS 802.11n WLAN Adapter
    再使用 iwconfig 命令确认一下:

    wlan0     unassociated  Nickname:"<WIFI@REALTEK>"
              Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
              Sensitivity:0/0  
              Retry:off   RTS thr:off   Fragment thr:off
              Power Management:off
              Link Quality:0  Signal level:0  Noise level:0
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:0   Missed beacon:0
    lo        no wireless extensions.
    eth0      no wireless extensions.
    

    如果出现了 wlan0,那说明网卡已经正常工作了,如果这里的显示不正常,请安装连接 wifi 必要的包。

    sudo apt-get install wireless-tools wpasupplicant firmware-realtek
    
    

    二、设置 WIFI

    输入如下命令可以搜索附近所有可连接的 WIFI AP:

    sudo iwlist wlan0 scan
    

    这边搜到了十几个 wifi 热点,下图是我自己家的:

    Cell 09 - Address: 10:0D:7F:45:9E:D9
              ESSID:"OpenWrt_2.4G"
              Protocol:IEEE 802.11bgn
              Mode:Master
              Frequency:2.462 GHz (Channel 11)
              Encryption key:on
              Bit Rates:144 Mb/s
              Extra:wpa_ie=dd1a0050f20101000050f20202000050f2040050f20201000050f202
              IE: WPA Version 1
                  Group Cipher : TKIP
                  Pairwise Ciphers (2) : CCMP TKIP
                  Authentication Suites (1) : PSK
              Extra:rsn_ie=30180100000fac020200000fac04000fac020100000fac020c00
              IE: IEEE 802.11i/WPA2 Version 1
                  Group Cipher : TKIP
                  Pairwise Ciphers (2) : CCMP TKIP
                  Authentication Suites (1) : PSK
              Quality=36/100  Signal level=66/100 
    

    使用如下命令获得 wifi 设置:

    wpa_passphrase SSID 名称 密码
    

    回显如下:

    network={
            ssid="OpenWrt_2.4G"
            #psk=" 密码 "
            psk=ff5e84f34e6f496acff05d1a97271508bb4405d5d07864c2dc321941e427f778
    }
    

    复制这段回显并保存到自己的配置文件中:

    sudo nano /etc/wpa_supplicant/wpa_supplicant . conf
    

    然后配置/etc/network/interfaces

    sudo nano /etc/network/interfaces
    

    配置 自动获得 IP 地址,配置内容如下:

    allow-hotplug wlan0
    auto wlan0
    iface wlan0 inet dhcp  
    pre-up wpa_supplicant -B w -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf 
    post-down killall -q wpa_supplicant
    

    连接网络:

    sudo /etc/init.d/networking restart
    sudo ifup wlan0
    

    关闭网络:

    sudo ifdown wlan0
    

    三、最后使用命令 iwconfigifconfig 验证查看连接速度

    iwconfig信息:

    wlan0     IEEE 802.11bgn  ESSID:"OpenWrt_2.4G"  Nickname:"<WIFI@REALTEK>"
              Mode:Managed  Frequency:2.462 GHz  Access Point: 10:0D:7F:45:9E:D9   
              Bit Rate:65 Mb/s   Sensitivity:0/0  
              Retry:off   RTS thr:off   Fragment thr:off
              Power Management:off
              Link Quality=100/100  Signal level=71/100  Noise level=0/100
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:0   Missed beacon:0
    lo        no wireless extensions.
    eth0      no wireless extensions.
    

    查看 ifconfig 信息:

    wlan0     Link encap:Ethernet  HWaddr e8:4e:06:20:03:7c  
              inet addr:192.168.0.206  Bcast:192.168.0.255  Mask:255.255.255.0
              inet6 addr: fd1a:b6c5:65ca:0:d10a:30ca:da70:e8c7/64 Scope:Global
              inet6 addr: fd1a:b6c5:65ca::c3b/128 Scope:Global
              inet6 addr: fe80::733a:6f84:a823:d26a/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:440 errors:0 dropped:27 overruns:0 frame:0
              TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:81492 (79.5 KiB)  TX bytes:17685 (17.2 KiB)
    
  • 相关阅读:
    观光公交
    luogu 4779 【模板】
    最小生成树(luogu 3366)
    计算系数
    更新区间,求单点—— luogu 3368
    HDU
    HDU
    HDU
    HDU
    BFS
  • 原文地址:https://www.cnblogs.com/imapla/p/5532993.html
Copyright © 2011-2022 走看看