ifconfig Command
Beginner Networking man(1)Configure or display network interface parameters (legacy)
👁 11 views
📅 Updated: Mar 15, 2026
SYNTAX
ifconfig [INTERFACE] [OPTION]...
What Does ifconfig Do?
ifconfig displays or configures network interfaces. It shows IP addresses, MAC addresses, MTU, and traffic statistics. While ifconfig has been the standard for decades, the ip command is its modern replacement.
ifconfig is part of the net-tools package and is gradually being replaced by the ip command from iproute2. However, ifconfig remains widely used and available, especially on older systems and in documentation.
For new scripts and learning, the ip command is recommended. But knowing ifconfig is valuable because it is ubiquitous in existing documentation and older systems.
ifconfig is part of the net-tools package and is gradually being replaced by the ip command from iproute2. However, ifconfig remains widely used and available, especially on older systems and in documentation.
For new scripts and learning, the ip command is recommended. But knowing ifconfig is valuable because it is ubiquitous in existing documentation and older systems.
Options & Flags
| Option | Description | Example |
|---|---|---|
| (no args) | Show all active interfaces | ifconfig |
| -a | Show all interfaces (including down) | ifconfig -a |
| interface up/down | Enable/disable interface | sudo ifconfig eth0 down |
| interface IP | Assign IP address | sudo ifconfig eth0 192.168.1.100 |
| interface netmask | Set subnet mask | sudo ifconfig eth0 netmask 255.255.255.0 |
Practical Examples
#1 Show interfaces
Displays all active network interfaces.
$ ifconfig
Output:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
inet 192.168.1.100 netmask 255.255.255.0
ether aa:bb:cc:dd:ee:ff
#2 Specific interface
Shows details for eth0 only.
$ ifconfig eth0#3 Get IP address
Extracts just the IP address.
$ ifconfig eth0 | grep 'inet ' | awk '{print $2}'
Output:
192.168.1.100
#4 Bring interface down
Disables the network interface.
$ sudo ifconfig eth0 down#5 Set IP address
Assigns IP address and brings interface up.
$ sudo ifconfig eth0 192.168.1.200 netmask 255.255.255.0 upTips & Best Practices
ip command is the replacement: ifconfig → ip addr show. ifconfig eth0 down → ip link set eth0 down. ip is more powerful and actively maintained.
Quick IP check: hostname -I is faster than ifconfig for just getting IP addresses.
Changes are temporary: ifconfig changes are lost on reboot. Use /etc/network/interfaces or NetworkManager for permanent configuration.
Frequently Asked Questions
How do I check my IP address?
ifconfig shows all interfaces. Or ip addr show. Or hostname -I for just the IPs.
Should I use ifconfig or ip?
ip is the modern replacement. Use ip for new scripts. Know ifconfig for compatibility with older systems.
How do I disable a network interface?
sudo ifconfig eth0 down. Or modern: sudo ip link set eth0 down.
Related Commands
More Networking Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →