树莓派 ubuntu 命令行配置wlan wifi 亲测有效(转自:How to set up WIFI on Ubuntu running on the Raspberry Pi 4)
转自:https://oastic.com/posts/how-to-set-up-wifi-on-ubuntu-running-on-the-raspberry-pi-4/
test @
pi 400
ubuntu-18.04.5-preinstalled-server-arm64+raspi4.img.xz
(不要勾选skip first-run wizard,否则装os不成功)
正文:
不用装net-tools
注意
network:
version: 2
renderer: networkd
wifis:
wlan0:
dhcp4: yes
dhcp6: no
access-points:
"<your network ESSID>":
password: "<your WIFI Password>"
注意:可能忘记 wifis:下面写wlan0
How to set up WIFI on Ubuntu running on the Raspberry Pi 4
First step is to check the status of the interfaces. For this, we will use the net-tools package.
sudo apt install net-tools
Then, we can see the interfaces status
ifconfig -a
In my case, I have this status of my interface wlan0:
ubuntu@ubuntu:~$ ifconfig -a wlan0
wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether dc:a6:32:6c:xx:xx txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
In the flags only there are 2 (BROADCAST,MULTICAST), but there is no “UP” flag.
In order to configure the WIFI network, I recommend to use the program netplan, available from Ubuntu 18.04. It doesn’t require any additional installation, it comes with the base system.
For the wireless configuration, you may follow the example:
/usr/share/doc/netplan/examples/wireless.yaml
so next step is to copy the file in the directory /etc/netplan/
sudo cp /usr/share/doc/netplan/examples/wireless.yaml /etc/netplan/
Then, edit the new file created and change the values. Probably you want to enable dhcp configuration and remove static parts. In my case, the file looks like this:
network:
version: 2
renderer: networkd
wifis:
wlan0:
dhcp4: yes
dhcp6: no
access-points:
"<your network ESSID>":
password: "<your WIFI Password>"
Last step is to execute the netplan
sudo netplan try
As an alternative, you could modify the existing file /etc/netplan/50-cloud-init.yaml
which is created by default. In this file you could add the WIFI configuration.
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
dhcp6: false
access-points:
"<your network ESSID>":
password: "<your WIFI Password>"
Last step is to execute the netplan
sudo netplan try
After this, your WIFI should be established. You could check it with ifconfig tool:
ubuntu@ubuntu:~$ ifconfig -a wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.220 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::dea6:32ff:fe6c:xxxx prefixlen 64 scopeid 0x20
ether dc:a6:32:6c:xx:xx txqueuelen 1000 (Ethernet)
RX packets 5047 bytes 936652 (936.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 78 bytes 9491 (9.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
And now the flags UP and RUNNING are set.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?