在 Debian 中,ifconfig 命令来自 net-tools 软件包。现代 Debian 默认不再安装它,因此你需要手动安装。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
which ifconfig
或
ifconfig -a
ifconfig 属于 net-tools,已被认为 过时。Debian 推荐使用 iproute2 提供的 ip 命令:
ip addr # 查看网卡和 IP
ip link # 查看网卡状态
ip route # 查看路由
例如:
ip addr show
如果你不想安装 net-tools,可以直接用 ip 命令替代,功能更强也更安全。
你可能使用的是最小化系统,先确认网络正常:
ip addr
确保使用 sudo,或切换到 root:
su -
✅ 安装命令
sudo apt install net-tools
✅ 更现代的替代
ip addr
如果你告诉我 Debian 版本(如 10 / 11 / 12) 或 是服务器还是桌面版,我可以给你更精确的建议。