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
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
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
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:
ifconfigis deprecated in many modern distros (Arch, RHEL/CentOS 7+). It is part ofnet-tools. - Replacement: The modern equivalent is
ip addrandip link. - Persistence: Changes made with
ifconfigare not persistent across reboots. You must edit/etc/network/interfaces(Debian/Ubuntu) or/etc/sysconfig/network-scripts/(RHEL) to make them permanent.