我如何找出我的不同(虚拟)网络接口是什么,以及什么服务创建了它们?

我如何找出我的不同(虚拟)网络接口是什么,以及什么服务创建了它们?

我想“清理”网络接口。如果我运行ip addr,我会得到以下列表(参见文章底部)。

#2 和 #3 是我的 2 个物理 NIC(#2 当前已拔出),并且我在 netplan 配置中自己创建了 #5 和 #6。#10(docker0)对我来说也有意义。

然而,其他大多数对我来说都是一个谜(例如,所有虚拟以太网)。

有没有办法查看哪个服务创建了它们,以及它们是否正在使用中?本质上,我是否可以安全地删除它们。sudo ip link delete INTERFACE在不了解它们更多信息的情况下,我有点犹豫是否要开始。

输出brctl show

bridge name bridge id       STP enabled interfaces
br-870fc0691e90     8000.0242670e67e3   no      veth3c7caf7
br-c43d0708a05e     8000.0242db5a4d9f   no      veth447ed70
br-f32d9d8a97b7     8000.024225ae37b1   no      veth0174902
                            veth0b62e6b
                            veth3965e56
                            veth52593cf
                            veth589e856
                            veth6acd0d3
                            veth74d8b27
                            vethb06ec0c
                            vethb71f188
                            vethcd3e855
                            vethe5a1aae
                            vetheb8ac27
                            vethff7a086
br0     8000.329db9331ed5   yes     eno1
                            vnet0
docker0     8000.0242c78c0ee3   no
virbr0      8000.5254002797d6   yes

输出ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
    link/ether 00:21:5e:c6:43:04 brd ff:ff:ff:ff:ff:ff
    altname enp11s0f0
3: eno2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:21:5e:c6:43:06 brd ff:ff:ff:ff:ff:ff
    altname enp11s0f1
4: enx02215eca3baf: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 02:21:5e:ca:3b:af brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 32:9d:b9:33:1e:d5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.30.21/24 metric 100 brd 10.0.30.255 scope global dynamic br0
       valid_lft 76838sec preferred_lft 76838sec
    inet6 fe80::309d:b9ff:fe33:1ed5/64 scope link
       valid_lft forever preferred_lft forever
6: vlan40@eno2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 00:21:5e:c6:43:06 brd ff:ff:ff:ff:ff:ff
7: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:27:97:d6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
8: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:26:69:40 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe26:6940/64 scope link
       valid_lft forever preferred_lft forever
9: br-870fc0691e90: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:67:0e:67:e3 brd ff:ff:ff:ff:ff:ff
    inet 172.20.0.1/16 brd 172.20.255.255 scope global br-870fc0691e90
       valid_lft forever preferred_lft forever
    inet6 fe80::42:67ff:fe0e:67e3/64 scope link
       valid_lft forever preferred_lft forever
10: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:c7:8c:0e:e3 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
11: br-c43d0708a05e: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:db:5a:4d:9f brd ff:ff:ff:ff:ff:ff
    inet 172.11.0.1/24 brd 172.11.0.255 scope global br-c43d0708a05e
       valid_lft forever preferred_lft forever
    inet6 fe80::42:dbff:fe5a:4d9f/64 scope link
       valid_lft forever preferred_lft forever
12: br-f32d9d8a97b7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:25:ae:37:b1 brd ff:ff:ff:ff:ff:ff
    inet 172.21.0.1/16 brd 172.21.255.255 scope global br-f32d9d8a97b7
       valid_lft forever preferred_lft forever
    inet6 fe80::42:25ff:feae:37b1/64 scope link
       valid_lft forever preferred_lft forever
14: vethb06ec0c@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 72:08:f7:98:75:d2 brd ff:ff:ff:ff:ff:ff link-netnsid 4
    inet6 fe80::7008:f7ff:fe98:75d2/64 scope link
       valid_lft forever preferred_lft forever
16: veth3c7caf7@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-870fc0691e90 state UP group default
    link/ether 2a:fb:a7:23:ef:a5 brd ff:ff:ff:ff:ff:ff link-netnsid 2
    inet6 fe80::28fb:a7ff:fe23:efa5/64 scope link
       valid_lft forever preferred_lft forever
18: veth447ed70@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-c43d0708a05e state UP group default
    link/ether ca:3a:29:a8:ba:bd brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::c83a:29ff:fea8:babd/64 scope link
       valid_lft forever preferred_lft forever
20: vethe5a1aae@if19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether a2:c1:db:43:c0:bd brd ff:ff:ff:ff:ff:ff link-netnsid 5
    inet6 fe80::a0c1:dbff:fe43:c0bd/64 scope link
       valid_lft forever preferred_lft forever
22: veth52593cf@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether ca:67:51:81:95:c5 brd ff:ff:ff:ff:ff:ff link-netnsid 3
    inet6 fe80::c867:51ff:fe81:95c5/64 scope link
       valid_lft forever preferred_lft forever
24: veth74d8b27@if23: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 92:fa:e9:b0:13:d7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::90fa:e9ff:feb0:13d7/64 scope link
       valid_lft forever preferred_lft forever
26: vethb71f188@if25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 0e:0e:da:df:15:98 brd ff:ff:ff:ff:ff:ff link-netnsid 6
    inet6 fe80::c0e:daff:fedf:1598/64 scope link
       valid_lft forever preferred_lft forever
28: veth0174902@if27: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 7e:e0:b1:76:d9:47 brd ff:ff:ff:ff:ff:ff link-netnsid 7
    inet6 fe80::7ce0:b1ff:fe76:d947/64 scope link
       valid_lft forever preferred_lft forever
30: veth3965e56@if29: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether b2:ca:05:df:1c:af brd ff:ff:ff:ff:ff:ff link-netnsid 9
    inet6 fe80::b0ca:5ff:fedf:1caf/64 scope link
       valid_lft forever preferred_lft forever
34: vethff7a086@if33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 6a:97:34:da:5d:2f brd ff:ff:ff:ff:ff:ff link-netnsid 10
    inet6 fe80::6897:34ff:feda:5d2f/64 scope link
       valid_lft forever preferred_lft forever
36: vetheb8ac27@if35: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether f2:d3:47:65:5c:b0 brd ff:ff:ff:ff:ff:ff link-netnsid 11
    inet6 fe80::f0d3:47ff:fe65:5cb0/64 scope link
       valid_lft forever preferred_lft forever
38: veth0b62e6b@if37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 4e:05:42:a2:62:3d brd ff:ff:ff:ff:ff:ff link-netnsid 12
    inet6 fe80::4c05:42ff:fea2:623d/64 scope link
       valid_lft forever preferred_lft forever
40: veth6acd0d3@if39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether b2:7e:7c:8c:85:b3 brd ff:ff:ff:ff:ff:ff link-netnsid 13
    inet6 fe80::b07e:7cff:fe8c:85b3/64 scope link
       valid_lft forever preferred_lft forever
42: veth589e856@if41: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether 0a:4e:7c:29:ba:3a brd ff:ff:ff:ff:ff:ff link-netnsid 14
    inet6 fe80::84e:7cff:fe29:ba3a/64 scope link
       valid_lft forever preferred_lft forever
72: vethcd3e855@if71: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-f32d9d8a97b7 state UP group default
    link/ether f6:24:c0:75:e6:24 brd ff:ff:ff:ff:ff:ff link-netnsid 8
    inet6 fe80::f424:c0ff:fe75:e624/64 scope link
       valid_lft forever preferred_lft forever

这是 Ubuntu 服务器 LTS 22.04。

答案1

当您使用 docker 或容器甚至虚拟机时,每个容器或系统都必须有一个连接到网桥的虚拟以太网设备。

您显示您使用 Docker,这也可能是您运行网桥的原因,因为您正在使用docker-compose。每个容器在主机系统上都有自己的veth映射到容器网络。您运行的 Docker 容器越多,veth产生的设备就越多。

如果您执行docker-compose down并关闭所有 Docker 容器,veth设备数量将急剧减少。


请注意,enx设备是通过 MAC 地址识别的设备。

根据可预测网络接口命名系统 (https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/),你可以很容易地发现这一点:

  1. 包含固件/BIOS 为板载设备提供的索引号的名称(例如:eno1)
  2. 包含固件/BIOS 的名称提供的 PCI Express 热插拔插槽索引号(例如:ens1)
  3. 包含硬件连接器的物理/地理位置的名称(例如:enp2s0)
  4. 包含接口 MAC 地址的名称(例如:enx78e7d1ea46da)
  5. 经典、不可预测的内核原生 ethX 命名(例如:eth0)

(重点是我的)

您的enx设备是一个物理接口,其 MAC 地址为 02:21:5E:CA:3B:AF,并且安装在系统的某个地方,无论是安装在系统内部还是通过 USB 加密狗安装在外部,都是无法分辨的。

相关内容