在 Debian 中,ifconfig 属于 net-tools 工具包,默认往往没有安装。可以通过下面方式安装和使用。
sudo apt update
sudo apt install net-tools
安装完成后就可以使用:
ifconfig
现代 Debian 更推荐使用 iproute2 提供的 ip 命令,功能更强:
ip addr # 查看网卡和 IP
ip link # 查看网卡状态
ip route # 查看路由
例如:
ip addr show
ifconfig: command not found说明 net-tools 未安装,按上面步骤安装即可。
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo ifconfig eth0 up
⚠️ 重启后会失效。
| 工具 | 建议 |
|---|---|
ifconfig |
老脚本、习惯兼容 |
ip |
新系统、生产环境 |
如果你告诉我 Debian 版本(如 11 / 12) 或 是服务器还是桌面版,我可以给你更合适的网络配置方案。