在 Linux 系统中,有几种方法可以查看网络接口的名称:

1. 使用 `ip link` 命令:
$ ip link
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33:
link/ether 00:0c:29:5f:5a:9b brd ff:ff:ff:ff:ff:ff
这个命令会列出所有的网络接口及其基本信息,如接口名称、状态、MAC 地址等。
2. 使用 `ifconfig` 命令:
$ ifconfig
ens33: flags=4163
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe5f:5a9b prefixlen 64 scopeid 0x20
ether 00:0c:29:5f:5a:9b txqueuelen 1000 (Ethernet)
RX packets 14050 bytes 19464713 (18.5 MiB)
TX packets 8594 bytes 721116 (704.2 KiB)
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 224 bytes 18416 (18.0 KiB)
TX packets 224 bytes 18416 (18.0 KiB)
`ifconfig` 命令会列出所有的网络接口及其详细信息,包括接口名称、IP 地址、MAC 地址等。
3. 使用 `lshw` 命令:
$ lshw -class network
*-network
description: Ethernet interface
product: 82540EM Gigabit Ethernet Controller
vendor: Intel Corporation
physical id: 3
bus info: pci@0000:00:03.0
logical name: ens33
version: 02
serial: 00:0c:29:5f:5a:9b
size: 100Mbit/s
capacity: 1Gbit/s
width: 32 bits
clock: 66MHz
capabilities: pm msi cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=7.3.21-k8-NAPI duplex=full firmware=0.13-3 ip=192.168.1.100 link=yes multicast=yes port=twisted pair speed=100Mbit/s
`lshw` 命令会列出系统的硬件信息,包括网络接口的详细信息。
以上三种方法都可以获取网络接口的名称,根据实际需求选择合适的方式即可。

查看详情

查看详情