Installing and using ifconfig in Linux
ifconfig, short for “interface configurator”, is a network management tool used to configure and view the status of network interfaces on Linux. With ifconfig you can assign IP addresses, enable or disable interfaces, manage the ARP cache and routes, and more. In this article we’ll show you how to use it.
Installing ifconfig
ifconfig has been deprecated in favor of the ip command, so it may not be installed on newer Linux distributions.
Install ifconfig on Ubuntu / Debian
On Ubuntu- and Debian-based Linux distributions, run:
sudo apt install net-tools -y
Install ifconfig on CentOS
On CentOS and other RHEL-based distributions, run:
sudo dnf install net-tools -y
Using ifconfig
The syntax of the ifconfig command is:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
interface: the name of the network interface.address: the IP address you want to assign.
Settings made with ifconfig aren’t persistent: they’re lost when the system restarts. To make them permanent, edit your distribution’s network configuration files or add the commands to a startup script. Only root or users with sudo privileges can configure network interfaces.
Show network interface information
The following shows the configuration of all network interfaces and their IP addresses:
ifconfig -a
To show the configuration of a specific interface, add its name after the command:
ifconfig eth0
Assign an IP address and netmask
To assign an IP address and netmask to an interface, use:
ifconfig [interface-name] [ip-address] netmask [subnet-mask]
For example, to assign the IP address 192.168.0.101 and netmask 255.255.0.0 to eth0, run:
ifconfig eth0 192.168.0.101 netmask 255.255.0.0
You can also assign a secondary IP address to an interface using an interface alias:
ifconfig eth0:0 192.168.0.102 netmask 255.255.0.0
Enable and disable an interface
Sometimes you may need to reset a network interface. To disable an active interface, enter its name followed by the down flag:
ifconfig eth0 down
To enable an inactive interface, use the up flag:
ifconfig eth0 up
Enable and disable promiscuous mode
Promiscuous mode lets a network interface see every packet on the network. To enable it on an interface, add the promisc flag after the device name:
ifconfig eth0 promisc
To disable it, use -promisc:
ifconfig eth0 -promisc
Change an interface’s MTU
The MTU (Maximum Transmission Unit) limits the size of packets sent over an interface. You can change it with:
ifconfig [interface-name] mtu [mtu-value]
For example, to set the MTU of eth0 to 500, run:
ifconfig eth0 mtu 500
Change an interface’s MAC address
The MAC (Media Access Control) address is the physical address that uniquely identifies a device on the network. To change it, use the hw ether flag followed by the new MAC address:
ifconfig eth0 hw ether 00:00:2d:3a:2a:28
Summary
We’ve shown you how to use ifconfig to configure network interfaces and view their information.
We hope you found this useful. Share your comments and questions below, and follow Mizbandade for more.

