Loading... > 此命令微软系统ipconfig非常类似。 #### 1. 安装的需求背景 我们知道ifconfig 命令可以用于查看、配置、启用或禁用指定网络接口,如配置网卡的IP地址、掩码、广播地址、网关等,功能不可谓不丰富。 但是,[CentOS](https://www.linuxidc.com/topicnews.aspx?tid=14 "CentOS") 7 默认已不再安装此命令,其中很多功能用 ip addr 指令 替代了。 考虑到 既有的很多管理工具或脚本都调用了此功能命令(ifconfig),如果将这些工具直接迁移过来会报错,如果对这个指令用其它指令进行替换,及对这些工具升级,则增加了工作量,还增加了出错的风险。 所以,在CentOS 7 系统中 安装 ifconfig 命令很有必要。 #### 2. 测试安装的具体步骤 CentOS 7 系统默认 没有安装 ifconfig 命令。 如果直接运行 **ifconfig** 命令,则提示错误 :-bash: ifconfig: command not found  此时,查看 /sbin 目录下,其实是没有 ifconfig 文件的。  那么 如何安装ifconfig 呢?我们首先想到的是 运行 **yum install ifconfig** 。执行效果如何呢?  结果是: No package ifconfig available. Error: Nothing to do 啊?! 没有 ifconfig 安装包,是不是 我们就要放弃了呢? 其实,我们 还可以通过yum 命令的search选项 来对 包 (package)进行再次搜索。 *search:可以搜寻某个软件名称或者是描述(description)的重要关键字。此指令可以查找显示出相关的软件有哪些。* 所以,在放弃前,我们运行以下命令: ***yum search ifconfig***  以上运行结果,我们只要分析最好一行就可以。**Matched: **ifconfig 这个 分割行 是用来显示 匹配结果的。 最后一行 中 冒号(:)前面的数据, (**net-tools.x86\_64 **) 是匹配的软件包;冒号(:)后面的数据,(**Basic networking tools **) 是对前面包的描述。 结合上面的信息,即 通过运行 ***yum search ifconfig ***提示我们: 安装ifconfig 包 只需要安装 net-tools.x86\_64 即可。 所以,我们执行** yum install net-tools.x86\_64 **  安装后,ifconfig 命令可以正常执行。因含有ip敏感信息,截图省略。 并且,查看/sbin 目录,此时 ifconfig 文件也出现了。 **3. 总结** **CentOS 7 安装 ifconfig 管理命令,通过yum 安装,** **运行 yum install net-tools.x86\_64 即可安装。** **侵删转自:[Linux公社](https://www.linuxidc.com/Linux/2018-10/154766.htm)** 最后修改:2024 年 10 月 07 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏