主要参考两篇文章:
https://blog.csdn.net/afeiqiang/article/details/106962505
https://blog.csdn.net/qq825255961/article/details/106042876
第一步:sudo vi etc/netplan/50-cloud-init.yaml
在文件中添加wifi网络的信息
-
network: ethernets: eth0: dhcp4: true optional: true wifis: wlan0: dhcp4: true optional: true access-points: "无线网络的名称": password: "密码"
第二步:应用配置
sudo netplan generate
sudo netplan apply
如果报错提示netplan-wpa-wlan0.service服务未找到,重启一下树莓派就可以联网了。
:unit netplan-wpa-wlan0.service not found