温馨提示×

debian怎么执行ifconfig

小樊
39
2026-10-06 12:45:37
栏目: 智能运维

在 Debian 中执行 ifconfig 通常有以下几种情况和做法:


1️⃣ 直接执行(可能失败)

ifconfig

如果提示:

bash: ifconfig: command not found

说明 没有安装 net-tools。


2️⃣ 安装 net-tools(推荐旧方式)

sudo apt update
sudo apt install net-tools

安装完成后即可使用:

ifconfig

3️⃣ 使用现代替代命令(推荐)

Debian 新版本默认使用 ip 命令:

ip addr       # 查看网卡信息(类似 ifconfig)
ip link      # 查看网卡状态
ip route     # 查看路由

4️⃣ 只看某个网卡

ifconfig eth0
# 或
ip addr show eth0

5️⃣ 需要 root 权限?

普通用户一般可以查看,但 修改配置需要 sudo:

sudo ifconfig eth0 up

✅ 总结

方式 命令
传统 ifconfig(需安装 net-tools)
推荐 ip addr

如果你是想 配置 IP / 重启网卡 / 查看公网 IP,可以告诉我具体需求。

0 踩