我有一个全新安装的 Ubuntu 12.04 Server。我想找到网络连接的 UUID。如何找到它?
ifconfig -a 没有列出它:
eth0 Link encap:Ethernet HWaddr 00:1e:67:6a:78:a8
inet addr:192.168.50.18 Bcast:192.168.50.255 Mask:255.255.255.0
inet6 addr: fe80::21e:67ff:fe6a:78a8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:572287 errors:0 dropped:0 overruns:0 frame:0
TX packets:70324 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:222908307 (222.9 MB) TX bytes:7982096 (7.9 MB)
Interrupt:16 Memory:c2300000-c2320000
nmcli 未安装(因为这是 Ubuntu 服务器):
user@server# nmcli
The program 'nmcli' is currently not installed. You can install it by typing:
apt-get install network-manager
从桌面安装,我可以执行以下操作:
user@desktop# nmcli c list
NAME UUID TYPE TIMESTAMP-REAL
Wired connection 2 d00a6778-80d6-4812-ad54-041de24e47fe 802-3-ethernet Mon 16 Dec 2013 12:20:09 EST
Wired connection 1 4fb95570-1922-495a-b498-846b7a6b0655 802-3-ethernet Tue 17 Dec 2013 11:20:03 EST
miwifi f3182ff5-81c2-44c4-9c4b-d3a1f0a550e9 802-11-wireless never
如果未安装网络管理器,我该如何找到它?当然我不知道有安装网络管理器?
答案1
UUID 是网络管理器的一部分。如果您没有安装并启用网络管理器,那么您就没有这个 UUID。
它与 OpenStack Quantum UUID 完全无关。
因此,您找不到 UUID。它不存在。
答案2
UUID 是使用 util-linux 包中的工具 uuidgen 生成的,该工具会生成随机数。uuidgen 还用于在创建分区时生成分区的 UUID,并在您请求 tune2fs 为分区创建新的 UUID 时由 tune2fs 调用。
当您在配置文件中更改 UUID 时,预计会有几种工具将设备识别为新设备。
答案3
网卡的 UUID 是运行时的事情,由 NetworkManager 完成。在“/dev”中找到网卡的最接近的方法是查看“/proc”,你会发现其中没有任何地方提到 UUID:
[root@kubeadm-test ~]# ls -l /sys/class/net/
total 0
lrwxrwxrwx. 1 root root 0 Jan 22 08:35 enp1s0 -> ../../devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio0/net/enp1s0
lrwxrwxrwx. 1 root root 0 Jan 22 08:35 lo -> ../../devices/virtual/net/lo
[root@kubeadm-test ~]#
[root@kubeadm-test ~]# nmcli connection
NAME UUID TYPE DEVICE
enp1s0 7be41c51-becf-3963-bd4f-1562dd489fb3 ethernet enp1s0
[root@kubeadm-test ~]#
“nmcli conn show enp1s0”命令显示 UUID 而不是 HW 地址。
[root@kubeadm-test ~]# nmcli conn show enp1s0
connection.id: enp1s0
connection.uuid: 7be41c51-becf-3963-bd4f-1562dd489fb3
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: enp1s0
connection.autoconnect: yes
connection.autoconnect-priority: -999
connection.autoconnect-retries: -1 (default)
connection.multi-connect: 0 (default)
connection.auth-retries: -1
connection.timestamp: 1611301844
connection.read-only: no
connection.permissions: --
connection.zone: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
connection.secondaries: --
connection.gateway-ping-timeout: 0
connection.metered: unknown
connection.lldp: default
connection.mdns: -1 (default)
connection.llmnr: -1 (default)
connection.wait-device-timeout: -1
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: no
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.generate-mac-address-mask:--
802-3-ethernet.mac-address-blacklist: --
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels: --
“nmcli device show enp1s0”命令显示 HWADDR 而不是 UUID。
[root@kubeadm-test ~]# nmcli device show enp1s0
GENERAL.DEVICE: enp1s0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 52:54:00:58:A4:20
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: enp1s0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 192.168.122.217/24
IP4.GATEWAY: 192.168.122.1
IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.122.1, mt = 100
IP4.ROUTE[2]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 100
IP4.DNS[1]: 192.168.122.1
IP6.ADDRESS[1]: fe80::5054:ff:fe58:a420/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[2]: dst = ff00::/8, nh = ::, mt = 256, table=255
[root@kubeadm-test ~]#