温馨提示×

debian怎么调用ifconfig

小樊
36
2026-10-09 11:40:17
栏目: 智能运维

在 Debian 里,ifconfig 属于 net-tools 工具包,而较新版本(Debian 9 及以后)默认没有安装这个包,所以直接运行会提示命令找不到。

一、先确认是否安装了 ifconfig

which ifconfig

或

ifconfig

如果提示:

bash: ifconfig: command not found

说明没装。


二、安装 ifconfig(Debian 官方方式)

sudo apt update
sudo apt install net-tools

安装完成后即可使用:

ifconfig

三、常用 ifconfig 命令示例

ifconfig              # 查看所有网卡
ifconfig eth0         # 查看指定网卡
ifconfig eth0 up      # 启用网卡
ifconfig eth0 down    # 禁用网卡
ifconfig eth0 192.168.1.100 netmask 255.255.255.0  # 临时配置 IP

⚠️ 这些配置重启后失效


四、Debian 推荐的新方式(替代 ifconfig)

Debian 官方更推荐使用 ip 命令:

ip addr      # 相当于 ifconfig
ip link      # 查看网卡状态
ip link set eth0 up

五、总结

  • Debian 新系统默认没有 ifconfig
  • 用 apt install net-tools 安装
  • 新系统建议学 ip 命令

如果你是 服务器 / 桌面版 / 容器环境,可以告诉我,我可以给你更具体的命令。

0 踩