A Step-By-Step Guide to Install and Use ifconfig on CentOS 


The ifconfig command serves as the most prevalent and effective way to configure a network interface in Linux. Usually, you can find the ifconfig command preinstalled on numerous Linux distributions. However, there exist certain Linux distributions such as CentOS 7, which do not incorporate the ifconfig command by default anymore. Therefore, we have come up with a tutorial that provides a step-by-step guide to install ifconfig and employ it on CentOS. But, before anything else let us give you the insights into prerequisites of installing and running ifconfig centos 7. 


Here are the three major prerequisites that you need to meet –

  • You must have CentOS 7 installed on your system
  • You must acquire command-line or terminal window access
  • You must have access to the root or user with sudo privileges

How to Install the ifconfig Command?

You can find the net-tools package in the YUM repository, which further provides ifconfig command as its part. Follow the steps to install ifconfig –

  1. First of all, you need to open the terminal window and update the repositories using the following command – sudo yum update
  2. Next, you have to download and then, install net-tools employing yum. For this, run the command – 

sudo yum install net-tools –y

Note: the Linux distributions that lack ifconfig command prompt users to make use of the IP command instead.

Read More: How to Use apt-get reinstall on Debian and Ubuntu?

Employing the ifconfig Command

The ifconfig command is quite flexible and versatile. It can enable you to attain the following things – 

  • It can display the details about the configuration of the system’s network.
  • It can help to enable or disable a network interface. 
  • It can help in allocating IP addresses, netmasks, and broadcasts to network interfaces.
  • It has the capability to change the MAC address. 
  • It can modify the maximum transmission unit (MTU).
  • It can help you to build the network interface aliases.
  • It has the ability to enable or disable promiscuous mode.

Peek into the subsequent sections to know how to perform every function discussed above –

Displaying Network Configuration Information

If you do not add any arguments while entering ifconfig command, your screen displays all the details about the current network interfaces. As an output, you get all the key information for the active network interfaces, incorporating:

  • Hardware MAC address
  • IP addresses (inet)
  • Netmasks
  • Broadcast addresses
  • And the information about whether the interface is up or down

In order to acquire all the interfaces that include inactive ones as well, you must append –a argument after the ifconfig command like – 

ifconfig  –a

Moreover, if you need to obtain the detail about a particular interface, you should add the interface name to the following command as – ifconfig [interface-name]

Enabling or Disabling a Network Interface

In order to enable a network interface, you need to use the following syntax –

sudo ifconfig [interface-name] up

The command gets executed successfully.

This command does not render any output. But, when you run ifconfig, it displays that the list of active connections now incorporates enp0s8.

Moreover, if you are required to disable an interface, you can use the following syntax –

sudo ifconfig [interface-name] down

Eg :- ifcongfig eth0 down 

Allocating the IP Address, Netmask, and Broadcast

The command for assigning an IP address with ifconfig – 

sudo ifconfig [interface-name] [IP-address]

Further, to allocate a new netmask value, enter the command – 

sudo ifconfig [interface-name] netmask [netmask-value]

You can allocate a new broadcast by running the command – 

sudo ifconfig [interface-name] broadcast [broadcast-value]

Moreover, you can verify that the new values are assigned aptly by running the ifconfig command. 

Also, you have the possibility to assign all the new values in one line by alternatively running the command as – 

sudo ifconfig [interface-name] [IP-address] netmask [netmask-value] broadcast [broadcast-value]

Modifying the Network Interface MAC Address

The MAC address refers to the unique identifier of a device on a network. For modifying the MAC address of a network interface, you need to enter the command – 

sudo ifconfig [interface-name] hw ether [MAC-address]

You can figure out the change in the MAC configuration from the output of the ifconfig command execution. 

Modifying the Network Interface MTU

The maximum transmission unit (MTU) refers to the maximum size of a packet or a frame that can be sent over the network. The default maximum transmission unit MTU is 1500. You must note that when you increase the MTU of the network, the data transfer rate also increases. You can modify the value of MTU with the ifconfig by utilizing the following syntax – 

sudo ifconfig [interface-name] mtu [MTU-value]

Again, you can confirm the modification by checking the output of ifconfig command. 

Building Network Interface Aliases

You can associate more than one IP address with a single network interface by employing IP aliases. The ifconfig command enables aliases while following the condition that their IP addresses regard to the same netmask. Basically, an alias name comprises the main interface name and the number of the alias, which are further parted by a colon. You have to utilize the following syntax for building an alias –

sudo ifconfig [alias-name] [alias-address]

You can confirm whether the alias was created successfully or not by executing ifconfig command.

Moreover, in order to remove an alias, you can implement the command as –

sudo ifconfig [alias-name] down

Enabling or Disabling Promiscuous Mode

The promiscuous mode helps to enable a network device to intercept and read every network packet that appears. It is usually employed for monitoring network activity. You can enable promiscuous mode using the syntax – 

sudo ifconfig [interface-name] promisc

You can confirm whether the promiscuous mode is active or not with the help ifconfig command. 

Moreover, you can disable the promiscuous mode, employing the command:

sudo ifconfig [interface-name] -promisc

Note : If you need a complete list of ifconfig commands, you can enter man ifconfig and you can have the desired information.


In this article, you have grasped the easy and accessible instructions to install ifconfig command and utilize it on CentOS. Further, you have also acquired insightful details into the list of common ifconfig commands for managing network interface effectively. However, if you still face any difficulty, you can connect with our Hostbillo experts. They are available through various communication modes and provide prompt responses.

Arpit Saini

He is the Chief Technology Officer at Hostbillo Hosting Solution and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Leave a Reply

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