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

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


1、用光驱配置yum源,安装net-tools这个软件包(或者用rpm这个命令)。

    1.1、把CentOS默认的yum源除(CentOS-Media.repo)都移动到一个指定的目录,我是在yum源配置文件存放目中建了一个叫repo的子目录,以下是具体操作:

    [[email protected] ~]# cd /etc/yum.repos.d/    
    [[email protected] 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
    [[email protected] yum.repos.d]# mkdir repo
    [[email protected] 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
    [[email protected] yum.repos.d]# mv *.repo repo/
    [[email protected] yum.repos.d]# ls
    repo
    [[email protected] yum.repos.d]# cd repo/
    [[email protected] repo]# ls
    CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentO    S-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
    [[email protected] repo]# mv CentOS-Media.repo ../
    [[email protected] repo]# ls
    CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentO    S-Sources.repo  CentOS-Vault.repo
    [[email protected] repo]# cd ..
    [[email protected] yum.repos.d]# ls
    CentOS-Media.repo  repo


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

    [[email protected] yum.repos.d]# mount /dev/sr0 /media/    
    mount: /dev/sr0 is write-protected, mounting read-only
    #以上是挂载光驱的命令和操作步骤
    
    [[email protected] 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源的配置文档
    
    [[email protected] yum.repos.d]# yum list | wc -l
    3776
    #用yum list查看测试yum源是否存在问题

1.3、用yum安装net-tools工具包

    [[email protected] 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命令

[[email protected] 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

2、在linux中除了ifconfig这个命令可以配置IP地址之外还有一个命令就是ip了(本人用的是这种方法)。

    [[email protected] yum.repos.d]# ip addr l eno16777736
    2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:2d:c1:30 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.131/24 brd 192.168.1.255 scope global eno16777736
           valid_lft forever preferred_lft forever
        inet6 fe80::20c:29ff:fe2d:c130/64 scope link 
           valid_lft forever preferred_lft forever
    [[email protected] yum.repos.d]# ip addr add 192.168.1.131/24 dev eno16777736

ip这个命令和博大精深不是一两句话就可以说明的,在以后网络学习的时候我会给大家进行详细认真的讲解,再给大家提一下关于网卡,在CentOS7以后默认的网卡类型标识符为eno16777736,在以前的系统为ethN。

希望这篇文章对大家有帮助,有不懂的地方,希望大家多多指教。QQ:87736754

时间: 2024-08-03 11:03:11

CentOS7最小化安装以后没有ifconfig这个命令的解决方案的相关文章

centos7 最小化安装 无 ifconfig,netstat 的安装

centos7 最小化安装之后,默认是没有 ifconfig,netstat命令的: 我们可以直接使用 yum -y install net-tools 即可: 1. 先来看下 net-tools的信息 yum info net-tools 可安装的软件包 名称 :net-tools 架构 :x86_64 版本 :2.0 发布 :0.17.20131004git.el7 大小 :304 k 源 :base/7/x86_64 简介 : Basic networking tools 网址 :http

centos7最小化安装

centos7最小化安装的时候有些命令是不包含的,所以一开始需要做一些配置才能正常使用. 1. 查看网络命令ifconfig 首先修改网卡配置文件 #vi /etc/sysconfig/network-scripts/ens33 修改配置文件为开机启动,不然后续没法安装 ONBOOT=yes 重启网卡 #service network restart 2. 安装net-tools,因为它包含了ifconfig这个命令 #yum -y install net-tools

CentOS7最小化安装下源码编译搭建LAMP环境

CentOS7最小化安装 CentOS7官网下载:http://www.centos.org 1.为了方便与主机交换文件建立共享文件夹:点击对话框顶部"选项",选择"共享文件夹",右侧点击"总是启用"点击"添加"按提示添加自己想要添加的目录,然后点击"确认",完成虚拟机设置. 2.按"Enter"建,选择"install CentOS 7".选择"中文 Ch

Centos7最小化安装下安装,编译lamp环境

centos7默认的php是5.5,mysql已经变为mariadb,如果想要自定义的配置,需要自己手动来编译配置.以下步骤在公司服务器上已经正常操作过. 1.安装centos7选择基本安装,配置完网络后首先要先关闭firewall: 停止firewall # systemctl stop firewalld.service 禁止firewall开机启动 # systemctl disable firewalld.service 2.安装iptables防火墙 yum方式安装iptables #

centos7 最小化安装没有ifconfig及修改网卡名enoxxx为ethX

问题: 1.最小化安装centos7后发现无ifconfig命令 想通过ifconfig查看ip地址发现ifconfig命令不存在,可通过命令 #ip addr       //查看ip 或者 解决: #yum -y install net-tools 问题: 2.centos7默认将网卡1命名为eno16777736,如何修改回熟悉的eth0 解决: [[email protected] ~]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIB

CentOS7最小化安装解决不能使用ifconfig命令

在最小化安装的CentOS7中,ifconfig是不能使用的,查看网卡信息的命令是ip addr 其中“ens33”为网卡名称,修改IP地址等信息 vi /etc/sysconfig/network-scripts/ifcfg-ens33  修改好后保存退出,并重启网络,测试网络是否连接正常: 安装ifconfig命令 yum provides ifconfig 或 yum whatprovides ifconfig ifconfig命令依赖于net-tools的,安装 yum install

centos7 最小化安装没有ifconfig 命令

centos6和7 还是有些变化的,最小化安装后我们经常用的查看ip信息命令:ifconfig  就没有此命令! 查看ip: ip addr 使用ifconfig命令: 这里"provides"或者"whatprovides"开关用于找出某个包提供了某些功能或文件  yum whatprovides ifconfig yum provides ifconfig 安装net-tools 包: yum -y install net-tools 我这里安装过了,所以yum

CentOS7最小化安装配置IP

CentOS7配置IP: 因为是我们安装的CentOS操作系统是最小化安装的,所以没有图形界面和一些软件或插件的.IP也是没有配置的我们需要手动配置IP,然后使用远程终端通过这个IP去连接操作系统,在终端上操作要比在虚拟机里操作方便. 因为在虚拟机里不能够用鼠标复制粘贴或者用滚轴上下滑动界面,例如要使用一个网址下载东西的话,总共不可能把这个网址一点点的从头敲到尾吧,即使有人愿意这么做,效率也太低了.如果是使用远程终端的话可以在我们的Windows操作系统上安装这个远程终端软件,然后可以将Wind

centos7 最小化安装后的配置优化

echo #CENTOS7echo #1.最小化安装之后需要做的事echo 2.配置echo 2.1 安装网络yum install net-tools -y echo 2.2 更新机器名echo hdp1.student >/etc/hostname echo 2.3.配置防火墙  echo #关闭防火墙systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动