Linux network interfaces are listed using the `ip link show` command in the terminal. If you are wondering how to find network interface name in linux, you have come to the right place. This guide will walk you through multiple methods, from simple commands to advanced tricks, so you can always identify your network interfaces quickly and confidently.
Whether you are a beginner setting up Wi-Fi or a sysadmin troubleshooting a server, knowing your interface names is essential. Let us jump straight into the practical steps.
How To Find Network Interface Name In Linux
The most common and reliable way is using the `ip` command. Open your terminal and type:
ip link show
This will list all network interfaces on your system. Look for names like `eth0`, `ens33`, `wlp2s0`, or `lo`. The `lo` interface is the loopback, which is always present. Other names represent your physical or virtual network cards.
For a cleaner output that shows only the interface names, use:
ip link show | grep -E '^[0-9]+:' | awk -F': ' '{print $2}'
This filters the output to display just the names. You can also use `ip addr` to see IP addresses assigned to each interface alongside their names.
Using The Ifconfig Command
Older Linux systems and some distributions still support `ifconfig`. Although it is deprecated, it remains a popular choice. Run:
ifconfig -a
This shows all interfaces, including those that are down. Look for names like `eth0`, `wlan0`, or `enp0s3`. If `ifconfig` is not installed, you can install it via `sudo apt install net-tools` (on Debian/Ubuntu) or `sudo yum install net-tools` (on RHEL/CentOS).
Note: The output from `ifconfig` can be verbose. For just the interface names, you can combine it with `grep`:
ifconfig -a | grep -E '^[a-z]' | awk '{print $1}'
Checking The /Sys/Class/Net Directory
Linux stores network interface information in the `/sys/class/net/` directory. Each interface has its own subdirectory. To list all interfaces, simply run:
ls /sys/class/net
This command is extremely fast and reliable because it reads directly from the kernel. It works on all Linux distributions without needing any additional tools. The output is a clean list of interface names, one per line.
You can also check the contents of a specific interface’s directory to get more details, like its MAC address or speed:
cat /sys/class/net/eth0/address
Using The Network Manager CLI
If your system uses NetworkManager (common on desktop distributions like Ubuntu, Fedora, or Linux Mint), you can use the `nmcli` command. Type:
nmcli device status
This shows a table with device names, types, and connection states. The first column is the interface name. For example, you might see `eth0`, `wlp2s0`, or `enp0s3`. This method is particularly useful if you want to see which interfaces are currently connected.
For a simpler list of just the names:
nmcli -t -f DEVICE device status
Reading The /Proc/Net/Dev File
The `/proc/net/dev` file is another kernel interface that lists network statistics. It includes all interfaces. To see the names, run:
cat /proc/net/dev | grep -E '^[a-z]' | awk -F':' '{print $1}'
This command extracts the interface names from the first column. The output is similar to the `/sys/class/net` method but includes some extra whitespace that you might need to clean up.
This approach works even on minimal Linux installations without any networking tools installed. It is a good fallback if other commands are unavailable.
Understanding Interface Naming Conventions
Modern Linux systems use predictable network interface names. Instead of traditional names like `eth0` or `wlan0`, you might see names like `enp0s3`, `ens33`, or `wlp2s0`. These names encode information about the hardware location.
- en – Ethernet
- wl – Wireless LAN
- ww – WWAN (cellular)
- p – PCI bus number
- s – Slot number
For example, `enp0s3` means: Ethernet, PCI bus 0, slot 3. This naming helps avoid confusion when you have multiple network cards. If you prefer the old naming, you can disable predictable names in your bootloader configuration, but it is not recommended.
Why Interface Names Matter
Knowing your network interface name is crucial for many tasks:
- Configuring static IP addresses
- Setting up firewall rules with iptables or nftables
- Debugging network connectivity issues
- Writing scripts that interact with specific interfaces
- Binding services to a particular network card
Without the correct name, you might accidentally configure the wrong interface, leading to network outages or security vulnerabilities.
Practical Examples For Finding Interface Names
Let us look at some real-world scenarios where you need to find your network interface name.
Example 1: Finding Your Wi-Fi Interface
If you are using a laptop with Wi-Fi, you need the wireless interface name to connect or troubleshoot. Run:
iwconfig
This command shows wireless-specific information. The interface name is listed at the top, like `wlp2s0` or `wlan0`. If `iwconfig` is not installed, use `nmcli device status` and look for the `wifi` type.
Example 2: Finding All Interfaces Including Virtual Ones
Virtual interfaces like `docker0`, `veth*`, or `tun0` are common on servers. To see them all, use:
ip link show type veth
Or simply `ip link show` to see everything. Virtual interfaces often start with `veth`, `br-`, or `docker`. They are essential for container networking.
Example 3: Finding The Interface With A Specific IP
If you know the IP address but not the interface name, use:
ip addr show | grep '192.168.1.100'
This will show the interface that has that IP. The interface name appears before the IP address in the output.
Using Grep And Awk For Advanced Filtering
Sometimes you need just the name of the active interface (the one with an IP). You can combine commands:
ip -o -4 addr show | awk '{print $2}'
This lists only interfaces with IPv4 addresses. The `-o` flag gives one-line output, and `-4` limits to IPv4. Similarly, for IPv6:
ip -o -6 addr show | awk '{print $2}'
These commands are great for scripting. For example, you can store the active interface in a variable:
ACTIVE_IFACE=$(ip -o -4 addr show | awk '{print $2}' | head -1)
Finding The Interface Name For A Specific MAC Address
If you have a MAC address and want to find the interface, run:
ip link show | grep -B1 '00:11:22:33:44:55' | head -1
This shows the line before the MAC address, which contains the interface name. Alternatively, use:
cat /sys/class/net/*/address | grep '00:11:22:33:44:55'
But this only gives the MAC, not the interface name. A better approach is:
for iface in /sys/class/net/*; do echo "$(basename $iface): $(cat $iface/address)"; done | grep '00:11:22:33:44:55'
Troubleshooting Common Issues
Sometimes you might not see all interfaces. Here are common problems and solutions.
Interface Not Showing Up
If an interface is missing from the output, it might be down. Use `ip link show` to see all interfaces, including those that are down. If it still does not appear, the driver might not be loaded. Check with `lspci -k | grep -A3 ‘Network’` or `lsusb` for USB devices.
Permission Denied
Some commands like `ifconfig` or `ip` might require root privileges to see all interfaces. Use `sudo` if you encounter permission errors. However, most basic commands work without root.
Interface Name Changes After Reboot
Predictable naming should keep names consistent. If names change, it might be due to hardware changes or BIOS settings. Check your `/etc/default/grub` file for `net.ifnames=0` which disables predictable naming. If you want consistency, keep predictable naming enabled.
Script To List All Interface Names
Here is a simple bash script that lists all network interface names with their types:
#!/bin/bash
for iface in /sys/class/net/*; do
name=$(basename $iface)
type=$(cat $iface/type)
case $type in
1) echo "$name: Ethernet" ;;
2) echo "$name: SLIP" ;;
6) echo "$name: Token Ring" ;;
32) echo "$name: InfiniBand" ;;
768) echo "$name: Loopback" ;;
772) echo "$name: Wireless" ;;
776) echo "$name: Tunnel" ;;
*) echo "$name: Unknown ($type)" ;;
esac
done
Save it as `list-interfaces.sh`, make it executable with `chmod +x list-interfaces.sh`, and run it. This script reads directly from the kernel, so it is very fast.
Using The Hwconfig Command
Some older systems have `hwconfig` which shows hardware configuration including network interfaces. Run:
hwconfig --network
This is less common but still useful on some enterprise distributions. If you have it, it provides a clean summary.
Comparing Different Methods
Here is a quick comparison of the methods we discussed:
- ip link show – Most modern and recommended. Works on all distributions.
- ifconfig -a – Legacy but still widely used. May need installation.
- /sys/class/net – Fastest and most reliable. No tools needed.
- nmcli device status – Best for NetworkManager users.
- /proc/net/dev – Good fallback for minimal systems.
Choose the one that fits your situation. For daily use, `ip link show` is usually the best balance of simplicity and power.
Frequently Asked Questions
What Is The Easiest Way To Find Network Interface Names In Linux?
The easiest way is to run `ip link show` in the terminal. It lists all interfaces with their names and status. For a cleaner list, use `ls /sys/class/net`.
Why Do My Network Interface Names Look Strange Like Enp0s3?
Modern Linux uses predictable naming based on hardware location. `enp0s3` means Ethernet on PCI bus 0, slot 3. This prevents names from changing when you add or remove hardware.
Can I Find The Network Interface Name Without Using The Terminal?
Yes, you can use GUI tools like `nm-connection-editor` or system settings. Look for “Network” or “Wi-Fi” settings. The interface name is usually shown in the connection details.
How Do I Find The Interface Name For A USB Network Adapter?
Connect the USB adapter and run `ip link show`. It will appear as a new interface, often named `enx` followed by the MAC address, or `eth1` on older systems. You can also check `dmesg | tail -20` for kernel messages.
What If I Have Multiple Interfaces With Similar Names?
Use `ip addr show` to see IP addresses assigned to each. Or check the MAC address with `ip link show` to identify the correct one. You can also use `ethtool` to get detailed hardware information.
Final Thoughts
Knowing how to find network interface name in linux is a fundamental skill. Whether you use the `ip` command, `ifconfig`, or the `/sys` filesystem, each method has its strengths. Practice these commands on your system, and you will be able to identify any interface in seconds.
Remember, the exact keyword “how to find network interface name in linux” is your starting point. With the techniques above, you can handle any networking task that comes your way. Keep this guide bookmarked for quick reference, and you will never be stuck wondering what your interface is called.