用 ip link 启用或禁用网络接口

在终端里手动关闭/开启网卡,快速重置抽风的连接。

Linux网络接口网络故障排查中风险
执行 sudo ip link set dev enp3s0 down 禁用网卡,再用 sudo ip link set dev enp3s0 up 重新启用。

01命令

命令
$ sudo ip link set dev enp3s0 up

02作用说明

ip link 工作在链路层:up/down 切换接口状态,同一个子命令还能设置 MTU、MAC 地址或混杂模式。网卡卡在“无载波”、Wi-Fi 停止扫描时,直接翻转接口状态是最快的复位手段。注意它只改链路状态——分配 IP 是 ip addr 的事,NetworkManager 通常会自动恢复地址。

03风险

风险中风险
使用条件iproute2 package; root access. Interface names differ per machine — find yours with ip link show. If you are connected over SSH via that interface, you will cut yourself off.
!注意: 如果你正通过这块网卡 SSH 连着机器,down 的一瞬间连接就断了;要么用一句能自动重新启用的组合命令,要么确保有控制台可登录。受 NetworkManager 或 systemd-networkd 管理的接口可能会把你的修改自动改回去。

04撤销

撤销
$ sudo ip link set dev enp3s0 down

05来源

  • ip-link(8) — Debian bookworm
    Debian Manpages · community · 2026-09-17
    依据: Documents ip link set - change device attributes, with the [ { up | down } ] state argument and dev DEVICE selector.
  • ip-link(8) — Arch Manual Pages
    Arch Linux · community · 2026-09-17
    依据: Shows the same 'ip link set - change device attributes' synopsis including the up/down device state option.

最后验证: 2026-09-19 · 分类: 网络

06相关方案