Live Chat Software by Kayako
Knowledgebase: Ubuntu
Ubuntu Linux Display List of Ethernet Adapter
Posted by Thang Le Toan on 03 April 2016 10:24 AM

How do I display a list of all installed Ethernet adapters on Ubuntu Linux server using bash command line option?

You can use the following commands to list Ethernet adapters under Ubuntu Linux:

  1. lspci command – List all PCI device including Ethernet cards (NICs).
  2. ip command – Display or manipulate routing, devices, policy routing and tunnels on Linux operating systems.
  3. ifconfig command – Display or configure a network interface on Linux or Unix like operating systems.

Examples

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command to list total number of Ethernet devices on Linux:
$ lspci
$ lspci | less
$ lspci | grep -i eth

Sample outputs:

09:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5761e Gigabit Ethernet PCIe (rev 10)

Above output indicates that my system has one Gigabit Ethernet controller installed using PCIe interface. It also displayed name of the manufacture. To list actual ip address assigned to the interface, enter:
$ ifconfig
$ ifconfig eth0

OR
$ /sbin/ifconfig
$ /sbin/ifconfig eth0

Sample outputs:

eth0      Link encap:Ethernet  HWaddr b8:ac:6f:65:31:e5
          inet addr:192.168.2.11  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1938092 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2436052 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:771061372 (771.0 MB)  TX bytes:2118333235 (2.1 GB)
          Interrupt:17

You can use ip command as follows to list all NICs:
$ ip link
OR
$ ip link

Alternatively, you can pass the -a (all) and -s (stats) option to the ifconfig command to

display Ethernet cards including network alias on Linux OS:
$ ifconfig -s -a

The last command “ifconfig -s -a” is equivalent to the “netstat -i” command:
$ netstat -i
Sample outputs:

Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0  46686747      0      0 0      23678718      0      0      0 BMRU
eth1       1500 0   5951068      0      0 0       2412620      0      0      0 BMRU
lo        16436 0         1      0      0 0             1      0      0      0 LRU

Display or change Ethernet card settings

You can use the ethtool command for querying settings of an ethernet device and changing them such as speed, duplex settings and much more:
$ ethtool eth0
Sample outputs:

Settings for eth0:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Link partner advertised link modes:  Not reported
	Link partner advertised pause frame use: No
	Link partner advertised auto-negotiation: No
	Speed: 100Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: Unknown
	Supports Wake-on: g
	Wake-on: g
	Current message level: 0x000000ff (255)
	Link detected: yes

-------------------

sudo lshw -c network

------------------

Maybe your interface card has changed from eth0 to eth1. This has happened often with me. To check, type this command:

sudo ls /sys/class/net

--------------------
Nếu card mạng khi dùng lệnh ip link lại báo card mạng đang ở tình trạng state down mode thì cần dùng lệnh sau để bật card mạng lên:
sudo ifdown eth0
sudo ifup eth0
(lưu ý: eth0 là tên card mạng ubuntu ngầm định tạo ra, bạn cần dùng lệnh sudo ls /sys/class/net để kiểm tra đúng tên card mạng.
 

 

(0 vote(s))
Helpful
Not helpful

Comments (1)
Ha lan
03 April 2016 01:16 PM
nano /etc/network/interfaces

iface eth0 inet static
address 192.168.1.15 ------> Your Ip Address
netmask 255.255.255.0 ------> Netmask
gateway 192.168.1.254 -------> Gateway
broadcast 192.168.0.255
dns-nameservers 192.168.1.3 -----> Dns server
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Kayako