我在 openstack 环境中使用 CoreOS,并且用它cloud-config.yml
来引导主机。
#cloud-config
write_files:
- path: /etc/systemd/resolved.conf
permissions: 0644
owner: root
content: |
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=10.8.20.40
# FallbackDNS=
# LLMNR=yes
但这不会在首次启动时反映 DNS 服务器。如果我重新启动 CoreOS 主机,它就会正常工作。如何让 DNS 更改在首次启动时生效?我可以发出systemctl
重新启动命令吗?
答案1
CoreOS 并未实现所有的 cloud-init 钩子。但它有一个叫做units
对于 DNS 设置,请使用如下所述的网络单元:https://coreos.com/os/docs/latest/network-config-with-networkd.html#cloud-config
答案2
我发现的最佳解决方案是/etc/resolv.conf
通过write_files
本例中所示的部分创建自己的解决方案云配置
#cloud-config
write_files:
- path: "/etc/resolv.conf"
permissions: "0644"
owner: "root"
content: |
nameserver 8.8.8.8