樹莓派鼓搗記 - 設置 wifi

樹莓派是自帶有無線網卡的,因此能夠鏈接 wifi。shell

本文的樹莓派系統環境是 Ubuntu Server 20.04,其餘 Linux 系統都大同小異。vim

ssh 進入樹莓派。app

1.第一步設置時區

sudo tzselect

# 選擇4 Aisa

# 而後選擇9 China

# 接着選擇1 Beijing Time

# 最後選擇1 確認

sudo cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

設置完成後執行 date -R 看時間是否準確。ssh

2.設置 wifi

cd /etc/netplan/
sudo vim 50-cloud-init.yaml

打開後應該會有如下內容:ide

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2

如今須要加一個wifi的配置,示例以下:debug

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    wifis:
        wlan0:
            dhcp4: true
            access-points:
                <wifi名字>:
                    password: "<wifi密碼>"
    version: 2

編輯完成後保存,而後執行命令3d

sudo netplan --debug apply

3.檢查設置code

執行命令 ifconfig 檢查是否有網卡 wlan0 的信息,而且獲取到了ip,最後經過這個ip進行 ssh 鏈接,若是鏈接成功,那就沒有問題了。orm

相關文章
相關標籤/搜索