0
0
Linux CLIscripting~5 mins

ifconfig and ip addr in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you need to see the details of your computer's network connections. The commands ifconfig and ip addr help you check your network interfaces and their settings like IP addresses. This helps you understand or fix network problems.
When you want to see the IP address assigned to your computer.
When you need to check if a network interface is active or down.
When you want to find the MAC address of your network card.
When troubleshooting network connection issues.
When configuring or verifying network settings on a Linux machine.
Commands
This command shows all active network interfaces and their details like IP address and MAC address.
Terminal
ifconfig
Expected OutputExpected
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::a00:27ff:fe4e:66a1 prefixlen 64 scopeid 0x20<link> ether 08:00:27:4e:66:a1 txqueuelen 1000 (Ethernet) RX packets 1000 bytes 1234567 (1.2 MB) TX packets 800 bytes 987654 (987.6 KB) Interrupt:19 Base address:0x2000
This command shows all network interfaces with detailed information including IP addresses and interface status.
Terminal
ip addr
Expected OutputExpected
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:4e:66:a1 brd ff:ff:ff:ff:ff:ff inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic eth0 valid_lft 86394sec preferred_lft 86394sec inet6 fe80::a00:27ff:fe4e:66a1/64 scope link valid_lft forever preferred_lft forever
Key Concept

If you remember nothing else, remember: 'ip addr' is the modern, more detailed command to check network interfaces, while 'ifconfig' is older but still commonly used.

Common Mistakes
Trying to use ifconfig on a system where it is not installed by default.
Many modern Linux systems do not include ifconfig by default, so the command will fail.
Use 'ip addr' instead, which is installed by default on modern Linux systems.
Running 'ifconfig' without root privileges and expecting to see all interfaces.
Some interfaces or details may not show without proper permissions.
Run 'sudo ifconfig' or 'sudo ip addr' to see all details.
Summary
Use 'ifconfig' to quickly see active network interfaces and their IP addresses on older systems.
Use 'ip addr' for a detailed and modern view of all network interfaces and their settings.
Both commands help you check network status and troubleshoot connection issues.