Fedora DNS配置持久化
操作系统
通过Virtual Box安装Fedora 37,操作系统信息如下所示:
[root@localhost ~]# cat /etc/os-release
NAME="Fedora Linux"
VERSION="37 (Server Edition)"
ID=fedora
VERSION_ID=37
VERSION_CODENAME=""
PLATFORM_ID="platform:f37"
PRETTY_NAME="Fedora Linux 37 (Server Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:37"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f37/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=37
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=37
VARIANT="Server Edition"
VARIANT_ID=server
网卡设置:
- enp0s3:网络地址转换(NAT);
- enp0s8:仅主机(host-only)网络;
DNS自动配置
安装后,DNS配置信息如下所示:
[root@localhost system-connections]# resolvectl status
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp0s3)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.11.28
DNS Servers: 192.168.11.28 192.168.78.39 192.168.78.40
Link 3 (enp0s8)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
可以看到enp0s3网卡使用192.168.11.28
局域网地址作为DNS server,解析部分域名存在问题,因此尝试更换为阿里云DNS。
更换DNS Server
sudo resolvectl dns enp0s3 223.5.5.5 223.6.6.6
查看更换后DNS信息
resolvectl status
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp0s3)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 223.5.5.5 223.6.6.6
Link 3 (enp0s8)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
查看可知,DNS配置已变更。
Tips
修改/etc/resolv.conf。实际上不生效,且每次重启机器后,DNS Server信息会丢失。