我到处都找过了,但仍然无法解决这个问题
naoapp01@naoapp01:/etc/netplan$ sudo netplan apply
Error in network definition /etc/netplan/50-cloud-init.yaml line 8 column 12: expected mapping
以下是 01-netcfg.yaml 的内容
# 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
ethernets:
ens18:
addresses: [192.168.1.222/24]
gateway4: 192.168.1.1
dhcp4: false
nameservers:
addresses: [192.168.1.2,192.168.1.221,8.8.8.8,8.8.4.4]
optional: true
答案1
尝试这个稍微修改过的 .yaml 文件...
复制/粘贴整个文本...
显示生成步骤期间的任何错误...
确保保持缩进、间距,并且没有制表符......
# 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:
ens18:
addresses: [192.168.1.222/24]
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.2,192.168.1.221,8.8.8.8,8.8.4.4]
optional: true
sudo netplan --debug generate
# 生成配置文件
sudo netplan apply
# 应用配置
reboot
#确认操作正确