温馨提示×

ifconfig为何Debian不能用

小樊
38
2026-07-21 21:18:41
栏目: 智能运维

在 Debian 里 ifconfig 不能用,通常不是系统坏了,而是这个命令已经不再默认安装。原因和解决办法如下:


一、为什么 Debian 里没有 ifconfig

1️⃣ ifconfig 已被弃用

ifconfig 属于 net-tools 工具包,这个包已经多年不维护,功能落后,官方不再推荐使用。

Debian 官方现在默认使用 iproute2 工具集:

旧命令 新命令
ifconfig ip addr
route ip route
arp ip neigh
netstat ss

2️⃣ Debian 默认不再安装 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 推荐方式


✅ 方案三:使用 NetworkManager(桌面用户)

如果是桌面版 Debian:

nmcli device status

四、总结一句话

Debian 不是不能用 ifconfig,而是默认不再安装它。

  • 想继续用 → 装 net-tools
  • 想跟官方走 → 学 ip 命令(强烈推荐)

如果你愿意,我可以:

  • 帮你 ifconfig 命令翻译成 ip 命令
  • 或根据你的 Debian 版本 + 使用场景 给你最合适的网络配置方案

0