日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

树莓派3B+ubunt server配置WiFi

發布時間:2024/3/24 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 树莓派3B+ubunt server配置WiFi 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

基于樹莓派的ubuntu server系統默認是沒有開啟WiFi的,如果想要在ubuntu下使用樹莓派的WiFi功能就必須要手動配置。

  • 安裝iwconfig工具和net-tools
  • sudo apt install wireless-tools sudo apt-get install net-tools
  • 啟動樹莓派的無線網卡,網卡名稱默認為wlan0
  • sudo iwconfig wlan0 power on sudo ifconfig wlan0 up
  • 配置樹莓派需要連接的路由器名稱和密碼
  • sudo iwconfig wlan0 essid "無線名稱" sudo su wpa_passphrase 無線名稱 密碼 > /etc/wpa_supplicant/wpa_supplicant.conf
  • 以上步驟操作完成后,/etc/wpa_supplicant/wpa_supplicant.conf的內容如下
  • sudo vi /etc/wpa_supplicant/wpa_supplicant.conf network={ssid="ap"#psk="12345678"psk=37f0aab65e8664c4524c3966ae54ca1ecf2266682db8753714d6d03040e1a267 } ~

    ssid表示無線的名稱,psk表示無線的密碼,無線密碼有兩種表示方式,一種是明文的密碼,一種是加密后的十六進制數據,兩種表示方式均可
    5. 手動配置使配置生效

    sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf sudo dhclient wlan0
  • 使用ifconfig命令查看wlan0是否獲取到ip地址
  • wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.1.150 netmask 255.255.255.0 broadcast 192.168.1.255inet6 fe80::ba27:ebff:feb0:2c69 prefixlen 64 scopeid 0x20<link>ether b8:27:eb:b0:2c:69 txqueuelen 1000 (Ethernet)RX packets 3 bytes 1180 (1.1 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 10 bytes 1580 (1.5 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  • 接下來需要將上面的配置設置為開機啟動,ubuntu在/etc目錄下是沒有rc.local文件的,我們需要創建它并寫入如下內容:
  • #!/bin/bash ip link set wlan0 up && wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf && dhclient wlan0 exit 0
  • 修改rc.local為可執行:
  • chmod a+x /etc/rc.local

    此時如果我們執行systemctl enable rc-local.service命令會報如下錯誤:

    The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl.Possible reasons for having this kind of units are: ? A unit may be statically enabled by being symlinked from another unit's.wants/ or .requires/ directory. ? A unit's purpose may be to act as a helper for some other unit which hasa requirement dependency on it. ? A unit may be started when needed via activation (socket, path, timer,D-Bus, udev, scripted systemctl call, ...). ? In case of template units, the unit is meant to be enabled with someinstance name specified.
  • 我們需要修改etc/systemd/system目錄下的rc-local.service文件,添加最后面兩行:
  • # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version.# This unit gets pulled automatically into multi-user.target by # systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target[Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no[Install] WantedBy=multi-user.target
  • 使能rc-local服務
  • sudo systemctl enable rc-local.service

    執行成功后會有提示:

    Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /lib/systemd/system/rc-local.service.

    如果沒有提示說明之前已經啟動過該服務。
    11. 設置開機啟動

    sudo systemctl daemon-reload sudo systemctl start rc-local.service

    第一條命令如果不執行可能出現如下錯誤:

    Warning: The unit file, source configuration file or drop-ins of rc-local.service changed on disk. Run 'sys> ● rc-local.service - /etc/rc.local CompatibilityLoaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled)Drop-In: /usr/lib/systemd/system/rc-local.service.d└─debian.confActive: failed (Result: exit-code) since Wed 2021-05-26 11:45:53 UTC; 5min agoDocs: man:systemd-rc-local-generator(8)Process: 2241 ExecStart=/etc/rc.local start (code=exited, status=203/EXEC)May 26 11:45:53 ubuntu systemd[1]: Starting /etc/rc.local Compatibility... May 26 11:45:53 ubuntu systemd[2241]: rc-local.service: Failed to execute command: Exec format error May 26 11:45:53 ubuntu systemd[2241]: rc-local.service: Failed at step EXEC spawning /etc/rc.local: Exec fo> May 26 11:45:53 ubuntu systemd[1]: rc-local.service: Control process exited, code=exited, status=203/EXEC May 26 11:45:53 ubuntu systemd[1]: rc-local.service: Failed with result 'exit-code'. May 26 11:45:53 ubuntu systemd[1]: Failed to start /etc/rc.local Compatibility.
  • 查看自啟動設置是否成功
  • sudo systemctl status rc-local.service

    成功后會出現如下內容:

    ● rc-local.service - /etc/rc.local CompatibilityLoaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled)Drop-In: /usr/lib/systemd/system/rc-local.service.d└─debian.confActive: active (exited) since Wed 2021-05-26 12:05:56 UTC; 2min 8s agoDocs: man:systemd-rc-local-generator(8)Tasks: 0 (limit: 973)CGroup: /system.slice/rc-local.serviceMay 26 12:05:56 ubuntu systemd[1]: Starting /etc/rc.local Compatibility... May 26 12:05:56 ubuntu rc.local[1694]: Successfully initialized wpa_supplicant May 26 12:05:56 ubuntu rc.local[1694]: Failed to open config file '/etc/wpa_supplicant.conf', error: No suc> May 26 12:05:56 ubuntu rc.local[1694]: Failed to read or parse configuration '/etc/wpa_supplicant.conf'. May 26 12:05:56 ubuntu systemd[1]: Started /etc/rc.local Compatibility.

    總結

    以上是生活随笔為你收集整理的树莓派3B+ubunt server配置WiFi的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。