首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >尝试配置时出现的Netplan错误

尝试配置时出现的Netplan错误
EN

Ask Ubuntu用户
提问于 2021-09-15 16:45:04
回答 1查看 3.4K关注 0票数 0

我正在远程 Raspberry Pi 4上运行Ubuntu服务器20.04.3LTS。它通过WiFi连接到一个远程路由器(IP 192.168.1.1),并且我已经用netplan配置了网络。然而,几个月后,我决定更改DNS配置,即删除我的路由器本地DNS,并将其替换为Cloudflare的DNS。因此,知道yaml文件对空格非常敏感,我所做的唯一更改就是删除"92“和"68",因此文件现在如下:

代码语言:javascript
运行
复制
$ cat /etc/netplan/50-cloud-init.yaml
# 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:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: true
    wifis:
        wlan0:
            dhcp4: no
            addresses: [192.168.1.12/24]
            gateway4: 192.168.1.1
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]
            access-points:
                "accesspointname":
                    password: "accesspointpassword"
    version: 2

然而,当我运行netplan尝试时,我会得到以下内容:

代码语言:javascript
运行
复制
$ sudo netplan try
Job for netplan-wpa-wlan0.service canceled.

An error occurred: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

Reverting.
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

另外,有时我会得到以下错误:

代码语言:javascript
运行
复制
$ sudo netplan try
Job for netplan-wpa-wlan0.service canceled.

An error occurred: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

Reverting.
Job for netplan-wpa-wlan0.service canceled.
Traceback (most recent call last):
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 84, in command_try
    NetplanApply().command_apply(run_generate=True, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 164, in command_apply
    utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services)
  File "/usr/share/netplan/netplan/cli/utils.py", line 131, in systemctl_networkd
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in 
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 66, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 95, in command_try
    self.revert()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 118, in revert
    NetplanApply().command_apply(run_generate=False, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 164, in command_apply
    utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services)
  File "/usr/share/netplan/netplan/cli/utils.py", line 131, in systemctl_networkd
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

我希望对此非常小心,因为我不希望在网络配置错误的情况下被永久地锁在门外,因为我没有本地访问权限来修复需要的东西(这就是为什么我运行netplan尝试。我不确定是否重新启动系统,是否会被锁在门外?)有什么建议吗?

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2021-09-15 17:31:38

看看这有什么区别..。

注意:确认没有制表符,只有空格

:普通缩进是两个空格

代码语言:javascript
运行
复制
network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    wifis:
        wlan0:
            addresses: [192.168.1.12/24]
            gateway4: 192.168.1.1
            nameservers:
                addresses: [1.1.1.1, 1.0.0.1]
            access-points:
                "accesspointname":
                    password: "accesspointpassword"

并创建/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg...

代码语言:javascript
运行
复制
network: {config: disabled}

然后..。

sudo netplan try

等你准备好了。

sudo netplan generate

sudo netplan apply

reboot

票数 2
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1363961

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档