Linux与运维

CentOS 7 ifconfig: command not found 解决方案及现代 ip addr 替代

新装的 CentOS 7 最小化系统中运行 ifconfig 查看 IP 地址常提示 “-bash: ifconfig: command not found”。本文介绍 net-tools 工具包安装及现代 Linux 标准替代命令。


一、 解决方案:安装 net-tools 软件包

sudo yum install -y net-tools

安装后即可正常使用 ifconfignetstatarp 等传统网络管理命令。


二、 现代标准替代:使用 ip addr 命令(无需安装任何包)

在现代 Linux 发行版中,net-tools 已逐渐被更强大的 iproute2 工具链取代:

# 极简查看所有网卡 IP 地址
ip addr
# 简写形式:
ip a