微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在CentOS 7 mini版中使用ifconfig

众所周知,“ifconfig”命令用于配置GNU/Linux系统的网络接口。它显示网络接口卡的详细信息,包括IP地址,MAC地址,以及网络接口卡状态之类。但是,该命令已经过时了,而且在最小化版本的RHEL 7以及它的克隆版本CentOS 7,Oracle Linux 7和Scientific Linux 7中也找不到该命令。那么问题来了,怎么在Centos7中查看ip信息呢?怎么操作才能找回以前的习惯呢?

CentOS 7最小化安装后找不到‘ifcon<a href=fig’命令――修复小提示" src="http://www.linuxprobe.com/wp-content/uploads/2017/03/171556br6r7f9tq7cc7ddh.jpg">

7版系统查看网络信息的命令

CentOS 7最小化系统,使用“ip addr”和“ip link”命令来查找网卡详情。要知道统计数据,可以使用“ip -s link”。

要查看网卡细节:ip addr

[root@linuxprobe~]#ipaddr
1:lo:<LOOPBACK,UP,LOWER_UP>mtu16436qdiscnoqueuestateUNKNowN
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
inet127.0.0.1/8scopehostlo
inet6::1/128scopehost
valid_lftforeverpreferred_lftforever
2:venet0:<broADCAST,POINTOPOINT,NOARP,LOWER_UP>mtu1500qdiscnoqueuestateUNKNowN
link/void
inet127.0.0.1/32scopehostvenet0
inet192.168.1.101/32brd192.168.1.101scopeglobalvenet0:0

要查看网络接口统计数据:ip link

[root@linuxprobe~]#iplink
1:lo:<LOOPBACK,LOWER_UP>mtu16436qdiscnoqueuestateUNKNowNmodeDEFAULT
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
2:venet0:<broADCAST,LOWER_UP>mtu1500qdiscnoqueuestateUNKNowNmodeDEFAULT
link/void

或者使用:ip -s link

[root@linuxprobe~]#ip-slink
1:lo:<LOOPBACK,LOWER_UP>mtu16436qdiscnoqueuestateUNKNowNmodeDEFAULT
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
RX:bytespacketserrorsdroppedoverrunmcast
000000
TX:bytespacketserrorsdroppedcarriercollsns
000000
2:venet0:<broADCAST,LOWER_UP>mtu1500qdiscnoqueuestateUNKNowNmodeDEFAULT
link/void
RX:bytespacketserrorsdroppedoverrunmcast
851566766670000
TX:bytespacketserrorsdroppedcarriercollsns
30040342490000

在CentOS 7最小化服务器版本中启用“ifconfig”命令

如果你不知道在哪里可以找到ifconfig命令,请按照以下简单的步骤来找到它。

首先,让我们找出哪个包提供了ifconfig命令:

[root@linuxprobe~]#yumprovidesifconfig
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*base:centos.aol.in
*extras:centos.aol.in
*updates:centos.aol.in
net-tools-2.0-0.17.20131004git.el7.x86_64:Basicnetworkingtools
Repo:@base
Matchedfrom:
Filename:/usr/sbin/ifconfig

或者你也可以使用以下命令

yumwhatprovidesifconfig

这里,“provides”或者“whatprovides”开关用于找出某个包提供了某些功能文件

net-tools包提供了ifconfig命令。因此,安装net-tools包也可以使用ifconfig命令。

安装net-tools包

yuminstallnet-tools

现在,你就可以像以往一样使用ifconfig命令了。

[root@linuxprobe~]#ifconfig-a
lo:flags=73<UP,LOOPBACK,RUNNING>mtu16436
inet127.0.0.1netmask255.0.0.0
inet6::1prefixlen128scopeid0x10<host>
looptxqueuelen0(LocalLoopback)
RXpackets0bytes0(0.0B)
RXerrors0dropped0overruns0frame0
TXpackets0bytes0(0.0B)
TXerrors0dropped0overruns0carrier0collisions0

venet0:flags=211<UP,broADCAST,RUNNING,NOARP>mtu1500
inet127.0.0.1netmask255.255.255.255broadcast0.0.0.0destination127.0.0.1
unspec00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00txqueuelen0(UNSPEC)
RXpackets7073bytes8549159(8.1MiB)
RXerrors0dropped0overruns0frame0
TXpackets4611bytes359201(350.7KiB)
TXerrors0dropped0overruns0carrier0collisions0

venet0:0:flags=211<UP,NOARP>mtu1500
inet192.168.1.101netmask255.255.255.255broadcast192.168.1.101destination192.168.1.101
unspec00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00txqueuelen0(UNSPEC)

尽情享受吧!

原文地址:http://www.linuxprobe.com/centos-7-use-ifconfig.html

原文地址:https://www.jb51.cc/centos/377943.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。