ifconfig command not found on CentOS 7 Minimal installation

ifconfig command to configure network interfaces, enable or disable the interface, display IP address information, change MAC address of the network interface on Linux. 

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 120.25.56.145 dev eth0

Note:

The IP address assigned using the above command is temporary and it will be lost after a 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 120.25.56.145
netmask 255.255.255.0
gateway 10.180.8.1


How to remove an IP address

# ip addr del 120.25.56.145/24 dev eth0


How to enable/disable a 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 !!

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)