我已经使用 配置了我的Ubuntu bionic (18.04)
服务器中的网络接口netplan
,然后我运行netplan apply
并启动了配置。特别是,我配置了 DNS 服务器,并且我的服务器确实使用我在配置中配置的名称服务器解析了 ips netplan
。
但是,重新启动后,配置并没有持续,并且默认情况下任何解析都是127.0.0.53
名称服务器。只有在运行netplan apply
配置后再次启动。
如何使netplan
配置持续到重新启动?
输出cat /etc/*-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
输出cat /etc/network/interfaces
:
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
我的 netplan yaml 文件:
10-nameservers.yaml
:
network:
version: 2
ethernets:
ens160:
nameservers:
addresses: [127.0.0.1]
50-cloud-init.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:
ethernets:
ens160:
addresses: []
dhcp4: true
dhcp-identifier: mac
version: 2
interfaces_ens160.yaml
network:
ethernets:
ens160:
addresses: [172.16.0.1/16]
dhcp4: 'no'
dhcp6: 'no'
gateway4: 172.16.100.1
nameservers:
addresses: [10.0.0.8, 8.8.8.8, 10.15.0.18]
version: 2