CentOS 7 mini使用ifconfig实例

许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改。Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config)。通常需要以root身份登录或使用sudo以便在Linux机器上使用ifconfig工具。

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

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

要查看网卡细节:ip addr

[root@linuxprobe ~]#ip addr
1: lo: 
  
    mtu 16436 qdisc noqueue state UNKNOWN    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    inet 127.0.0.1/8 scope host lo    inet6 ::1/128 scope host       valid_lft forever preferred_lft forever 2: venet0: 
   
     mtu 1500 qdisc noqueue state UNKNOWN    link/void    inet 127.0.0.1/32 scope host venet0    inet 192.168.1.101/32 brd 192.168.1.101 scope global venet0:0 
   
  

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

[root@linuxprobe ~]#ip link
1: lo: 
  
    mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: venet0: 
   
     mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT    link/void 
   
  

或者使用:ip -s link

[root@linuxprobe ~]#ip -s link
1: lo: 
  
    mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    RX: bytes  packets  errors  dropped overrun mcast      0          0        0       0       0       0          TX: bytes  packets  errors  dropped carrier collsns    0          0        0       0       0       0       2: venet0: 
   
     mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT    link/void    RX: bytes  packets  errors  dropped overrun mcast      8515667    6667     0       0       0       0          TX: bytes  packets  errors  dropped carrier collsns    300403     4249     0       0       0       0 
   
  

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

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

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

[root@linuxprobe ~]# yum provides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.aol.in
* extras: centos.aol.in
* updates: centos.aol.in
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig

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

yum whatprovides ifconfig

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

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

安装net-tools包

yum install net-tools

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

[root@linuxprobe ~]# ifconfig -a
lo: flags=73
  
     mtu 16436        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10
   
            loop  txqueuelen 0  (Local Loopback)        RX packets 0  bytes 0 (0.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 0  bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 venet0: flags=211
    
       mtu 1500        inet 127.0.0.1  netmask 255.255.255.255  broadcast 0.0.0.0  destination 127.0.0.1        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC)        RX packets 7073  bytes 8549159 (8.1 MiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 4611  bytes 359201 (350.7 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 venet0:0: flags=211
     
        mtu 1500        inet 192.168.1.101  netmask 255.255.255.255  broadcast 192.168.1.101  destination 192.168.1.101        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC) 
     
    
   
  

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/12932.html

(0)
晴川运维晴川运维
上一篇 2025年9月20日
下一篇 2025年9月20日

相关推荐

  • CentOS 6.6最小安装实战图解

    1. 背景CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,它是来自于Red Hat …

    CentOS 2025年10月11日
  • Centos设置GRUB2引导程序背景

    在默认情况下Centos/RedHat系列的Linux操作系统都没有配置grub背景,当做服务器使用的话可能会无所谓,如果自己使用的话,总是想着让它看起来美丽一些,在本篇文章中在g…

    CentOS 2025年10月23日
  • Centos如何更换epel源

    在dell r410上面装的是centos6,64的操作系统,用的163的源,我一直都是用163的源,比较快。但是我发现这个源里面,根本没有libmcrypt libmcrypt-…

    CentOS 2025年6月8日
  • CentOS 6.5安装及简单配置Nginx

    centos 6.5安装及简单配置Nginx 一、准备事项 (1) 因为nginx需要访问80端口所以请先关闭或者开放防火墙端口,和selinux。 关闭防火墙: [root@lo…

    CentOS 2025年6月8日
  • CentOS 7下安装配置 VNC Server

    需要使用linux的远程桌面服务,xmanager之前用过,感觉一般,这次尝试下VNC。 我的操作系统是centos7 一服务端 安装VNCserver #yum -y insta…

    CentOS 2025年6月8日
  • 基于RHEL8/CentOS8的网络IP配置详解

    在rhel8(含centos8)上,没有传统的network.service,在/etc/sysconfig/network-scripts/里也看不到任何脚本文件,那么该如何进行…

    CentOS 2025年7月11日
  • CentOS 7部署Memcached缓存服务器

    1.简介 1.1Memcached Memcached是一款开源的、高性能的纯内存缓存服务软件。 MySQL数据库属于磁盘上的数据库,数据的读写较慢;而Memcached数据库属于…

    CentOS 2025年10月27日
  • CentOS 7安装部署Rsync数据同步服务器

    Rsync(remote sync)是UNIX及类UNIX平台下一款神奇的数据镜像备份软件,它不像FTP或其他文件传输服务那样需要进行全备份,Rsync可以根据数据的变化进行差异备…

    CentOS 2025年10月6日
  • CentOS 7下安装配置PHP7跟LAMP及MongoDB和Redis

    CentOS 7下安装配置PHP7跟LAMP及MongoDB和Redis 我是想能yum就yum,所有软件的版本一直会升级,注意自己当时的版本是不是已经更新了。 首先装CentOS…

    CentOS 2025年10月10日
  • VMware虚拟机克隆CentOS及网络设置

    VMware虚拟机的克隆功能能大大简化我们需要多台虚拟机的工作,只需要简单的点击克隆就可以生成一个和原虚拟机一样虚拟机。以前不懂这个,经常是自己手动复制一份虚拟机的文件,占用空间的…

    CentOS 2025年10月18日

发表回复

登录后才能评论