在 Debian 里,ifconfig 已经不再默认安装,它属于 net-tools 软件包。你可以通过安装 net-tools 来使用 ifconfig。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
Debian 官方更推荐使用 ip 命令(来自 iproute2,一般已默认安装):
ip addr # 查看网卡和 IP
ip link # 查看网卡状态
ip route # 查看路由
例如:
ip addr show
ifconfig: command not found说明没有安装 net-tools,按方法一安装即可。
不是必须。
ifconfig:老工具,功能有限ip:现代、功能更强,推荐学习使用| 工具 | 是否需要安装 | 推荐程度 |
|---|---|---|
| ifconfig | 需要 | ⭐⭐ |
| ip | 通常已安装 | ⭐⭐⭐⭐⭐ |
如果你是在 服务器 / 容器 / 最小化 Debian 环境,我也可以帮你判断用哪种方式更合适。