CentOS 7 Minimal 安装后找不到ifconfig命令

最近在VMWare上安装了CentOS的系统先说一下CentOS镜像的各种版本。

CentOS 版本

CentOS 7提供了以下几种ISO镜像文件:

DVD ISO 标准安装版,推荐使用,可以同来安装桌面版,也可以选择安装“最小化安装”

Everything ISO 对完整版安装盘的软件进行补充,集成所有软

Minimal ISO 精简版,自带的软件最少 ,只能最小化安装

NetInstall ISO 网络安装镜像

GnomeLive GNOME桌面版

KdeLive KDE桌面版、

livecd 光盘上运行的系统,类拟于Windows PE

CentOS 版本之间的区别

(1)CentOS-xxxx-LiveCD.ios 和CentOS-xxxx-bin-DVD.iso有什么区别?

前者只有700M,后者有3.8G,其差别不仅仅在大小上,其更本质的差别是,CentOS-xxxx-LiveCD.ios只能加载到内存里运行,不能安装。CentOS-xxx-bin-DVD1.iso才可以安装到硬盘上。

(2)CentOS-xxx-bin-DVD1.iso,CentOS-xxx-bin-DVD2.iso分别是干什么的?

前者是3.8G,后者是500M。其差别是DVD1是CentOS的安装文件,DVD2是CentOS的一些软件(就简单实用CentOS来说是不需要的)。

CentOS镜像

CentOS 7官网:

https://www.centos.org

http://vault.centos.org

阿里云镜像:

https://opsx.alibaba.com/mirror

问题场景

采用VMware安装好CentOS 7 Minimal之后,使用ifconfig命令发现

[root@bigdata1 ~]# ifconfig
-bash: /usr/sbin/ifconfig: No such file or directory

问题原因

用标准安装版镜像最小化安装的系统装有 net-tools 和 firewalld,默认开启了 firewalld,也就是说开启了默认防火墙策略,用精简版镜像最小化安装的系统,没有安装net-tools 和 firewalld,默认防火墙策略是清空状态,我们是用精简版最小化安装的,则是没有安装net-tools工具的,而ifconfig命令在net-tools工具包中

解决方案

方案一:

安装net-tools工具包

yum install net-tools

验证,再次使用ifconfig命令查看网络,则可以正常显示了

[root@bigdata1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.37.135  netmask 255.255.255.0  broadcast 192.168.37.255
        inet6 fe80::cdcd:837b:6c5a:8b87  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:2e:13:25  txqueuelen 1000  (Ethernet)
        RX packets 668  bytes 362199 (353.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 426  bytes 54794 (53.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 72  bytes 5728 (5.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 72  bytes 5728 (5.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

如果不知道ifconfig在哪个包里,怎么办呢,不用着急,我们去找到它,使用以下命令

yum provides ifconfig 或者 yum whatprovides ifconfig

结果

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.163.com
base/7/x86_64/filelists_db                                                                                               | 6.7 MB  00:00:02     
extras/7/x86_64/filelists_db                                                                                             | 709 kB  00:00:00     
updates/7/x86_64/filelists_db                                                                                            | 4.2 MB  00:00:02     
net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig

我们可以看到是net-tools提供的,只需要下载net-tools就可以愉快的使用ifconfig了。

方案二

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

使用 ip addr 命令

[root@bigdata1 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:2e:13:25 brd ff:ff:ff:ff:ff:ff
    inet 192.168.37.135/24 brd 192.168.37.255 scope global dynamic ens33
       valid_lft 1600sec preferred_lft 1600sec
    inet6 fe80::cdcd:837b:6c5a:8b87/64 scope link 
       valid_lft forever preferred_lft forever

使用 ip link 命令

[root@bigdata1 ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:2e:13:25 brd ff:ff:ff:ff:ff:ff

使用 ip -s link 命令

[root@bigdata1 ~]# ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast   
    5728       72       0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    5728       72       0       0       0       0       
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:2e:13:25 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    371049     775      0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    63794      498      0       0       0       0   
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值