Ubuntu22.04 服务器版连接WiFi

Ubuntu22.04使用Netplan来管理网络

首先通过ip a查看无线网卡的名字,我的是wlp3s0

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:e0:4c:04:b8:3b brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 24:18:c6:37:4d:79 brd ff:ff:ff:ff:ff:ff

编辑配置文件/etc/netplan/00-installer-config-wifi.yaml注意文件名可能不一样,请根据实际情况选择,如果你不是root,那么需要sudo,文件内容为:

wlp3s0为网卡名字,根据实际情况修改,yaml文件通过2个空格确定上下级关系,需要严格遵守.

# This is the network config written by 'subiquity'
network:
  version: 2
  wifis:
    wlp3s0:
      dhcp4: true
      access-points:
        "WiFi名字,根据实际情况修改":
          password: "WiFi密码,根据实际情况修改"

重启网络

sudo netplan generate
sudo netplan apply
欢迎转载,转载请注明出处。

发表评论

您的电子邮箱地址不会被公开。