在较新版本的 Debian(如 Debian 9 及以后)中,ifconfig 命令默认不再安装,因为它属于 net-tools 软件包,而 Debian 推荐使用 ip 命令(来自 iproute2)。
如果你需要使用 ifconfig,可以按以下方法启用:
sudo apt update
sudo apt install net-tools
安装完成后,就可以直接使用:
ifconfig
Debian 官方推荐使用 ip 命令替代 ifconfig:
ip addr
sudo ip link set eth0 up
sudo ip link set eth0 down
如果你只是偶尔需要,可以用:
/sbin/ifconfig
但前提是系统里已经存在该命令(通常没有)。
apt install net-toolsip 命令如果你告诉我你的 Debian 版本(如 11 / 12),我可以给你更具体的建议。