«

CentOS7最小化安装找回ifconfig命令net-tools

时间:2026-11-14 07:16     作者:emer     分类: Linux


前言

CentOS7 最小化安装后执行 ifconfig 报 command not found,因为新版系统不再默认安装 net-tools 套件,改用 ip 命令。但很多老习惯和老脚本仍用 ifconfig。本文讲解安装 net-tools 找回 ifconfig,以及直接用 ip 替代的写法,二选一即可。

操作步骤

1. 报错确认

ifconfig
# -bash: ifconfig: command not found

2. 安装 net-tools

yum install -y net-tools

3. 重新查看网卡

ifconfig
ifconfig eth0

4. 替代:用 ip 命令查看地址

ip addr
ip -br addr

5. 查看网卡状态替代

ip link show

6. 安装其他常用小工具

yum install -y wget vim net-tools lsof

常见坑

  1. 只装 ifconfig 找不到,其实 net-tools 是一整套工具包,包含 netstat、route 等。
  2. 换最小化系统后 netstat 也消失,一并装 net-tools。
  3. 新服务器优先学 ip 命令,net-tools 已进入维护状态。
  4. yum 源不通导致装不上,先换源再装。
  5. 容器内精简系统可能没有 yum,需镜像层面解决。
  6. 脚本里硬编码 ifconfig,建议逐步替换为 ip。
  7. 多网卡时 ifconfig 显示全部,ip addr 信息更全。

总结

最小化 CentOS7 缺 ifconfig 是因为没装 net-tools,yum install -y net-tools 即可找回整套旧工具;更推荐直接使用 ip addr、ip link 现代命令。新装机建议把 wget、vim、lsof、net-tools 一次性补齐,减少后续反复安装。

遇到问题加QQ23979811 协助处理

标签: CentOS7 net-tools ifconfig 最小化安装