Jos*_*jen 7 dns systemd netplan systemd-networkd
我从Linode租用了一个 VPS ,上面安装了 Ubuntu 20.04 LTS (Focal Fossa)。但 Linode 的默认 DNS 服务器无法解析我真正需要它解析的域名。因此,我尝试编辑我的 netplan 配置,将 DNS 服务器更改为 Google 的服务器,因为 VPS 显然是无头的。我编辑了文件 /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:
eth0:
dhcp4: yes
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Run Code Online (Sandbox Code Playgroud)
Ubuntu 20.04默认使用networkd作为netplan后端。我检查了 YAML,它的格式正确。DHCP 默认情况下处于打开状态(通过设置 dhcp4: yes),将其关闭(通过设置 dhcp4: no)并不能解决该问题。eth0 是我的网络连接的名称ip a。但是,每当我sudo netplan apply保存 netplan 配置文件后运行时,活动名称服务器似乎都没有按照sudo systemd-resolve --status. 即使通过运行强制 networkd 重新启动sudo ip link set eth0 down和/sudo ip link set eth0 up或通过运行重新启动 systemd-resolved 也sudo systemctl restart systemd-resolved不会执行任何操作。
为什么在 Ubuntu Server 20.04 LTS 上更改 DNS 服务器如此困难?我在这里错过了什么吗?
预先非常感谢您的帮助,
约书亚
编辑:
输出sudo lshw -C network:
*-network
description: Ethernet controller
product: Virtio network device
vendor: Red Hat, Inc.
physical id: 4
bus info: pci@0000:00:04.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: msix bus_master cap_list rom
configuration: driver=virtio-pci latency=0
resources: irq:20 ioport:c080(size=64) memory:febd3000-febd3fff memory:fe
008000-fe00bfff memory:feb80000-febbffff
*-virtio2
description: Ethernet interface
physical id: 0
bus info: virtio@2
logical name: eth0
serial: f2:3c:93:91:e5:ed
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=virtio_net
driverversion=1.0.0 ip=170.187.185.46 link=yes multicast=yes
Run Code Online (Sandbox Code Playgroud)
输出sudo ls -al /etc/resolv.conf:
lrwxrwxrwx 1 root root 37 Feb 24 06:53 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf
Run Code Online (Sandbox Code Playgroud)
输出sudo cat /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 "resolvectl 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 trust-ad
search members.linode.com
Run Code Online (Sandbox Code Playgroud)
输出sudo 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
Run Code Online (Sandbox Code Playgroud)
输出cat /etc/netplan/*.yaml:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
dhcp4-overrides:
use-dns: false
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Run Code Online (Sandbox Code Playgroud)
转至https://netplan.io/reference/并查看有关DHCP 覆盖的部分。
/etc/netplan/01-netcfg.yaml...
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
dhcp4-overrides:
use-dns: false
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Run Code Online (Sandbox Code Playgroud)
sudo netplan generate
sudo netplan apply
reboot# 如果需要
| 归档时间: |
|
| 查看次数: |
19417 次 |
| 最近记录: |