Linux show network interfaces

How can I find available network interfaces?

This is in regard to linux, but if anyone knows of a general *nix method that would be good. I booted a system yesterday with an ethernet cable plugged in. «NetworkManager» is not installed, so once it started I went to look for the name of the ethernet interface with ifconfig to start a DHCP client manually, but it did not show anything other than lo . The NIC was listed via lspci , and the appropriate kernel driver was loaded. The system normally uses wifi, and I could remember the interface name for that was wlan0 . When I tried ifconfig wlan0 up , wlan0 appeared. But the only ethernet interface names I could remember were eth[N] and em[N] — neither of which worked. This document refers to «predictable interface names» but does not do a good job of explaining what they might be in simple terms. It does refer to a piece of source code which implies the name in this case might be deduced from the the PCI bus and slot numbers, which seems like an unnecessarily complicated hassle. Other searching around led me to believe that this might be determined by systemd in conjunction with udev , but there are almost 100 files in /usr/lib/udev/rules.d and spending an hour trying to determine where (and if) there’s a systemd config file for this also seems ridiculous. It would also be nice to know for certain that they are available, not just how they might be named if they are, so I can rule out hardware problems, etc. Isn’t there a simple way to find the names of available network interfaces on linux?

In the question you state that you used ip link but then you accept an answer that suggests ip link show which does the exactly same thing. Why?

The manual pages for iproute2 are quite good nowadays, I guess you’re using and older version of the package.

Источник

How to list network interfaces in Ubuntu

A network interface is a software interface for the networking hardware. In Linux-based systems like Ubuntu, network interfaces are of two types: virtual and physical network interfaces. A simple network hardware device, such as a network interface controller, comes under the category of the physical network interface. Ethernet network card or eth0 is an example of it. On the other hand, a virtual network interface does not have a physical existence but is associated with any physical device. VLANs, bridges, Loopback are examples of virtual network interfaces.

Читайте также:  Apt install linux generic hwe

In Ubuntu, you can configure network interfaces at the installation time or after the complete setup of the operating system, whether it is a physical or virtual network interface. To configure network settings via the Ubuntu command line, you must first know how many network interfaces exist on the

machine. This article will show you how to list network interfaces in Ubuntu using five different methods. So let’s get started!

Method 1: How to list network interfaces in Ubuntu using ip command

Linux administrators are familiar with the “ip” command, which is a powerful tool for configuring network interfaces. The “ip” stands for Internet protocol. In Ubuntu, the “ip” command can be utilized to assign and delete addresses and routes, put up or down interfaces, control ARP cache, and more. On all modern network interfaces, “iproute” is the package that contains the “ip” utility.

Now, we will see how we can use the “ip” command for listing the network interface in Ubuntu. For this, we will utilize the “link” option with the “ip” command. This option is used to list out and modify network interfaces:

In the “ip” command, there is another option that can be used for the same purpose. Adding the “address” option in the “ip” command will also show you the list of network interfaces and their IP addresses in the Ubuntu terminal:

Method 2: How to list network interfaces in Ubuntu using nmcli command

The “nmcli” stands for Network Manager Command-Line Tool. In Ubuntu, network status is reported, and the Network Manager is controlled using nmcli. You can also utilize this tool as an alternative to nm-applet and other graphical clients. This command is also used for creating, viewing, deleting, activating, and deactivating network connections.

By using “nmcli”, if you want to list out network interfaces in Ubuntu, then write out the below-given command in your terminal:

Here “device” option will list out the network interfaces, and the “status” will display their current status on the system:

To view the profile of the network interfaces, utilize this command in your terminal:

This command will retrieve the profile information of the network interface from the “/etc/sysconfig/network-scripts” file, comprising connection name as “NAME”, Universal Unique Identifier as “UUID“, network interface type as “TYPE”, and lastly, device name as “DEVICE”:

Method 3: How to list network interfaces in Ubuntu using netstat command

Network statistics or “netstat” is another utility used in Ubuntu to display network interface statistics, routing tables and monitor incoming and outgoing network connections. This command-line tool is essential for Linux-based systems and network administrators for resolving network-related issues and determining traffic performance.

In the netstat command, the “-i” option is added to list all network interface packet transactions. Execution of the below-given will also you the active network interfaces on your Ubuntu system:

Читайте также:  Linux and ntp server

Method 4: How to list network interfaces in Ubuntu using ifconfig command

The kernel-resident network interfaces are configured with the help of “ifconfig” or interface configuration command. This utility is used for setting up the interfaces as needed at boot time. After that, it is typically used only when system tuning or debugging is required. You can also use “ipconfig” command for the assignment of an IP address and netmask to an interface and to enable or disable it.

The below-given command will list out all the network interfaces of your Ubuntu system even if they are not active:

You can also utilize the below-given command for the same purpose:

Method 5: How to list network interfaces in Ubuntu using the “/sys/class/net/” file

The “/sys/class/net/” file contains the names of network interfaces or the network cards on your system. Utilize the “ls” command to list out the network interfaces present in this file:

Conclusion

When you operate as a Linux administrator, you are responsible for managing the system’s network configuration. Both physical and virtual network interfaces can be configured at installation or after setting up the whole Ubuntu system. To make any required changes in the network interface, you must know the information related to network interfaces. This article demonstrated how to list network interfaces in Ubuntu using five different methods. All of the discussed utilities are simple and easy to implement. Try any of them for getting a list of your network interfaces.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.

Источник

List network interfaces on Linux

The network configuration is a common place to start during system configuration, security audits, and troubleshooting. It can reveal useful information like MAC and IP addresses. This guide helps you to gather this information on Linux, including listing all available network interfaces and its details.

Show network interfaces

Linux

Every Linux distribution is using its own way of configuring the network configuration details. Therefore, it is good to know which tools can be used to query these details in a generic way. So these commands should be working on the popular distributions like Arch Linux, CentOS, Debian, Gentoo, RHEL, and Ubuntu.

The old way: ifconfig

Previously the most obvious command to obtain the available network interfaces was using the ifconfig command. As some systems no longer have that command installed by default, we will also look at using alternative ip. If you still have ifconfig available, run it with the -a parameter.

Depending on what particular information you need, you can use grep to get you the right lines. The ifconfig command on Linux actually has the most option available, so have a look at the man page for all details.

Modern version: using the ip command

Newer Linux distributions now ship only the ip command. It is advised to start using this command instead of ifconfig, as its output works better with newer machines. Especially when using containerized applications, dynamic routing, and network aliases.

Читайте также:  Gzip all files in directory linux

The easiest way to see what network interfaces are available is by showing the available links.

Screenshot showing ip command, an alternative to ifconfig

Linux network interfaces with ip link show command

Another option to show available network interfaces is by using netstat.

Note: the column command is optional, but provides a friendlier output for the eye.

Show the default gateway

The default gateway is the system that receives traffic for networks outside your own. On Linux systems, this gateway is typically received via DHCP or manually configured in a text configuration file.

Using the ip command

The output may look like this:

default via 123.12.0.1 dev eth0 onlink 10.17.0.0/16 dev eth0 proto kernel scope link src 10.17.0.3 123.12.0.0/18 dev eth0 proto kernel scope link src 123.123.0.3
With netstat

The default gateway can be listed with the netstat command.

The output will be something like this:

Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface default 123.12.0.1 0.0.0.0 UG 0 0 0 eth0 10.17.0.0 * 255.255.0.0 U 0 0 0 eth0 123.12.0.0 * 255.255.192.0 U 0 0 0 eth0

The second column shows the gateway. When it lists an asterisk (*), it means it uses the default gateway.

AIX and Solaris

These two old style platforms have of course ifconfig still available. By using the -a parameter, all interfaces will be displayed.

ifconfig -a | grep «flags ez-toc-section» > DragonBSD, FreeBSD, NetBSD

On the systems running BSD, it is also the ifconfig tool that can be used.

ifconfig -l

Frequently Asked Questions

How can I see the MTU of an interface?

Use the ip show link command.

What command can I use to display the default gateway on Linux?

Use the ip route command to show routing information, including the default gateway and the network interface it uses.

How can I test if my network configuration is correct?

Test if you can reach or access both devices on your network as outside of it. This way you know that your IP address and gateway is correctly set up. If you can only access remote systems by IP address, then check your name server configuration, typically stored in /etc/resolv.conf. Another useful tool to test your system, including your network configuration, is by using auditing tool Lynis. It will test for connectivity of the name servers and retrieves the most important parts of the network settings.

Did this article help you? Become part of the community and share it on your favorite website or social media. Do you have additional tips regarding the network configuration on Linux? Share it in the comments!

One more thing.

Keep learning

So you are interested in Linux security? Join the Linux Security Expert training program, a practical and lab-based training ground. For those who want to become (or stay) a Linux security expert.

Lynis Enterprise screenshot to help with system hardening

Security scanning with Lynis and Lynis Enterprise

Run automated security scans and increase your defenses. Lynis is an open source security tool to perform in-depth audits. It helps with system hardening, vulnerability discovery, and compliance.

Источник

Оцените статью
Adblock
detector