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
相关推荐
努力搬砖的鱼1 小时前
校园网运维-生成树协议实战
运维·网络
蜕变的小白1 小时前
Linux系统编程:揭秘网络通信 IP与端口号的奥秘
linux·网络·网络协议·tcp/ip
爱倒腾的老唐2 小时前
02、STM32——嵌入式芯片
linux·stm32·嵌入式硬件
AryShaw2 小时前
macOS 上搭建 RK3568 交叉编译环境
linux·macos
芒果披萨2 小时前
Linux文件类基础命令行1
linux·运维·服务器
学嵌入式的小杨同学2 小时前
STM32 进阶封神之路(八):外部中断 EXTI 实战 —— 按键检测从轮询到中断(库函数 + 寄存器双版本)
linux·stm32·单片机·嵌入式硬件·mcu·架构·硬件架构
杨云龙UP4 小时前
ODA服务器RAC节点2/u01分区在线扩容操作记录及后续处理流程(Linux LVM + ext4 文件系统在线扩容操作手册)_20260307
linux·运维·服务器·数据库·ubuntu·centos
欲买桂花同载酒58211 小时前
程序人生-Hello’s P2P
运维·服务器·数据库
NineData11 小时前
AI时代的数据对比:DBA还需要盯着屏幕看差异吗?
运维·数据库