在 Linux 中,使用 ifconfig 关闭(停用)网卡的方法如下:
sudo ifconfig <网卡名> down
例如,关闭 eth0:
sudo ifconfig eth0 down
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)。
如果你是在做实验、断网测试或配置网络,我也可以帮你写对应场景的命令。