Ifconfig command not found in CentOS 7 and RHEL 7

Dear friend, today we will see how to resolve the issue “ifconfig command not found” in CentOS 7and RHEL 7. When we have installed CentOS 7 and RHEL 7 with minimal server option, then ifconfig command will not be running, this because net-tools package is not installed by default with minimal server option.

If you wan this command in your CentOS 7 and RHEL 7 server then you will need to be install net-tools then you can run ifconfig command.

You can see below I have installed minimal CentOS 7 and ifconfig command is not working on this server.

[[email protected] ~]# ifconfig -a
-bash: ifconfig: command not found
[[email protected] ~]#

Install net-tools on CentOS 7 and RHEL 7 as like below:-

[[email protected] ~]# yum install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.crazyfrogs.org
* extras: centos.mirror.fr.planethoster.net
* updates: centos.crazyfrogs.org
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================
Installing:
net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k

Transaction Summary
====================================================================================================================================================
Install 1 Package

Total download size: 306 k
Installed size: 918 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for net-tools-2.0-0.24.20131004git.el7.x86_64.rpm is not installed
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1

Installed:
net-tools.x86_64 0:2.0-0.24.20131004git.el7

Complete!
[[email protected] ~]#

We can see above we have successfully install net-tools on CentOS. Now we can check ifconfig working or nor?

[[email protected] ~]# ifconfig -a
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.255.246.221 netmask 255.255.252.0 broadcast 10.255.247.255
inet6 fe80::250:56ff:fe99:5ce4 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:99:5c:e4 txqueuelen 1000 (Ethernet)
RX packets 20966517 bytes 1435439716 (1.3 GiB)
RX errors 0 dropped 11976 overruns 0 frame 0
TX packets 4573 bytes 340407 (332.4 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 0 (Local Loopback)
RX packets 198 bytes 16144 (15.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 198 bytes 16144 (15.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[[email protected] ~]#

We can see, now ifconfig command is working properly.

If we want to check our interface link status, speed and duplex then we can run ethtool <interface name> like below:-

[[email protected] ~]# ethtool ens160
Settings for ens160:
Supported ports: [ TP ]
Supported link modes: 1000baseT/Full
10000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: No
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 10000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
MDI-X: Unknown
Supports Wake-on: uag
Wake-on: d
Link detected: yes
[[email protected] ~]#

You can see here interface link is detected. Check your cables or switch ports status if link detected No. There will be some problem in switch ports and cables.

Speed 10000Mb/s and duplex Full, Speed and duplex can also be set with ethtool commands.

That’s all..!

You can also check this link to configure network after CentOS 7 minimal installation.

Network configuration after CentOS 7 minimal installation

 

1 thought on “Ifconfig command not found in CentOS 7 and RHEL 7

  1. There are some attention-grabbing points in time on this article however I don’t know if I see all of them heart to heart. There is some validity however I will take maintain opinion until I look into it further. Good article , thanks and we wish more! Added to FeedBurner as properly

Leave a Reply

Your email address will not be published. Required fields are marked *