在 Debian(尤其是较新版本,如 Debian 9 及以后)中,ifconfig 命令默认 不再预装,所以你会遇到:
bash: ifconfig: command not found
ifconfig 属于 net-tools 工具包,而 Debian 已逐步使用 iproute2(ip 命令)替代它。
sudo apt update
sudo apt install net-tools
安装后即可使用:
ifconfig
ip查看网卡信息:
ip addr
或简写:
ip a
查看路由:
ip route
启用/禁用网卡:
sudo ip link set eth0 up
sudo ip link set eth0 down
which ifconfig
如果返回路径但仍无效,可尝试:
/sbin/ifconfig
ip 命令ifconfig 仅用于兼容旧习惯或脚本如果你是在 Docker / 最小化 Debian / LXC 环境中,也可以告诉我,我可以给你更合适的方案。