Ifconfig Command in Linux

The ifconfig command is an essential network administration tool in Linux systems used to configure network interfaces and display network interface parameters. It allows system administrators to view current network configuration, assign IP addresses, enable/disable interfaces, and modify various network settings from the command line.

Syntax

The basic syntax of the ifconfig command is

ifconfig [interface] [options]

Where interface specifies the network interface name (e.g., eth0, wlan0), and options define the actions to perform. If no interface is specified, ifconfig displays information for all available interfaces.

Common Options

Interface Control

up/down Activate or deactivate a network interface

ifconfig eth0 up
ifconfig eth0 down

IP Configuration

Setting IP Address Assign an IP address to an interface

ifconfig eth0 192.168.1.10

netmask Set the subnet mask

ifconfig eth0 netmask 255.255.255.0

broadcast Set the broadcast address

ifconfig eth0 broadcast 192.168.1.255

Hardware Configuration

hw ether Change the MAC address

ifconfig eth0 hw ether 00:11:22:33:44:55

mtu Set Maximum Transmission Unit size

ifconfig eth0 mtu 1500

Special Modes

promisc Enable promiscuous mode (capture all network packets)

ifconfig eth0 promisc
ifconfig eth0 -promisc

Practical Examples

Display All Interfaces

ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:fe4e:66a1  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:4e:66:a1  txqueuelen 1000  (Ethernet)

Configure Interface Completely

ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 up

View Specific Interface

ifconfig eth0

Key Points

  • Root privileges are required for configuration changes

  • Changes are temporary lost after reboot unless made permanent in network configuration files

  • Modern alternative ip command is preferred in newer Linux distributions

  • Interface names vary by system (eth0, ens33, enp0s3, wlan0, etc.)

Comparison with Modern Tools

ifconfig Command Modern ip Command Purpose
ifconfig ip addr show Display all interfaces
ifconfig eth0 192.168.1.10 ip addr add 192.168.1.10/24 dev eth0 Set IP address
ifconfig eth0 up ip link set eth0 up Activate interface
ifconfig eth0 down ip link set eth0 down Deactivate interface

Conclusion

The ifconfig command remains a fundamental tool for Linux network administration, providing straightforward interface configuration and monitoring capabilities. While newer tools like ip are becoming standard, ifconfig's simple syntax makes it ideal for quick network tasks and troubleshooting.

Updated on: 2026-03-17T09:01:38+05:30

849 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements