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 7云服务器搭建SVN版本控制库

    基于腾讯CentOS 7云服务器搭建SVN版本控制库 最近在和小伙伴组队参加一个关于人工智能的比赛,无奈不知道怎么处理好每个人的代码托管问题,于是找到了晚上免费svn托管服务器的服…

    CentOS 2025年10月23日
  • CentOS 8禁用SELinux具体方法

    SELINUX全称为Security Enhanced Linux (安全强化 Linux),是对系统安全级别更细粒度的设置。 由于SELinux配置设置太严格,可能会与CM需要的…

    CentOS 2025年9月25日
  • CentOS下使用Tomcat搭建HTTPS协议服务器详解

    CentOS下使用Tomcat搭建HTTPS协议服务器详解 一 、安装java jdk配置环境变量 1、 卸载原有openjdk yum -y remove java-1.7.0-…

    CentOS 2025年10月5日
  • CentOS 7安装Splunk具体步骤

    Splunk 是机器数据的引擎。使用 Splunk 可收集、索引和利用所有应用程序、服务器和设备生成的快速移动型计算机数据 。 使用 Splunking 处理计算机数据,可让您在几…

    CentOS 2025年10月19日
  • Linux CentOS 7 非root用户安装源码版Docker

    linux 版本:centos 7 注意:非root用户必须要有sudo权限 一、安装前的准备 1.查看当前主机是否有docker组 若没有输出结果则新建 再次查看,发现已经有了d…

    CentOS 2025年7月8日
  • CentOS 8清空DNS缓存的方法

    DNS缓存不仅仅产生于操作系统,在浏览器和应用程序以及IPS网络运营商都会对DNS进行缓存,下面详细讲解一下清空DNS缓存的方法。 nscd清理缓存命令如下: [root@loca…

    CentOS 2025年6月8日
  • CentOS7 配置网卡端口镜像

    背景 最近一直在研究旁路监测,需要设置一个源端口镜像给两个目的端口(分别接两个监测设备),无奈ip-com交换机没配置明白,研究下使用软件实现暂时代替。 环境 发行版、内核、ipt…

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

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

    CentOS 2025年10月6日
  • CentOS 7下Nagios的安装及配置

    简介 Nagios 是一款自动化运维工具,可以协助运维人员监控服务器的运行状况,并且拥有报警功能。本文章将介绍其安装方法和详细的配置方法。 nagios 监控服务应用指南本地资源:…

    CentOS 2025年6月9日
  • CentOS Kickstart及引导镜像文件制作

    1. 什么是kickstart安装? kickstart是RedHat/CentOS/Fedora等系统实现无人值守自动化安装的一种安装方式,系统管理员可将安装过程中需要配置的所有…

    CentOS 2025年10月24日

发表回复

登录后才能评论