我试图覆盖 netplan yaml 配置中的名称服务器设置,但它似乎不起作用。这是 /etc/netplan/01-netcfg.yaml 文件:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp4-overrides:
use-dns: no
nameservers:
addresses: [192.168.1.7]
Run Code Online (Sandbox Code Playgroud)
我正在运行Ubuntu 18.04.3 LTS(我更改了名称服务器 IP 地址,但其他一切都相同)。另外,当我运行时netplan --debug generate,它会产生以下结果:
** (generate:1951): DEBUG: 20:05:57.212: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:1951): DEBUG: 20:05:57.212: starting new processing pass
** (generate:1951): DEBUG: 20:05:57.212: eth0: setting default backend to 1
** (generate:1951): DEBUG: 20:05:57.212: Configuration is valid
** (generate:1951): DEBUG: 20:05:57.212: Generating output files..
** (generate:1951): DEBUG: 20:05:57.212: NetworkManager: definition eth0 is not for us (backend 1)
Run Code Online (Sandbox Code Playgroud)
真正令人困惑的是没有任何/run/netplan目录......
我还应该提到这是一个虚拟专用服务器,所以我无法访问裸机...不确定这是否重要...另外,我使用 eth0 的原因是因为这是唯一的一个当我运行时显示ifconfig,除了环回地址。/etc/netplan/01-netcfg.yaml我从托管公司获得服务器时的原始文件是:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
Run Code Online (Sandbox Code Playgroud)
我想重新配置它,以便我可以使用另一个虚拟专用服务器作为 DNS 服务器......
编辑 只是想提及显示systemd-resolve --statusDNS 服务器是 DHCP 配置的原始服务器的输出,而不是被上面的 netplan 配置覆盖的服务器。它似乎不接受网络规划设置。
编辑2 在回答评论中发布的一些问题时,我相信托管公司已经安装了Ubuntu Server而不是桌面安装。据我所知,我只能通过终端访问VPS,而且我不相信我可以访问GUI桌面。至于其他问题,我已经恢复到原始/etc/netplan/01-netcfg.yaml文件并重新启动服务器。现在,它应该回到原来的配置:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
Run Code Online (Sandbox Code Playgroud)
另外,当我这样做时,它看起来不像 dhclient 正在运行...如果 dhclient 没有在计算机上运行,ps aux | grep -i dhc如何配置 /etc/netplan/01-netcfg.yaml 文件?dhcp4: yes
当我跑步时ip a,我得到
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
...
Run Code Online (Sandbox Code Playgroud)
但没有提到 enp0s3...同样对于该ifconfig命令,它只提到 eth0 而不是 enp0s3...
这是 /etc/resolv.conf 文件:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver <Some loopback IP>
options edns0
search home
Run Code Online (Sandbox Code Playgroud)
我更改了上面的值nameserver以及选项的值seach。
systemd-resolve --status在其输出的底部包含以下内容:
Link 2 (eth0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: <IP1>
<IP2>
<IP3>
DNS Domain: <domain1>
Run Code Online (Sandbox Code Playgroud)
其中 IP1、IP2 和 IP3 是我不希望用于 DNS 的三个 IPv4 地址,domain1 是我也没有使用的域名。如果可以找到任何其他有用的信息,请在评论中告诉我。由于 dhclient 未运行,我是否应该在 /etc/netplan/01-netcfg.yaml 中配置静态 IP?eth0另一个问题,使用网络设备而不是是否更有意义,因为后者在运行enp0s3时不存在?ip a
编辑 3 知道有问题的服务器是由 Linode 提供的可能会很有用。我停用了他们的 Linode Network Helper,以便设置我自己的 DNS 服务器。只是认为了解它是有用的信息...它应该只是一个常规Ubuntu 18.04服务器。
对更新 1 的回应 - 请参阅 Heynnema 的回应
所以,用/etc/netplan/01-netcnf.yamlas重新启动后
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp4-overrides:
use-dns: no
nameservers:
addresses: [ 192.168.1.7 ]
Run Code Online (Sandbox Code Playgroud)
并/etc/systemd/resolved.conf作为
# 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=
DNS=192.168.1.7
#FallbackDNS=
#Domains=
Domains=mydomain.com
#LLMNR=no
LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
Run Code Online (Sandbox Code Playgroud)
我有以下内容:
/run/resolvconf/resolv.conf系统上不存在。
cat /run/systemd/resolve/resolv.conf产生:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 192.168.1.7
nameserver IP1
nameserver IP2
# Too many DNS servers configured, the following entries may be ignored.
nameserver IP3
search mydomain.com <domain1>
Run Code Online (Sandbox Code Playgroud)
其中 IP1、IP2 和 IP3 与 的原始输出中的 IP1、IP2 和 IP3 匹配systemd-resolve --status。
cat /run/systemd/resolve/stub-resolv.conf产生:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search mydomain.com <domain1>
Run Code Online (Sandbox Code Playgroud)
此外,还dpkg -l *dnsmasq* | grep ii生产:
ii dnsmasq-base 2.79-1 amd64 Small caching DNS proxy and DHCP/TFTP server
Run Code Online (Sandbox Code Playgroud)
并dpkg -l *dhcp* | grep ii产生:
ii isc-dhcp-client 4.3.5-3ubuntu7.1 amd64 DHCP client for automatically obtaining an IP address
ii isc-dhcp-common 4.3.5-3ubuntu7.1 amd64 common manpages relevant to all of the isc-dhcp packages
Run Code Online (Sandbox Code Playgroud)
但是,当我运行ps aux | grep dnsand时ps aux | grep dh,除了 grep 本身之外,没有返回任何结果。
编辑4
如果有人感兴趣的话,/etc/systemd/network/05-eth0.network除去评论后的内容是:
[Match]
Name=eth0
[Network]
DHCP=no
DNS=IP1 IP2 IP3
Domains=<domain1>
IPv6PrivacyExtensions=false
Gateway=the_gateway_ip
Address=my_public_ip
Address=my_private_ip
Run Code Online (Sandbox Code Playgroud)
其中 IP1、IP2 和 IP3 是我需要覆盖的名称服务器 IP,domain1 是托管提供商创建的域名。网关和两个地址设置是我需要的正确设置。我只是想覆盖 DNS 设置,因此重命名该文件以避免其被使用就达到了目的。
提前谢谢了!
我打电话给托管提供商,他们指示我查看两个配置文件。一个是我知道的 netplan 配置文件,但另一个是/etc/systemd/network/05-eth0.network. 通过在.文件名前面放置 a 来重命名该文件,然后重新启动服务器,所做的更改将对/etc/netplan/01-netcfg.yamldevice 生效eth0。我将文件的内容添加到问题的最后更新中,以防它可以帮助任何人。
| 归档时间: |
|
| 查看次数: |
21322 次 |
| 最近记录: |