ifconfig Command Guide for Viewing Network Interfaces (Legacy)
ifconfig is the classic tool for showing and configuring network interfaces on Linux — deprecated in favor of ip, but still found on older systems and in countless tutorials.
What is ifconfig, and Why Use It?
ifconfig (short for interface configuration) has been the standard way to inspect network interfaces on Unix systems for decades. It shows every interface with its MAC address, IPv4 and IPv6 addresses, and traffic statistics, and it can also assign addresses and toggle interfaces. On modern Linux it is considered deprecated: the ip command from iproute2 replaces it completely. That said, ifconfig still ships on many systems (usually via a small net-tools package), and it appears in older guides, scripts, and interviews — so recognizing its output is part of being able to read Linux documentation.
Why Learn ifconfig?
- You will meet it in the wild — legacy servers, embedded devices, and older tutorials all still use it; knowing the output saves translation work.
- It is the simplest interface listing — one word,
ifconfig, prints everything, with no subcommands to remember. - Understanding it makes
ipeasier — every fieldifconfigshows has a directipequivalent, and comparing the two cements both.
Think of
ifconfigas a dialect: you do not need to speak it fluently, but you should recognize it when an old guide uses it.
1. Show All Interfaces
The basic invocation:
ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.42 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:feab:cdef prefixlen 64 scopeid 0x20<link>
ether 08:00:27:ab:cd:ef txqueuelen 1000 (Ethernet)
RX packets 15234 bytes 18223456 (17.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9876 bytes 1234567 (1.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
...
Key fields:
UP,RUNNING— the interface is enabled and has a carrier.inet 192.168.1.42 netmask 255.255.255.0— the IPv4 address and subnet mask (/24inipnotation).ether 08:00:27:ab:cd:ef— the MAC address (shown byipaslink/ether).RX/TX— bytes and packets received and transmitted; a quick sanity check that traffic is flowing.
2. Show One Interface
ifconfig enp0s3
ifconfig wlan0
Filters the list to a single interface — the same job as ip addr show enp0s3.
3. Find Your Local IP Quickly
ifconfig | grep 'inet '
The inet lines carry the IPv4 addresses; the first one that is not 127.0.0.1 is your machine’s address on the local network. (This exact pipeline is one of the most common ifconfig incantations on the internet.)
4. Bring an Interface Up or Down
sudo ifconfig enp0s3 down
sudo ifconfig enp0s3 up
Same intent as sudo ip link set enp0s3 down / up. Warning: if you are running this over SSH through that interface, you will disconnect yourself.
5. Assign a Temporary IP Address
sudo ifconfig enp0s3:0 10.0.0.5 netmask 255.255.255.0 up
The :0 syntax adds a second (“aliased”) address to the interface. This is how you temporarily join another subnet for testing. It disappears on reboot, exactly like ip addr add.
6. Translating Between ifconfig and ip
ifconfig shows | ip equivalent |
|---|---|
inet 192.168.1.42 netmask 255.255.255.0 | inet 192.168.1.42/24 |
ether 08:00:27:ab:cd:ef | link/ether 08:00:27:ab:cd:ef |
UP,RUNNING flags | state UP and LOWER_UP |
RX packets ... bytes ... | ip -s link show enp0s3 |
ifconfig -a | ip link show |
If a guide says “run ifconfig to get your IP”, the modern equivalent is ip addr show — same answer, current syntax.
7. Installing It When Missing
On current distributions ifconfig is not installed by default:
# Debian / Ubuntu
sudo apt install net-tools
# Fedora / RHEL
sudo dnf install net-tools
# Arch
sudo pacman -S net-tools
If the command is not found, that is normal — reach for ip instead, or install net-tools if a tutorial truly requires ifconfig.
Common Pitfalls
- Treating
ifconfigas current best practice — it is deprecated; new work should useip. - Misreading
netmaskvs prefix —255.255.255.0and/24are the same thing written two ways. - Assuming missing means broken — a modern system without
ifconfigis simply shipping the newer tool. - Forgetting the alias syntax —
enp0s3:0is a label for a second address, not a separate interface.
Related Pages
| Page | Relationship |
|---|---|
| ip | The modern replacement for every ifconfig feature |
| ping | Test reachability once you have an address |
| ss | Shows connections on the interfaces listed here |
ifconfig Cheatsheet
| Command | What it does |
|---|---|
ifconfig | Show all interfaces with addresses and statistics |
ifconfig -a | Show all interfaces, including ones that are down |
ifconfig enp0s3 | Show one interface |
ifconfig | grep 'inet ' | List IPv4 addresses |
sudo ifconfig enp0s3 up | Enable an interface |
sudo ifconfig enp0s3 down | Disable an interface |
sudo ifconfig enp0s3:0 10.0.0.5 up | Add a temporary second address |