CentOS7 minimal Installation:”Ifconfig” : Command not found [Solved]

Updated on September 2, 2017

Question : Recently installed minimal version of CentOS 7 as a guest VM on my xen hypervisor. After successful completion of the installation, executed ifconfig command to know the network devices and the addresses allocated. But to my surprise got the below error:

[root@localhost]# ifconfig
-bash: ifconfig: command not found

Please help me.

Solution:

From our previous experience of CentOS/RedHat/Fedora We all knew that “ifconfig“command is used to display and configure network interfaces. But this is obsolete, and is not found in the minimal version of CentOS 7.

ifconfig command not found on centos7 minimal installation

How to find IP address and network interface details on CentOS 7

Use the command “ip addr” or “ip link” which is very similar to ifconfig. Execute the below command to view the details of the network interface cards.

[root@localhost ~]# ip addr

Sample Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 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
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:3e:69:7c:a9 brd ff:ff:ff:ff:ff:ff
inet 192.168.8.222/24 brd 192.168.8.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe69:7ca9/64 scope link
valid_lft forever preferred_lft forever

To view the statistics of your network devices, enter the below command:

[root@localhost ~]# ip link

Sample Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:16:3e:69:7c:a9 brd ff:ff:ff:ff:ff:ff

How to Install package to use ifconfig command in minimal CentOS7 version

With the help of yum’s switches like provides you can find which package contains ifconfig command as shown below:

[root@localhost ~]# yum provides */ifconfig

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo        : base
Matched from:
Filename    : /sbin/ifconfig

As you see from the above output, the net-tools package provides the ifconfig command. So, install net-tools package to use the ifconfig command using yum.

[root@localhost ~]# yum install net-tools

Now, you’ll be able to use the command ifconfig as usual like in older CentOS versions.

[root@localhost ~]# ifconfig -a

Sample Output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.222  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::216:3eff:fe69:7ca9  prefixlen 64  scopeid 0x20        ether 00:16:3e:69:7c:a9  txqueuelen 1000  (Ethernet)
        RX packets 18877  bytes 17894467 (17.0 MiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 8146  bytes 617357 (602.8 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
        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

Happy Networking!

Was this article helpful?

Related Articles

Leave a Comment