我是 Linux 新手。所以我在 /etc/netplan/01-networkd-manager-all.yaml 中输入了以下内容:
network:
version: 2
renderer: NetworkManager
wifis:
wlp3s0:
dhcp: no
address: [192.168.0.222/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
access-points:
"Wifi Name":
password: "wifi password"
在终端中输入以下命令:
sudo netplan generate
sudo netplan -debug apply
调试输出:
** (generate:2606): DEBUG: 11:39:58.743: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:2606): DEBUG: 11:39:58.744: starting new processing pass
** (generate:2606): DEBUG: 11:39:58.744: wlp3s0: adding wifi AP 'Agujar Wifi'
** (generate:2606): DEBUG: 11:39:58.744: wlp3s0: setting default backend to 2
** (generate:2606): DEBUG: 11:39:58.744: Generating output files..
** (generate:2606): DEBUG: 11:39:58.744: networkd: definition wlp3s0 is not for us (backend 2)
DEBUG:no netplan generated networkd configuration exists
DEBUG:netplan generated NM configuration exists, restarting NM
DEBUG:wlp3s0 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets: {}
vlans: {}
wifis:
wlp3s0:
access-points:
Agujar Wifi:
password: *******
addresses:
- 192.168.0.222/24
dhcp4: false
gateway4: 192.168.0.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
DEBUG:Skipping non-physical interface: lo
DEBUG:Skipping non-physical interface: enp6s0
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp6s0
DEBUG:netplan triggering .link rules for wlp3s0
我已重启电脑,但它仍使用 dchp ip 地址。奇怪的是,当我使用 GUI 在详细信息选项卡上检查 wifi 设置时,它显示 192.168.0.24(DHCP 地址),但如果我更改为 IPv4 选项卡,它显示已设置为手动,并且所有内容与我在 yaml 文件中输入的内容相同。我猜我在这里错过了一个关键步骤。任何帮助都值得感激。