You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

QEMU虚拟机DNS解析失效(已按Arch Wiki规范配置)

解决虚拟机内systemd-resolved DNS解析失败问题

排查与修复步骤

  • 确认systemd-resolved服务运行状态:

    systemctl status systemd-resolved
    

    若服务未启动,执行以下命令启动并设置开机自启:

    systemctl start systemd-resolved
    systemctl enable systemd-resolved
    
  • 检查/etc/resolv.conf配置:
    该文件需为指向/run/systemd/resolve/stub-resolv.conf的软链接,若链接异常,重新创建:

    ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
    
  • 手动配置公共DNS服务器:
    编辑/etc/systemd/resolved.conf,取消DNS行注释并添加公共DNS地址:

    [Resolve]
    DNS=8.8.8.8 1.1.1.1
    

    重启服务使配置生效:

    systemctl restart systemd-resolved
    
  • 验证DNS服务器连通性:
    先ping指定的DNS服务器,确认网络可达:

    ping 8.8.8.8 -c 3
    

    若不通,排查虚拟机网络模式(如NAT配置是否正常)、系统防火墙是否拦截53端口(DNS默认使用UDP/TCP 53端口)。

  • 检查防火墙规则:
    确保允许DNS端口的出站流量,以iptables为例:

    iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
    iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
    

验证解析恢复

执行以下命令确认域名解析正常:

resolvectl query google.com
ping google.com -c 3

内容的提问来源于stack exchange,提问作者Benedict Schlütter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 12:45:43