We are going to show you how to get different network card properties like
Name of network cards Network card link status Network card speeds Network card MAC address Network card IP address Network card driver details Network card manufacture details Network card duplex/half duplex details Network card auto-negotiation details Complete network card capabilities details Complete network card hardware details
Let us start to find these details with examples so that it will be easy to understand. Note that most of the below commands should be run as root to get proper output.
Example 1: Find all your network cards(Ethernet, Gigabit Ethernet, Wireless) names attached to a given system.
ifconfig | cut -c1-8 | sort -u
output:
eth0 lo virbr0 wlan0
Example 2 : find how many network connections(network cables are connected to your machine) are active i.e. link is up.
ip link show
Output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000 link/ether 10:1f:74:58:e1:04 brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT qlen 1000 link/ether d0:df:9a:e6:1d:a6 brd ff:ff:ff:ff:ff:ff 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT link/ether 52:54:00:be:79:50 brd ff:ff:ff:ff:ff:ff 5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT qlen 500 link/ether 52:54:00:be:79:50 brd ff:ff:ff:ff:ff:ff
or
As a root user
mii-tool
Output:
eth0: no link
or for wireless network card
ethtool interfacename
Example
root@linuxnix.com:/home/surendra# ethtool wlan0 Settings for wlan0: Link detected: yes
Example 3: How can we find out network card speeds so that we can see throughput of the devices attached to a machine.
ethtool eth0 | grep speed
output:
ethtool eth0 | grep Speed Speed: 10Mb/s
Example 4: How can we get MAC address of a given NIC card?
ethtool -P devicename
Example:
ethtool -P eth0
Output:
Permanent address: 10:1f:74:58:e1:04
Example 5: Find IP address assigned to an interface and all interfaces in Linux.
ifconfig interfacename
Example
ifconfig wlan0
Output:
wlan0 Link encap:Ethernet HWaddr d0:df:9a:e6:1d:a6 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::d2df:9aff:fee6:1da6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:314270 errors:0 dropped:0 overruns:0 frame:0 TX packets:382181 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:99368108 (99.3 MB) TX bytes:177093425 (177.0 MB)
For all the interfaces in a given machine
ifconfig
Output:
eth0 Link encap:Ethernet HWaddr 10:1f:74:58:e1:04 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:7595 errors:0 dropped:0 overruns:0 frame:0 TX packets:7595 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:688876 (688.8 KB) TX bytes:688876 (688.8 KB) virbr0 Link encap:Ethernet HWaddr 52:54:00:be:79:50 inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:654 (654.0 B) wlan0 Link encap:Ethernet HWaddr d0:df:9a:e6:1d:a6 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::d2df:9aff:fee6:1da6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:314270 errors:0 dropped:0 overruns:0 frame:0 TX packets:382181 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:99368108 (99.3 MB) TX bytes:177093425 (177.0 MB)
Example 6: How can we find network cared driver details in Linux?
ethtool -i wlan0
Output:
root@linuxnix.com:/# ethtool -i wlan0 driver: ath9k version: 3.5.0-25-generic firmware-version: N/A bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no root@linuxnix.com:/# ethtool -i eth0 driver: r8169 version: 2.3LK-NAPI firmware-version: rtl_nic/rtl8168e-2.fw bus-info: 0000:01:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: yes supports-priv-flags: no
Example 7: How can we find network card manufacture details for both Ethernet card and wireless cards
lspci -v | grep -iE 'Wire|Ether'
Output:
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller (rev 06)
02:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
02:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
Example 8: How can we get NIC card mode details like full/half duplex
ethtool eth0 | grep Duplex
Output:
Duplex: Half
Example 9: How about finding my network card is auto negotiation enabled or not in Linux?
ethtool eth0 | grep Auto
Output:
Auto-negotiation: on
Example 10: Find complete network card software details like speed, modes, negotiations, link status etc.
root@linuxnix.com:/home/surendra# ethtool eth0 Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Speed: 10Mb/s Duplex: Half Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000033 (51) drv probe ifdown ifup Link detected: no
Example 11: Find complete network card hardware details.
lshw -class network
Output:
*-network description: Ethernet interface product: RTL8111/8168 PCI Express Gigabit Ethernet controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:01:00.0 logical name: eth0 version: 06 serial: 10:1f:74:58:e1:04 size: 10Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half firmware=rtl_nic/rtl8168e-2.fw latency=0 link=no multicast=yes port=MII speed=10Mbit/s resources: irq:41 ioport:3000(size=256) memory:c0404000-c0404fff memory:c0400000-c0403fff *-network description: Wireless interface product: AR9285 Wireless Network Adapter (PCI-Express) vendor: Atheros Communications Inc. physical id: 0 bus info: pci@0000:02:00.0 logical name: wlan0 version: 01 serial: d0:df:9a:e6:1d:a6 width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless configuration: broadcast=yes driver=ath9k driverversion=3.5.0-25-generic firmware=N/A ip=192.168.1.2 latency=0 link=yes multicast=yes wireless=IEEE 802.11bgn resources: irq:18 memory:c2500000-c250ffff *-network DISABLED description: Ethernet interface physical id: 1 logical name: virbr0-nic serial: 52:54:00:be:79:50 size: 10Mbit/s capabilities: ethernet physical configuration: autonegotiation=off broadcast=yes driver=tun driverversion=1.6 duplex=full link=no multicast=yes port=twisted pair speed=10Mbit/s
lspci | grep -i “Ethernet”I tried above said command in my Linux Server and got the following results. It looks like the network card uses the BCM5709 chip from Broadcom. When you run the same command in your linux box, you should see something similar to this.NOTE: lspci command may not be available by default on all Linux machines. lspci is part of pciutils package and if you are using Redhat, CentOS or Fedora, then you need to run yum install pciutilscommand to install this tool. If you are using Ubuntu or Debian, then use the command apt-getinstall pciutils to enable lspci command.lspci command provides very detailed information about all PCIbuses and devices in the system. So if you need detailed information about the NIC card, then we can specify more options to the lspci command. Go ahead and try the command:lspci -v | grep Ethernet -A 1This command will list the actual name of the network adapter next to “Subsystem”. I ran above said command on my Linux machine and got the below provided result. From the result, I understand that my NIC Card model is HP NC382i NIC Adapter from Hewlett-Packard and the chipset used is BroadcomBCM5709.Well, if you are greedy like me and would like to have lot more information about the network interface card installed in your machine, then you go ahead and run below said command:lspci -v | grep Ethernet -A 20Holy cow!, it pulled hell lot of information about my NIC card. Here I can find Chipset, Model number, NICDriver information, Buffer size and different capabilities of the NIC card. If you run the above said command in your machine, you should see something similar to this (Please check the screenshot provided below).Another way to find hardware information is by using lshw command. By default, lshw command is not available on your Fedora, CentOS, Ubuntu, Debian or RedHat system. To install lshw, you need to setup right repository using YUM or apt-get. Once you configured repository, run the command apt-get installlshw for Ubuntu or Debian Linux. If you are using CentOS, RedHat and Fedora, then run the command yuminstall lshw . Once lshw is installed, go ahead and run the command:lshw -class networkFind the Driver and Firmware of Network Card in Linux:
Here, we will discuss how to find Network Card Driver and firmware version in Linux. As you know that, NIC manufactures often release newer drivers and firmware for the NIC cards. Very often these drivers andfirmware solves variety of bugs reported ewith the NIC card. So in many occasion, we may need to find the existing version of NIC driver and the current firmware of NIC card. In Linux, we can easily find this information by using ethtool command.I assume that your machine have at-least one Network Interface Card (NIC) available and the name of the NIC is eth0. Now try the command:ethtool -i eth0I ran the ethtool -i eth0 command in my machine and got the following results (you may check the screenshot). From the results, I understand that NIC card is currently using “bnx2 driver version 2.2.3” andfirmware of NIC card is 5.2.3. Moreover I found information related to Broadcom NIC here.NOTE: ethtool may not be installed by default on your Fedora, CentOS, Ubuntu, Debian or RedHat system. To install ethtool on your Fedora, CentOS or RedHat machine, run the command yuminstall ethtool and if you are using Ubuntu or Debian Linux, you could run the command apt-getinstall ethtool.If above said command does not work, we can use you dmesg command. In Linux, dmesg command will display the system message buffer and helps to view log messages related to the most recent Linux system start-up. So let us see what dmesg found at the system start-up regarding the NIC card. Run below provided command:dmesg | grep “Ethernet Driver”Once I executed the command, you can find that I use a Broadcom NIC chipset, the driver is bnx2, driverversion is 2.2.3 and driver date is June 27, 2012.Another way to find driver information is to check the /var/log/messages. The /var/log/messages file contains all system related messages that are logged during system startup. There is a good chance this file would contain information about the network card. Run below said command.grep “Ethernet Driver” /var/log/messagesCheck the result displayed on my System. You could find the device driver name, driver date and version ofdriver.Find NIC Link Status and Duplex information in Linux:
Let us try to find the Link status and Duplex information of the Network Card. To check the link status anddriver information of the NIC card, you could go ahead and try the command provided below.dmesg | grep -i duplexI ran above said command and here is the output of above said command.You could also use mii-tool to find the NIC link status. Run below said command:mii-tool eth0How to find MAC Address of the NIC Card in Linux:
Each Network card is shipped with unique MAC address. This MAC address may be needed if you are a Network Admin. If you ever wanted to find the MAC address of the NIC card, then you can run following linux command:ethtool -P eth0Check the sample output shown below (I hide the mac address though).Most common way to find the MAC address of the NIC card is by using the ifconfig –a command. Apart from MAC address, this command will list lots of information about the NIC card. Try running following command to find MAC address:ifconfig -aHow to find Hardware settings of the NIC in Linux:
If you would like to see hardware settings or features of network card, such as supported link modes, pause frame, duplex, auto-negotiation, speed, port type and link status, then you can run following command:ethtool eth0The output of ethtool command is shown below. It gives lots of information about the NIC.How to find the statistics of the NIC in Linux:
If you would like to find statistics of your NIC card such as how many bytes it received, how many bytes it sent, how many error occurred while transmitting data or while receiving data, was there any mediumerror, how many unicast packets sent, how many broadcast packets sent and so on. You could find all these information by using following command:ethtool –s eth0Here is the output for you. There are tons of information shown over here. This information is very useful while you troubleshoot network card related issues in Linux.Another method is to use the ifconfig command. This command can give us enough information regarding the NIC statistics. You can find MTU size, MAC address, Sent and receive error by using this command. So go ahead and run the command:ifconfigCheck the screenshot for more information. From the output you can find that current MTU size is 1500. It means, I have not configured Jumbo Frames on my NIC card. Most NIC card has a maximum frame size of 1500 bytes, so most devices use 1500 as their default MTU but we can increase this value if required. From the below provided screenshot, I could also find Sent (Tx) and Receive (Rx) packet numbers, Number of errors, how many packets are dropped etc.How to find NIC information using mii-tool in Linux:
We could also use mii-tool to find the NIC information. Personally I do not trust this tool as this utility is old and may not correctly report the speed of 10GBPS NIC cards. However let me show you the usage of mii-tool. Run the following command:.mii-tool eth0mii-tool -v eth0I run both commands in my linux machine and here is the screenshot. This command can also be used to find the Ethernet Link Status.Today, we have discussed finding Network Card model number, driver, firmware, MAC address, Sent or Receive error
No comments:
Post a Comment