CentOS 7最小化安装后找不到‘ifconfig’命令——修复小提示
  ViFPlSCOcstX 2023年11月02日 51 0


就像我们所知道的,“ifconfig”命令用于配置GNU/Linux系统的网络接口。它显示网络接口卡的详细信息,包括IP地址,MAC地址,以及网络接口卡状态之类。但是,该命令已经过时了,而且在最小化版本的RHEL 7以及它的克隆版本CentOS 7,Oracle Linux 7和Scientific Linux 7中也找不到该命令。

在CentOS最小化服务器版本中如何查找网卡IP和其它详细信息?

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

要查看网卡细节,输入以下命令:



  1. ip addr

输出样例:


1. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
2. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3. inet 127.0.0.1/8 scope host lo
4. inet6 ::1/128 scope host
5. valid_lft forever preferred_lft forever
6. 2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
7. link/void
8. inet 127.0.0.1/32 scope host venet0
9. inet 192.168.1.101/32 brd 192.168.1.101 scope global venet0:0

要查看网络接口统计数据,输入命令:



  1. ip link

输出样例:


1. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT 
2. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3. 2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT
4. link/void

或者



  1. ip -s link

输出样例:

1. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT 
2. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3. RX: bytes packets errors dropped overrun mcast
4. 0 0 0 0 0 0
5. TX: bytes packets errors dropped carrier collsns
6. 0 0 0 0 0 0
7. 2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT
8. link/void
9. RX: bytes packets errors dropped overrun mcast
10. 8515667 6667 0 0 0 0
11. TX: bytes packets errors dropped carrier collsns
12. 300403 4249 0 0 0 0

在CentOS 7最小化服务器版本中如何启用并使用“ifconfig”命令?

如果你不知道在哪里可以找到ifconfig命令,请按照以下简单的步骤来找到它。首先,让我们找出哪个包提供了ifconfig命令。要完成这项任务,输入以下命令:



  1. yum provides ifconfig

输出样例:


1. Loaded plugins: fastestmirror
2. Loading mirror speeds from cached hostfile
3. * base: centos.aol.in
4. * extras: centos.aol.in
5. * updates: centos.aol.in
6. net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
7. Repo : @base
8. Matched from:
9. Filename : /usr/sbin/ifconfig

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



  1. yum whatprovides ifconfig

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

就像你在上面的输出中所看到的,net-tools包提供了ifconfig命令。因此,让我们安装net-tools包来使用ifconfig命令。



  1. yum install net-tools

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



  1. ifconfig -a

输出样例:

1. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
2. inet 127.0.0.1 netmask 255.0.0.0
3. inet6 ::1 prefixlen 128 scopeid 0x10<host>
4. loop txqueuelen 0 (Local Loopback)
5. RX packets 0 bytes 0 (0.0 B)
6. RX errors 0 dropped 0 overruns 0 frame 0
7. TX packets 0 bytes 0 (0.0 B)
8. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
9.
10. venet0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP> mtu 1500
11. inet 127.0.0.1 netmask 255.255.255.255 broadcast 0.0.0.0 destination 127.0.0.1
12. unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 0 (UNSPEC)
13. RX packets 7073 bytes 8549159 (8.1 MiB)
14. RX errors 0 dropped 0 overruns 0 frame 0
15. TX packets 4611 bytes 359201 (350.7 KiB)
16. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
17.
18. venet0:0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP> mtu 1500
19. inet 192.168.1.101 netmask 255.255.255.255 broadcast 192.168.1.101 destination 192.168.1.101
20. unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 0 (UNSPEC)

尽情享受吧!

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  4koL3J55wyKx   2023年11月13日   35   0   0 icogitCentOS
  9E2BTpjt8nym   2023年12月06日   34   0   0 WindowsgitCentOS
ViFPlSCOcstX