The ifconfig (interface configuration) command is a powerful networking utility used to configure, manage, and display information about network interfaces on Linux and Unix-like operating systems. Think of it as a tool that helps you see and control how your computer connects to networks.
If you try to use ifconfig and get an error message saying "command not found", don't panic! This just means the tool isn't installed on your system yet.
For security or testing purposes, you might want to change your MAC address:
ifconfig eth0 hw ether 00:1a:2b:3c:4d:5e
Beginner Tip: A MAC address is a unique identifier assigned to your network hardware. Changing it can sometimes help bypass network restrictions, but should be used responsibly.
RX packets/bytes: Information about data your computer has received
TX packets/bytes: Information about data your computer has sent
errors/dropped/overruns: Information about any problems with data transmission
Beginner Tip: The most important parts to look at are usually the interface name (eth0), your IP address (inet), and whether the interface is UP or not.
Your public IP address is how the internet sees you. It's assigned by your Internet Service Provider (ISP) and is usually shared by all devices on your network.
To find your public IP, you need to ask an external service on the internet:
Another web service that can tell you your public IP:
curl icanhazip.com
Beginner Tip: Your public IP address might change from time to time if your ISP uses dynamic IP assignment. If you're running a server from home, you might want to look into "Dynamic DNS" services.
While ifconfig is a classic command that many Linux users know and love, newer Linux distributions are moving toward using the ip command instead. The ip command is part of the iproute2 package and offers more features.
If you're learning Linux networking today, it's good to know both commands. Here's how they compare:
What you want to do
ifconfig command
ip command equivalent
See all network interfaces
ifconfig
ip addr show
See one specific interface
ifconfig eth0
ip addr show dev eth0
Turn on a network interface
ifconfig eth0 up
ip link set eth0 up
Turn off a network interface
ifconfig eth0 down
ip link set eth0 down
Set an IP address
ifconfig eth0 192.168.1.10
ip addr add 192.168.1.10/24 dev eth0
Set a netmask
ifconfig eth0 netmask 255.255.255.0
ip addr add 192.168.1.10/24 dev eth0
Change a MAC address
ifconfig eth0 hw ether 00:1a:2b:3c:4d:5e
ip link set dev eth0 address 00:1a:2b:3c:4d:5e
Beginner Tip: Notice how the ip command is more structured? It uses subcommands like addr and link to organize different types of network settings.
To set up a default gateway (the router that connects your network to other networks or the internet), you'll need to use the route command along with ifconfig:
# First set your IP address and netmaskifconfig eth0 192.168.1.10 netmask 255.255.255.0# Then add the default gatewayroute add default gw 192.168.1.1
In this example, 192.168.1.1 is the IP address of your router or gateway.
With the newer ip command, you would do:
# Set IP address and netmaskip addr add 192.168.1.10/24 dev eth0# Add default gatewayip route add default via 192.168.1.1
Even though ifconfig is considered "old" by some Linux distributions, it remains an essential tool to understand for several reasons:
It's Simple: The command structure is straightforward and easy to remember
It's Widespread: Many tutorials, guides, and older systems still use it
It's Powerful: Despite its simplicity, it can handle most network configuration tasks
It's Educational: Learning ifconfig helps you understand basic networking concepts
Whether you're a beginner just starting with Linux, a student learning networking, or an experienced system administrator, knowing how to use ifconfig will help you manage and troubleshoot network connections effectively.
Remember that networking is a fundamental skill in today's connected world. By mastering tools like ifconfig, you're building a solid foundation for more advanced networking concepts and technologies.
Happy networking!
Test Your Knowledge
Take a quiz to reinforce what you've learned
Exam Preparation
Access short and long answer questions for written exams