Ubuntu 服务器 20.04 无线网络连接

Ubuntu 服务器 20.04 无线网络连接

我在一台 Compaq 笔记本电脑上安装了 ubuntu server 20.04。有线连接时,它可以连接到互联网。我一直尝试通过无线方式连接,但没有成功。我在网上阅读了许多关于使用 netplan 的文章,并尝试了他们的说明,但没有成功。命令:“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: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:1f:16:d1:af:b7 brd ff:ff:ff:ff:ff:ff
3: wls1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:24:2c:63:3f:09 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:e3:f9:bf:ef brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

有人能帮我调出“wls1”界面吗?或者这里还有其他问题?

谢谢。eoo。

命令“iwconfig wls1”产生的结果如下:

wls1      IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

cat /etc/netplan/*.yaml 的结果:

scr# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
        enp1s0:
            dhcp4: true
    version: 2
    wifis:
            wls1:
                    dhcp4: true
                    optional: true
                    access-points:
                            "A-----66a":
                                    password: "7m-----k8y"

@Heynnema 请根据您的建议在下面找到我当前编辑的 *yaml 文件:

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
  version: 2
  renderer: networkd 
  ethernets:
    enp1s0:
      dhcp4: true
      optional: true
  wifis:
    wls1:
      dhcp4: true
      access-points:
        "AT-----66a":
           password: "7m------rk8y"

应用并重新启动后,问题仍然存在。以下是命令“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: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:1f:16:d1:af:b7 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21f:16ff:fed1:afb7/64 scope link 
       valid_lft forever preferred_lft forever
3: wls1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:24:2c:63:3f:09 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:47:8f:bc:4d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
5: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default 
    link/ether 32:06:6d:56:99:34 brd ff:ff:ff:ff:ff:ff
    inet 10.1.11.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
    inet6 fe80::3006:6dff:fe56:9934/64 scope link 
       valid_lft forever preferred_lft forever

@heynnema 请参阅下面给出的命令的输出:

对于'sudo netplan --debug generate',我有:

** (generate:1099813): DEBUG: 03:18:36.906: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:1099813): DEBUG: 03:18:36.906: starting new processing pass
** (generate:1099813): DEBUG: 03:18:36.906: wls1: adding wifi AP 'ATTc58k66a'
** (generate:1099813): DEBUG: 03:18:36.906: We have some netdefs, pass them through a final round of validation
** (generate:1099813): DEBUG: 03:18:36.907: wls1: setting default backend to 1
** (generate:1099813): DEBUG: 03:18:36.907: Configuration is valid
** (generate:1099813): DEBUG: 03:18:36.907: enp1s0: setting default backend to 1
** (generate:1099813): DEBUG: 03:18:36.907: Configuration is valid
** (generate:1099813): DEBUG: 03:18:36.907: Generating output files..
** (generate:1099813): DEBUG: 03:18:36.907: openvswitch: definition enp1s0 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.907: NetworkManager: definition enp1s0 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.907: Creating wpa_supplicant config
** (generate:1099813): DEBUG: 03:18:36.907: wls1: Creating wpa_supplicant configuration file run/netplan/wpa-wls1.conf
** (generate:1099813): DEBUG: 03:18:36.907: Creating wpa_supplicant unit /run/systemd/system/netplan-wpa-wls1.service
(generate:1099813): GLib-DEBUG: 03:18:36.907: posix_spawn avoided (workdir specified) (fd close requested) 
** (generate:1099813): DEBUG: 03:18:36.926: Creating wpa_supplicant service enablement link /run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wls1.service
** (generate:1099813): DEBUG: 03:18:36.926: openvswitch: definition wls1 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.927: NetworkManager: definition wls1 is not for us (backend 1)
(generate:1099813): GLib-DEBUG: 03:18:36.927: posix_spawn avoided (fd close requested) 
(generate:1099813): GLib-DEBUG: 03:18:36.934: posix_spawn avoided (fd close requested) 

对于命令 'sudo lshw -C network' 我有:

*-network
       description: Ethernet interface
       product: RTL810xE PCI Express Fast Ethernet controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: enp1s0
       version: 02
       serial: 00:1f:16:d1:af:b7
       size: 100Mbit/s
       capacity: 100Mbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 duplex=full ip=192.168.1.124 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:16 ioport:3000(size=256) memory:d0410000-d0410fff memory:d0400000-d040ffff memory:d3700000-d371ffff
  *-network
       description: Wireless interface
       product: AR242x / AR542x Wireless Network Adapter (PCI-Express)
       vendor: Qualcomm Atheros
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wls1
       version: 01
       serial: 00:24:2c:63:3f:09
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=ath5k driverversion=5.4.0-66-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:17 memory:d2600000-d260ffff
  *-network
       description: Ethernet interface
       physical id: 2
       logical name: flannel.1
       serial: 32:06:6d:56:99:34
       capabilities: ethernet physical
       configuration: broadcast=yes driver=vxlan driverversion=0.1 ip=10.1.11.0 link=yes multicast=yes

命令“ grep -i wls1 /var/log/syslog* ”输出如下:

/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd[1]: Started WPA supplicant for netplan wls1.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: Interface name change detected, wls1 has been renamed to wlan0.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wlan0: Interface name change detected, wlan0 has been renamed to wls1.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: Link UP
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: IPv6 successfully enabled
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver cloud-init[867]: ci-info: |  wls1  | False |                    .                     |       .       |   .    | 00:24:2c:63:3f:09 |
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver kernel: [   15.765134] ath5k 0000:02:00.0 wls1: renamed from wlan0

命令“iwlist wls1 freq”显示如下:

wls1      11 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz



























           

答案1

为了使无线在服务器安装中工作,您需要安装wpasupplicantnet-tools

使用有线连接...

sudo apt update

sudo apt install wpasupplicant net-tools

reboot

您的 /etc/netplan/*.yaml 应该看起来完全像这样:

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: true
      optional: true
  wifis:
    wls1:
      dhcp4: true
      access-points:
        "A-----66a":
          password: "7m-----k8y"

然后/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg使用以下内容创建:

network: {config: disabled}

然后:

sudo netplan generate

sudo netplan apply

reboot

相关内容