Skip to content

ifconfig Command Cheat Sheet

ifconfig (interface configuration) is a legacy command-line utility for configuring network interfaces. Although widely replaced by the ip command, it remains essential for maintaining older systems and is still preferred by many administrators for its simplicity.


Synopsis

ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]

Basic Monitoring

View All Active Interfaces

ifconfig
Displays active interfaces with their IP addresses, netmasks, and statistics (packets RX/TX).

View All Interfaces (Including Down)

ifconfig -a

View Specific Interface

ifconfig eth0

Short Output (-s)

Displays a summary list, similar to netstat -i.

ifconfig -s

Interface Management

Enable an Interface (Up)

sudo ifconfig eth0 up

Disable an Interface (Down)

sudo ifconfig eth0 down
Note: This effectively kills network connectivity for that interface.


IP Configuration

Assign IP Address

Assigns IP 192.168.1.50 to eth0.

sudo ifconfig eth0 192.168.1.50

Assign IP and Netmask

sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0

Assign IP, Netmask, and Broadcast

sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255

Advanced Configurations

Change MAC Address (Spoofing)

You must bring the interface down first.

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

Configure MTU (Maximum Transmission Unit)

useful for Jumbo Frames or VPN tunneling optimization.

sudo ifconfig eth0 mtu 9000

Enable/Disable Promiscuous Mode

Allows the interface to receive all packets on the network (used for packet sniffing with Wireshark/tcpdump).

# Enable
sudo ifconfig eth0 promisc

# Disable
sudo ifconfig eth0 -promisc

Virtual Interfaces (IP Aliasing)

Assign multiple IP addresses to a single physical interface.

sudo ifconfig eth0:0 192.168.1.51 up
Now eth0 has its main IP, and eth0:0 acts as a second one.


Troubleshooting Output

Understanding the output statistics:

  • RX packets/errors/dropped: Received traffic health. Large error/drop counts indicate hardware issues or buffer saturation.
  • TX packets/errors/dropped: Transmitted traffic health.
  • collisions: In modern full-duplex networks, this should be 0. If high, check duplex mismatch.
  • txqueuelen: Transmission queue length (default usually 1000).

Notes

  • Deprecation: ifconfig is deprecated in many modern distros (Arch, RHEL/CentOS 7+). It is part of net-tools.
  • Replacement: The modern equivalent is ip addr and ip link.
  • Persistence: Changes made with ifconfig are not persistent across reboots. You must edit /etc/network/interfaces (Debian/Ubuntu) or /etc/sysconfig/network-scripts/ (RHEL) to make them permanent.