温馨提示×

debian为何ifconfig缺失

小樊
42
2026-09-06 16:08:55
栏目: 智能运维

在 Debian(尤其是较新版本,如 Debian 9 及以后)中,ifconfig 命令“缺失”或默认不可用,主要原因如下:


1. ifconfig 属于 net-tools,已被官方弃用

  • ifconfig、route、netstat 等命令来自 net-tools 软件包
  • 这些工具已经多年不再维护,功能落后于现代网络管理

Debian 官方推荐使用 iproute2 套件替代:

  • ip addr(替代 ifconfig)
  • ip route(替代 route)
  • ss(替代 netstat)

2. 新装系统默认不安装 net-tools

在最小化安装或新版本 Debian 中:

  • 默认只包含 ip 命令
  • net-tools 不会自动安装

所以你执行:

ifconfig

会得到:

bash: ifconfig: command not found

3. 如何确认与解决

检查是否安装

which ifconfig

若无输出,说明未安装。

临时/长期使用推荐(现代方式)

ip addr
ip link
ip route

如果确实想用 ifconfig

安装 net-tools:

sudo apt update
sudo apt install net-tools

安装后即可使用:

ifconfig

4. 建议

✅ 新系统、新脚本:优先使用 ip 命令
❌ 不建议在新项目中依赖 ifconfig


如果你愿意,我也可以:

  • 对比 ifconfig vs ip 的命令对照表
  • 解释 Debian 网络配置方式(/etc/network/interfaces vs NetworkManager)

0 踩