我试图知道一种方法来仅显示我在任何正在运行的虚拟机上拥有的每个网卡的 MAC 地址:
到目前为止我有这个:
ipcopv2
-----------------------------------------------
Groups: /Infraestructura
State: powered off (since 2018-03-16T13:30:56.389000000)
NIC 1: MAC: 080027D40320, Attachment: Bridged Interface 'eth1.15', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 2: MAC: 080027660656, Attachment: Bridged Interface 'eth1', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3: MAC: 0800270D3D9E, Attachment: Bridged Interface 'eth0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
Capture screens: 0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
我想要这个:
ipcopv2
-----------------------------------------------
Groups: /Infraestructura
State: powered off (since 2018-03-16T13:30:56.389000000)
NIC 1: MAC: 080027D40320, Attachment: Bridged Interface 'eth1.15', Cable connected: on
NIC 2: MAC: 080027660656, Attachment: Bridged Interface 'eth1', Cable connected: on
NIC 3: MAC: 0800270D3D9E, Attachment: Bridged Interface 'eth0', Cable connected: on
Capture screens: 0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
如何做到这一点?我想了解如何读取信息并仅使用 bash 显示该部分。
答案1
这似乎可以解决问题:
$ ip link | awk '/link/ { print $2 }'
00:00:00:00:00:00
00:20:78:1c:xx:yy
00:1d:92:67:xx:yy