树莓派鼓捣记 - 设置 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

相关文章
相关标签/搜索