在 Debian 里 ifconfig 不能用,通常不是系统坏了,而是这个命令已经不再默认安装。原因和解决办法如下:
ifconfigifconfig 已被弃用ifconfig 属于 net-tools 工具包,这个包已经多年不维护,功能落后,官方不再推荐使用。
Debian 官方现在默认使用 iproute2 工具集:
| 旧命令 | 新命令 |
|---|---|
| ifconfig | ip addr |
| route | ip route |
| arp | ip neigh |
| netstat | ss |
net-tools从 Debian 9(Stretch) 开始:
net-tools所以你执行:
ifconfig
会看到:
bash: ifconfig: command not found
which ifconfig
或:
command -v ifconfig
如果没输出,就是没装。
ifconfig(最常用)sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
✅ 适合习惯老命令的用户
查看网卡和 IP:
ip addr
启用/禁用网卡:
sudo ip link set eth0 up
sudo ip link set eth0 down
查看路由:
ip route
查看端口:
ss -tunlp
✅ 这是 Debian 推荐方式
如果是桌面版 Debian:
nmcli device status
Debian 不是不能用
ifconfig,而是默认不再安装它。
net-toolsip 命令(强烈推荐)如果你愿意,我可以:
ifconfig 命令翻译成 ip 命令