Linux List Network Interfaces and Details
In this article
Listing network interfaces in Linux helps identify available connections and troubleshoot network issues. This guide shows how to use command-line tools to display interface names, statuses, and configurations.
What You'll Need
- A Linux-based system (e.g., Ubuntu, Fedora, CentOS).
- Access to a terminal or command-line interface.
- Basic familiarity with Linux commands.
Step-by-Step
- Open the terminal.
Press Ctrl + Alt + T or find "Terminal" in your application menu. On some systems, you may need to use the app launcher and search for "Terminal" or "Console". This is the main interface for running commands. - Use the
ipcommand.
Runip link showto list all network interfaces. This command shows interface names (e.g.,eth0,ens33,wlan0) and their statuses (UP/DOWN). For example:
1: lo:
Here,mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:1a:2b:3c:4d:5e brd ff:ff:ff:ff:ff:ff lois the loopback interface, andeth0is an active Ethernet interface. - View detailed interface info.
Runip addr showto see IP addresses, MAC addresses, and other interface details. This is useful for confirming which interface is being used for internet access. Sample output includes:
2: eth0:
Here,mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:1a:2b:3c:4d:5e brd ff:ff:ff:ff:ff:ff inet 192.168.1.5/24 brd 192.168.1.255 scope global dynamic eth0 eth0has an IPv4 address of192.168.1.5. - Use
ifconfig(if available).
Some Linux versions still supportifconfig. Runifconfigto see interface statuses and assigned IP addresses. If it's not recognized, installnet-toolsviasudo apt install net-toolsorsudo dnf install net-toolsdepending on your distro. - Check interface status.
Runip link showagain to confirm whether interfaces are UP or DOWN. Interfaces withUPare active and transmitting data. Those withDOWNare inactive or disconnected. - Use
nmclifor NetworkManager users.
If NetworkManager is installed, runnmcli deviceto list interfaces and their connection status. This is particularly useful on desktop systems like GNOME or KDE. Sample output includes:
DEVICE TYPE STATE CONNECTION eth0 802-3-ethernet connected Home Network wlan0 wifi disconnected --
This showseth0is connected, andwlan0is not. - Optional: View interface files.
Check/sys/class/netor/etc/network/interfacesfor interface configurations. For example,ls /sys/class/netlists all available interfaces in the system./etc/network/interfacesis used in Debian and Ubuntu to define static IP settings.
Common Mistakes
Here are common errors and how to avoid them:
- Typo in command names.
Commands likeiporifconfigmust be spelled correctly. Use tab completion in the terminal to avoid typos. For example, typeip land press Tab to auto-complete toip link. - Confusing interface names.
Interfaces likeeth0andens33can look similar. Always check the full output to match interface names with IPs. For example,ip addr show dev eth0gives details exclusive to that interface. - Running commands without privileges.
Some commands requiresudo. Addsudobefore the command if you see permission errors. For example,sudo ip link set eth0 downrequires elevated privileges. - Using outdated tools.
Some distros have droppedifconfigin favor ofip. Useipfor consistency across modern systems. If you must useifconfig, installnet-toolsfirst.
Tips
- Filter interface output.
Useip link show dev eth0to focus on a specific interface. This is useful when you only care about a single device, such as a dedicated Ethernet or USB tethering interface. - Automate with scripts.
Create a script to list interfaces on startup or during diagnostics. For example, create a filelist_interfaces.shand run it at boot to log interface status. Sample script:
#!/bin/bash ip link show > /var/log/interfaces.log
- Use grep for quick filtering.
Runip link show | grep UPto find only active interfaces. This is helpful in scripts or when interfaces are numerous. - Check wireless interfaces separately.
Useiwconfigfor wireless-specific info if needed. This command shows details like signal strength, encryption, and connection status for WiFi interfaces. - Combine commands for faster inspection.
Useip -br addr showto get a condensed view of all interfaces and their IP addresses. This is particularly useful for quickly identifying which interface is in use.
Troubleshooting
If commands do not return expected results, try these steps:
- Restart the network service.
Runsystemctl restart NetworkManagerorsystemctl restart networking, depending on your system. This can reset the state of interfaces and re-trigger network detection. - Check system logs.
Usejournalctl -u NetworkManagerto see if there are errors related to network interfaces. Logs often include driver issues or failed connection attempts. - Verify command availability.
Runwhich iporwhich ifconfigto confirm the tools are installed. If not, installiproute2ornet-toolsas needed. Usesudo apt install iproute2orsudo dnf install iproute2for installation. - Scan for hardware issues.
Uselspci | grep networkto check if network cards are detected by the system. If no output is shown, the hardware may not be recognized or may have a missing driver. - Check for missing drivers.
If an interface is missing, uselsmod | grep -i e1000(for Intel cards) or similar to see if the required kernel module is loaded. If not, load it withsudo modprobe e1000.
Advanced Interface Inspection
For deeper inspection, use the following commands:
ethtoolfor hardware diagnostics.
Runethtool eth0to see detailed stats about the interface, including speed, duplex, and link status. This is useful for diagnosing issues like slow speeds or dropped connections.nmclifor managing connections.
If using NetworkManager, you can activate or deactivate interfaces withnmcli device set eth0 managed yesornmcli device set eth0 managed no. This can isolate the interface from automatic configuration.arpfor local network inspection.
Runarp -ato list devices on the local network. This is useful for identifying connected clients and their MAC addresses.
Frequently Asked Questions
1. What does ip link show display?
It lists all network interfaces along with their status (UP/DOWN), type (Ethernet, wireless), and other attributes.
2. Why does ifconfig not work on my system?
Some Linux distros (like Ubuntu) have replaced ifconfig with the ip command. Install net-tools to use ifconfig if needed.
3. How do I know which interface is my main one?
Look for the interface with an IP address assigned (e.g., inet 192.168.1.5). This is typically the active interface for internet access.
4. Can I list only active interfaces?
Yes. Run ip link show up to display only interfaces in the UP state.
5. What if I see no interfaces listed?
Check for hardware issues using lspci or ls /sys/class/net. If interfaces are missing, ensure drivers are installed and working.
6. How do I check wireless interface status?
Use iwconfig or ip link show wlan0 to check wireless interface details and status.