温馨提示×

Debian中ifconfig怎么安装

小樊
45
2026-08-31 10:28:40
栏目: 智能运维

Debian 中,ifconfig 属于 net-tools 工具包,默认往往没有安装。可以通过下面方式安装和使用。

一、安装 ifconfig

sudo apt update
sudo apt install net-tools

安装完成后就可以使用:

ifconfig

二、更推荐的方式(新系统)

现代 Debian 更推荐使用 iproute2 提供的 ip 命令,功能更强:

ip addr      # 查看网卡和 IP
ip link      # 查看网卡状态
ip route     # 查看路由

例如:

ip addr show

三、可能遇到的问题

1️⃣ 提示 ifconfig: command not found

说明 net-tools 未安装,按上面步骤安装即可。

2️⃣ 临时配置网卡(不持久)

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo ifconfig eth0 up

⚠️ 重启后会失效。


四、建议使用场景

工具 建议
ifconfig 老脚本、习惯兼容
ip 新系统、生产环境

如果你告诉我 Debian 版本(如 11 / 12)是服务器还是桌面版,我可以给你更合适的网络配置方案。

0