我正在尝试在 Ubuntu 20.04 中配置网络。我想在同一个界面下设置多个 wifi 接入点。
我现在正在使用以下配置:
# 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
addresses: [x.y.z.w/24]
optional: true
version: 2
wifis:
wlan0:
dhcp4: false
gateway4: x.y.z.w
addresses: [x.y.z.w/24]
access-points:
"SSID":
password: "pass"
但只能指定一个接入点。是否可以设置具有相应凭据的 wifi 网络列表?
答案1
也许你已经找到了答案,仍在发布,确保两个热点都是 2.4GHz。只需将粗体行附加到/etc/netplan/50-something.yaml
文件 L
wifis:
wlan0:
dhcp4: false
gateway4: x.y.z.w
addresses: [x.y.z.w/24]
access-points:
"SSID1":
password: "pass1"
"SSID2":
password: "pass2"
答案2
示例代码如下。
# 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
addresses: [x.y.z.w/24]
optional: true
version: 2
wifis:
wlan0:
access-points:
"first-network-ssid":
password: 'first-network-password'
dhcp4: true
optional: true
wlan0:
access-points:
"second-network-ssid":
password: 'second-network-password'
dhcp4: true
这
第一个网络 SSID
应该替换为你的第一个网络 ssid,然后
第一个网络密码
应该替换为你的第一个网络密码,因此
第二个网络的 SSID
第二个网络密码
如果需要添加另一个 wifi,请将 wlan config 添加为 wifis 的子节点。
标题必须是wlan0。
最后更新网络计划。
到选择 wifi,首先显示wifi列表
sudo wpa_cli -i wlan0 list_networks
它将显示 network_id 和 network_ssid,然后通过 network_id 选择。
sudo wpa_cli -i wlan0 select_network network_id