Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

ubuntu20 server启用WiFi[0]

Posted on 2023年11月14日 by

新入手了树莓派4B的 2G 版本,打算用来做服务器用所以安装了 Ubuntu Server 18.04 系统,因为家里小米路由器只有 2 个 LAN 口,一个给台式一个给另一个路由器做中继,所以打算用 5G WIFI 连接网络。

ubuntu在 18.04 之后 更换了网络管理工具,以前的 ifconfig 没了,取而代之的是 ip 命令,而配置 wifi,需要使用 netplan 命令

安装无线工具

apt-get install wireless-tools

确认自己的无线网卡叫什么:

ip a

使用 ip a 命令可以看到,eht0 是有线网卡,wlan0 是无线网卡。

启用无线网卡

ifconfig wlan0 up

扫描可用的无线信号

iwlist wlan0 scan

若找不到 5G 频道,则运行下面的命令查看支持的频道,再看路由器设置的5G是哪个频道。
可修改无线路由器的信道,选择一个树莓派系统中支持的信道。

iwlist channel

微酷这里将小米路由器 5G 频道改成了 56,如下图

配置网络

接下来编辑 vim /etc/netplan/xxx.yaml 下的 YAML 配置文件,不同的机器文件名不一样。

注意:这是 python 语法,对空格和缩进要求很严格,一开始总是设置不对,最后用 PyCharm 编辑后搞定。

# 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
    wifis:
        wlan0:
            dhcp4: true
            access-points:
                "XINGGANG_5G":
                    password: "123456"

使用 :x 保存文件后再扫描下面这个命令,查看配置是否有错,如果有错它会自动回滚上次正确配置。

sudo netplan try

如果没错会让你按 enter 确认使用这些配置,然后再执行下面的命令来使配置生效

sudo netplan apply

查看连接信息

执行 ip a 如果顺利的话可以看到已经分配到 ip 地址了。
参考资料:

  1. https://weiku.co/article/527/

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT