温馨提示×

linux ifconfig如何关闭网卡

小樊
34
2026-10-10 21:31:28
栏目: 智能运维

在 Linux 中,使用 ifconfig 关闭(停用)网卡的方法如下:

1. 关闭指定网卡

sudo ifconfig <网卡名> down

例如,关闭 eth0:

sudo ifconfig eth0 down

2. 重新开启网卡(可选)

sudo ifconfig <网卡名> up

例如:

sudo ifconfig eth0 up

补充说明

  • 查看网卡名称:

    ifconfig -a
    

    或(较新系统):

    ip addr
    
  • ifconfig 已逐渐被 ip 命令取代,等价写法为:

    sudo ip link set eth0 down
    sudo ip link set eth0 up
    
  • 关闭网卡只是临时禁用,重启系统后可能恢复,具体取决于网络管理服务(如 NetworkManager、systemd-networkd)。

如果你是在做实验、断网测试或配置网络,我也可以帮你写对应场景的命令。

0 踩