How to Obtain Information About Network Devices and Their Configuration on Linux

Linux is a powerful operating system that provides a wide range of tools for network management and configuration. Whether you are troubleshooting network issues, configuring new devices, or just exploring your system’s network setup, knowing how to obtain information about network devices is essential. Understanding basic linux commands is fundamental to network management. This article will guide you through several methods to gather network device details and their configurations on a Linux system.

In this tutorial you will learn:

  • How to utilize ip addr for detailed interface information
  • How to check routing tables with route
  • How to inspect network connections using netstat
  • How to use lshw to view hardware details of network devices
  • How to extract network details with nmcli
  • How to verify network settings with networkctl
  • How to display IRQ settings for network devices
  • How to find the Vendor ID of network devices
  • How to use the ifconfig command to view network interfaces
How to Obtain Information About Network Devices and Their Configuration on Linux
How to Obtain Information About Network Devices and Their Configuration on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distribution (e.g., Ubuntu, CentOS, Fedora)
Software Basic Linux command-line tools (pre-installed on most distributions)
Other Root or sudo privileges for certain commands
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Methods to Obtain Network Device Information on Linux

When managing network devices and their configurations on a Linux system, several methods can be utilized. Below are nine methods that are commonly used by system administrators and network engineers.

DID YOU KNOW?
Network device configurations on Linux can often be automatically managed by tools like NetworkManager, but knowing how to manually retrieve and configure network settings gives you greater control and understanding of your system.

  1. Using the ip addr Command to Find Network Information and MAC Address: The ip addr command is part of the iproute2 package and is the modern replacement for ifconfig. It provides detailed information about network interfaces, including IP addresses and MAC addresses.
    $ ip addr show

    This command displays all active network interfaces, along with their IP addresses, status, and MAC addresses. The MAC address is listed under the link/ether field. For example:

    2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 01:23:45:67:89:ab brd ff:ff:ff:ff:ff:ff
    

    The link/ether value represents the MAC address of the interface. This command is more commonly used in modern Linux distributions for detailed network information.

  2. Checking Routing Tables with the route Command: The route command is used to display the kernel’s IP routing table. This is particularly useful for troubleshooting network issues related to routing.
    # route -n

    This command displays the routing table in a numeric format, showing destinations, gateways, and the interfaces used for routing traffic.

  3. Inspecting Network Connections with netstat: The netstat command is a powerful tool that provides information about network connections, routing tables, interface statistics, and more.
    $ netstat -tuln

    This command lists all active listening ports and their associated protocols. It’s helpful for checking which services are listening on the network.

  4. Viewing Hardware Details with lshw: The lshw command is a hardware information tool that can be used to list detailed information about all hardware on your system, including network devices.
    # sudo lshw -C network

    This command provides detailed information about network devices, including the manufacturer, product name, and configuration.

    Viewing Hardware Details with lshw
    Viewing Hardware Details with lshw
  5. Using nmcli for NetworkManager Details: The nmcli command is a command-line client for NetworkManager, a popular network management tool on Linux.
    $ nmcli device show

    This command shows detailed information about network devices managed by NetworkManager, including IP addresses, gateways, and DNS servers.

  6. Verifying Network Settings with networkctl: The networkctl command is part of the systemd suite and provides an overview of network interfaces and their status on systems using systemd-networkd.
    # networkctl status

    This command displays the status of network interfaces, showing IP addresses, routes, and more. It’s particularly useful for systems that rely on systemd-networkd for network management.

  7. Displaying IRQ Settings for Network Devices: To find IRQ (Interrupt Request) settings specific to network devices, you can use the following command. This provides the IRQ numbers assigned to your network interfaces.
    # grep -r '.*' /sys/class/net/*/device/irq

    This command will output the IRQ numbers associated with each network interface, such as:

    /sys/class/net/enp0s31f6/device/irq:137
    /sys/class/net/wlp0s20f3/device/irq:16
    

    This information is valuable when diagnosing hardware-related network issues.



  8. Finding the Vendor ID of Network Devices: The lspci command can be used to display detailed information about PCI devices, including network adapters. The Vendor ID and Device ID are crucial for identifying hardware components.
    $ lspci -nn | grep -i ethernet

    This command displays the network devices along with their Vendor ID and Device ID in hexadecimal format. It is useful when searching for specific drivers or hardware compatibility information.

  9. Using the ifconfig Command: The ifconfig command is a traditional tool that provides information about network interfaces and their configurations. Although it has been deprecated in favor of ip in many distributions, it is still widely used for quick checks.
    # ifconfig

    This command will display information such as IP addresses, netmasks, and interface statuses. If you need to install it, you can do so by installing the net-tools package on your distribution.

Conclusion

Obtaining information about network devices and their configuration on Linux can be achieved through various methods. By mastering the tools mentioned in this article, you can effectively manage and troubleshoot network issues on your Linux system. Whether you are using traditional commands like ifconfig and route or modern tools like ip and nmcli, understanding these commands will provide you with the insights needed to maintain a healthy network environment. Additionally, methods like checking IRQ settings and finding Vendor IDs offer deeper insights into your network hardware configuration.



Comments and Discussions
Linux Forum