ifconfig Command

The ifconfig command (interface configuration) is used to configure and display network interface parameters in Linux and Unix systems. It's essential for network administration and troubleshooting.

Syntax

ifconfig [INTERFACE] [OPTIONS]
ifconfig [INTERFACE] [ADDRESS] [PARAMETERS]

Description

The ifconfig command is used to configure network interface parameters and display network interface information. It can assign IP addresses, configure netmasks, enable/disable interfaces, and much more.

Key features:

  • Display network interface information
  • Configure IP addresses and netmasks
  • Enable and disable network interfaces
  • Set hardware addresses (MAC)
  • Configure network parameters
Note: The ifconfig command is deprecated in favor of the ip command in modern Linux distributions, but it's still widely used and available.

Common Options

Option Description
-a Display all interfaces (active and inactive)
-s Display short list (similar to netstat -i)
up Activate the interface
down Deactivate the interface
netmask addr Set the IP network mask
broadcast addr Set the broadcast address
hw ether addr Set the hardware (MAC) address
mtu N Set the Maximum Transfer Unit

Examples

Display all active interfaces

ifconfig

Shows configuration of all active network interfaces

Display all interfaces (active and inactive)

ifconfig -a

Shows all network interfaces regardless of status

Display specific interface

ifconfig eth0

Shows configuration of the eth0 interface only

Assign IP address to interface

sudo ifconfig eth0 192.168.1.100

Assigns IP address 192.168.1.100 to eth0 interface

Assign IP address with netmask

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0

Assigns IP address with specific subnet mask

Enable network interface

sudo ifconfig eth0 up

Activates the eth0 network interface

Disable network interface

sudo ifconfig eth0 down

Deactivates the eth0 network interface

Set broadcast address

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255

Sets IP, netmask, and broadcast address

Change MAC address

sudo ifconfig eth0 down sudo ifconfig eth0 hw ether 00:11:22:33:44:55 sudo ifconfig eth0 up

Changes the hardware (MAC) address of the interface

Set MTU (Maximum Transfer Unit)

sudo ifconfig eth0 mtu 1500

Sets the MTU size for the interface

Configure interface with multiple parameters

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 up

Configures IP, netmask, broadcast, and enables interface

Display short interface list

ifconfig -s

Shows a condensed list of all interfaces

Add alias IP address

sudo ifconfig eth0:0 192.168.1.101 netmask 255.255.255.0

Adds an alias IP address to the interface

Remove alias IP address

sudo ifconfig eth0:0 down

Removes the alias IP address from the interface

Understanding ifconfig Output

Sample output explanation

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) RX packets 1234 bytes 567890 (554.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 987 bytes 123456 (120.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Key information displayed:

  • flags - Interface status (UP, BROADCAST, RUNNING, etc.)
  • mtu - Maximum Transfer Unit size
  • inet - IPv4 address, netmask, and broadcast
  • inet6 - IPv6 address information
  • ether - MAC address and queue length
  • RX/TX - Receive and transmit statistics

Common Use Cases

When to Use ifconfig
  • Network Troubleshooting - Check interface status and configuration
  • Temporary Configuration - Quick IP address changes for testing
  • Interface Management - Enable/disable network interfaces
  • Network Monitoring - View traffic statistics and errors
  • System Administration - Configure network settings

Modern Alternative: ip Command

The ip command is the modern replacement for ifconfig:

ifconfig Command ip Command Equivalent
ifconfig ip addr show
ifconfig eth0 ip addr show eth0
ifconfig eth0 up ip link set eth0 up
ifconfig eth0 192.168.1.100 ip addr add 192.168.1.100/24 dev eth0

See also