ifconfig command not found on CentOS 7 Minimal installation

Updated on November 9, 2017

I have been using ifconfig command to configure network interfaces, enable or disable interface, display IP address information, change MAC address of the network interface on Linux. But where is that command now on CentOS 7? I get ifconfig command not found on CentOS 7 minimal installation? Well, you know what, ifconfig command is now obsolete on minimal versions of RHEL 7, CentOS 7 and other Linux versions starting from 7. If you ever install minimal version of CentOS 7, then here’s how you can find IP address & other details of network interfaces.

In CentOS 7 minimal installation, you can use alternate command – ‘ip addr‘ to view the network interface details.

How to view IP address details using ip command?

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
 inet6 ::1/128 scope host
 valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
 linet 10.180.8.129/26 brd 10.180.8.1 scope global eth0
valid_lft forever preferred_lft forever

You can also use ‘ip link‘ to view the statistics of the network interface.

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
 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 qlen 1000
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast qlen 1000

How to assign an IP address to an interface?

# ip addr add 10.180.8.220 dev eth0
Note:

The IP address assigned using the above command is temporary and it will be lost after system restart. To make permanent changes, you need to edit /etc/network/interfaces and assign an IP address.

auto eth0
iface eth0 inet static
address 10.180.8.220
netmask 255.255.255.0
gateway 10.180.8.1

How to remove an IP address

# ip addr del 10.180.8.220/24 dev eth0

How to enable/disable network interface

Remember, ifup and ifdown commands for enabling and disabling network interface? The same can be achieved using the below commands.

# ip link set eth0 up

To disable network interface:

# ip link set eth0 down

How to get back ifconfig on CentOS 7 minimal installation?

Simply install a package that provides ifconfig command. To check which package provides ifconfig command, run the below command.

# yum provides ifconfig

Sample output:

net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo : @base
Matched from:
Filename : /usr/sbin/ifconfig

The above output confirms that net-tools is the package that provides ifconfig command.

Install net-tools package using yum

# yum install net-tools

That’s it! You can now use ifconfig command on CentOS 7 minimal installation.

Was this article helpful?

Related Articles

Leave a Comment