ubuntu重做系统后无法apt update

检查 DNS 解析

复制代码
resolvectl status

resolvectl status

Global

Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

resolv.conf mode: stub

Link 2 (ens27f0)

Current Scopes: none

Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 3 (ens27f1)

Current Scopes: none

Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

  • Global 配置正常(stub模式)

  • 但是 Link 2 (ens27f0) 的 Current Scopes 为 none,说明 systemd-resolved 没有在这个接口上启用 DNS 解析

立即修复

1. 为接口设置 DNS

复制代码
# 为 ens27f0 设置 DNS 服务器
sudo resolvectl dns ens27f0 114.114.114.114 223.5.5.5

# 设置 DNS 搜索域(可选)
sudo resolvectl domain ens27f0 ""

# 启用这个接口的 DNS 解析
sudo resolvectl default-route ens27f0 true

2. 验证设置是否生效

复制代码
# 再次查看状态
resolvectl status

# 应该看到 Link 2 (ens27f0) 的 Current Scopes 变为 DNS

3. 测试网络连通性

复制代码
# 先测试网关(根据之前的 ip route 输出)
ping -c 4 10.107.16.1

# 测试外网 IP
ping -c 4 8.8.8.8

# 测试域名解析
ping -c 4 www.baidu.com

持久化配置

如果临时修复有效,需要持久化配置:

sudo nano /etc/systemd/resolved.conf

Resolve

DNS=114.114.114.114 223.5.5.5

FallbackDNS=8.8.8.8 1.1.1.1

#Domains=~

DNSSEC=no

重启服务:

sudo systemctl restart systemd-resolved

方案二:

复制代码
sudo nano /etc/netplan/50-cloud-init.yaml
复制代码
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens27f0:
            dhcp4: no
            addresses:
              - 10.107.16.199/24
            gateway4: 10.107.16.1
            nameservers:
              addresses: [114.114.114.114, 223.5.5.5]
        ens27f1:
            dhcp4: true
    version: 2
相关推荐
高梦轩4 小时前
MySQL高可用
android·运维·数据库
hsjcjh7 小时前
Nodemailer使用教程:在Node.js中发送电子邮件
linux·运维·node.js
没有梦想的咸鱼185-1037-16638 小时前
北斗高精度数据解算:破解城市峡谷/长基线/无网区难题,从毫米级定位到自动化交付——(GAMIT/GLOBK底层核心解算技术方法)
运维·arcgis·数据分析·自动化
不怕犯错,就怕不做8 小时前
linux 如何查看自己的帐号密码及samba的帐号和密码
linux·运维·服务器
实在智能RPA8 小时前
Agent 在物流行业能实现哪些自动化?——深度拆解 AI Agent 驱动的智慧物流新范式
运维·人工智能·ai·自动化
地下核武8 小时前
Ubuntu 24.04 在线安装 Qt 6.10.2 后 Qt Creator 无法启动问题记录与解决
linux·qt·ubuntu
张3239 小时前
Linux 启动过程
linux·运维
三万棵雪松9 小时前
【Linux 物联网网关主控系统-Linux主控部分(二)】
linux·嵌入式linux
chinesegf9 小时前
ubuntu建虚拟环境制作docker容器
linux·ubuntu·docker
Stack Overflow?Tan909 小时前
标注软件labelImg在linux下鼠标滚轮闪退解决办法
linux·labelimg