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

AWS Ubuntu 22.04内核更新后重启网卡无法自动启用的问题咨询

AWS Ubuntu 22.04内核更新后重启网卡无法自动启用的问题咨询

大家好,我遇到一个挺棘手的问题,想请教下各位大佬:

我在AWS上部署的Ubuntu 22.04.01实例,最近执行apt upgrade时顺便把内核更到了6.2.0-1017-aws,结果重启之后直接断网了,只能通过AWS控制台登录进去排查。

登录后发现ifconfig只显示lo回环接口在正常运行,原本带私有IP的ens5接口完全没上线;用ip a查看的话,这个接口确实存在,但状态是DOWN:

root@test:~# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 336  bytes 26160 (26.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 336  bytes 26160 (26.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@test:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 12:af:bd:fe:c2:c3 brd ff:ff:ff:ff:ff:ff
    altname enp0s5

我去查了netplan的配置文件/etc/netplan/50-cloud-init.yaml,这个是AWS云服务自动生成的,重启会自动重写,里面的配置看起来没毛病,dhcp4明确设为true:

# 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:
        ens5:
            dhcp4: true
            dhcp6: false
            match:
                macaddress: 12:af:bd:fe:c2:c3
            set-name: ens5
    version: 2

手动运行dhclient就能立刻解决问题,甚至不用手动启动接口,它会自动把ens5拉起来,还能拿到预期的静态私有IP:

root@test:~# dhclient
root@test:~# ifconfig
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.1.200 netmask 255.255.255.0  broadcast 172.31.1.255
        inet6 fe80::10af:bdff:fefe:c2c3  prefixlen 64  scopeid 0x20<link>
        ether 12:af:bd:fe:c2:c3  txqueuelen 1000  (Ethernet)
        RX packets 3  bytes 680 (680.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9  bytes 990 (990.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 496  bytes 38048 (38.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 496  bytes 38048 (38.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

目前我用crontab -e加了@reboot dhclient到定时任务里,重启后就不会断网了,但总觉得这个方法有点“凑活”,不够规范。我主要想搞明白:为什么内核更新之后,网卡不能像之前一样自动启动?有没有更合适的、更符合Ubuntu/netplan规范的解决办法?也希望我的临时方案能帮到遇到同样问题的朋友。

备注:内容来源于stack exchange,提问作者joeyofblades

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.20 10:10:35