CentOS7最小化安装以后没有ifconfig这个命令的解决

前几天我最小化安装了一下CentOS7,进入系统发现没有ifconfig这个网络配置工作,又想急着上网,那怎么办呀。下面是我给出的解决方法:

1、用光驱配置yum源,安装net-tools这个软件包(或者用rpm这个命令)。
    1.1、把CentOS默认的yum源除(CentOS-Media.repo)都移动到一个指定的目录,我是在yum源配置文件存放目中建了一个叫repo的子目录,以下是具体操作:
[root@bogon ~]# cd /etc/yum.repos.d/   
    [root@bogon yum.repos.d]# ls
    CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentO    S-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
    [root@bogon yum.repos.d]# mkdir repo
    [root@bogon yum.repos.d]# ls
    CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
    CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  repo
    [root@bogon yum.repos.d]# mv *.repo repo/
    [root@bogon yum.repos.d]# ls
    repo
    [root@bogon yum.repos.d]# cd repo/
    [root@bogon repo]# ls
    CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentO    S-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
    [root@bogon repo]# mv CentOS-Media.repo ../
    [root@bogon repo]# ls
    CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentO    S-Sources.repo  CentOS-Vault.repo
    [root@bogon repo]# cd ..
    [root@bogon yum.repos.d]# ls
    CentOS-Media.repo  repo


      1.2、挂载光驱配置yum源的具体操作步骤:

[root@bogon yum.repos.d]# mount /dev/sr0 /media/   
    mount: /dev/sr0 is write-protected, mounting read-only
    #以上是挂载光驱的命令和操作步骤
     
    [root@bogon yum.repos.d]# cat CentOS-Media.repo 
    [c7-media]
    name=CentOS-$releasever - Media
    baseurl=file:///media/
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
    #以上光驱yum源的配置文档
     
    [root@bogon yum.repos.d]# yum list | wc -l
    3776
    #用yum list查看测试yum源是否存在问题

1.3、用yum安装net-tools工具包
[root@bogon yum.repos.d]# yum install net-tools -y   
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    Resolving Dependencies
    --> Running transaction check
    ---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
    --> Finished Dependency Resolution
    …………
    Running transaction
      Installing : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                                  1/1
      Verifying  : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                                  1/1
    Installed:
      net-tools.x86_64 0:2.0-0.17.20131004git.el7                                                                                                 
    Complete!

1.4、测试ifconfig命令 
[root@bogon yum.repos.d]# ifconfig
    eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.1.131  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::20c:29ff:fe2d:c130  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:2d:c1:30  txqueuelen 1000  (Ethernet)
            RX packets 53366  bytes 3890372 (3.7 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 47832  bytes 22949340 (21.8 MiB)
            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 0  (Local Loopback)
            RX packets 58  bytes 5088 (4.9 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 58  bytes 5088 (4.9 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15420.html