Ifconfig-Command-Used

What Is the Ifconfig Command Used For? Get the Basics

  • Post author:
  • Post category:Linux
  • Post last modified:August 30, 2024
  • Reading time:7 mins read

The ifconfig command, a traditional tool used in Unix-like operating systems, configures and manages network interfaces. Although the ip command has largely replaced it in modern Linux distributions, ifconfig remains useful and available on many systems.

use case #1: Displaying Information on All Network Interfaces Available on the System:

Using (ifconfig)

  • To list all network interfaces and their configurations, use:
  • This command shows IP addresses, netmasks, broadcast addresses, and the current status of each interface.

use case #2: Displaying Information on All Network Interfaces Available on the System:

Using (ifconfig -a)

  • To display only the active (up) interfaces, use.
  • This command shows detailed information for all interfaces, including those that are not currently active.

use case # 3 Assigning an IP Address to an Interface:

  • To assign an IP address to a specific interface, use.
sudo ifconfig <interface> <IP_address> netmask <netmask>
  • For example, to set the IP address 192.168.1.10 with a netmask of 255.255.255.0 to the eth0 interface.
root@ip-172-31-22-37:~#sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0

use case # 4 Altering Status of Network Interfaces:

  • To bring an interface up or down, use.
sudo ifconfig <interface> up

sudo ifconfig <interface> down
Status of Network Interfaces
For example, to bring lo up:-
root@ip-172-31-22-37:~#sudo ifconfig lo up

And to bring it lo down:-
root@ip-172-31-22-37:~#sudo ifconfig lo down

use case # 5 Setting MTU Size of an Interface:

  • To set the Maximum Transmission Unit (MTU) size for an interface, use.
sudo ifconfig <interface> mtu <size>
MTU Size of an Interface:
  • for instance, to set the MTU size to 1500 on eth0.
root@ip-172-31-22-37:~#sudo ifconfig enX0 mtu 1500
MTU Size of an Interface:

use case # 6 Enabling/Disabling Promiscuous Mode:

  • To enable or disable promiscuous mode (where the network interface captures all packets, not just those addressed to it), use:
sudo ifconfig <interface> promisc
sudo ifconfig <interface> -promisc
  • For example, to enable promiscuous mode on eth0:
root@ip-172-31-22-37:~#sudo ifconfig eth0 promisc
Enabling/Disabling Promiscuous Mode

And to disable it:

root@ip-172-31-22-37:~#sudo ifconfig eth0 -promisc
Enabling/Disabling Promiscuous Mode
  • While ifconfig is useful, you might also want to explore the ip command, which offers more comprehensive functionality and is the preferred tool in many modern Linux environments.

see also:

techlinux.in

ubuntu.com

techlinux.in

I’m a DevOps engineer with 8 years of experience in automation and cloud infrastructure. I’m passionate about optimizing software delivery and love sharing practical DevOps tips.Outside of work, I enjoy hiking, cooking, and contributing to open-source projects.Thanks for visiting my blog