当我向我的Ubuntu机器添加新的NIC卡时,引擎盖后面会发生什么。 哪个程序/模块负责将设备的硬件地址映射到名称(eth0 / eth1)。这个映射(HWaddress1-eth0,HWaddress2-eth1)实际存储在哪里。?
答案 0 :(得分:2)
据我所知,内核本身将命名nics,具体取决于它们连接到总线的顺序。此行为与SCSI / SATA命名非常相似。
看一下
的输出lspci
你应该在那里找到相应的网卡。第一列,例如0000:00:03.0
包含以下信息:
0000 : PCI domain (each domain can contain up to 256 PCI buses)
00 : the bus number the device is attached to
03 : the device number
.0 : PCI device function
(来源:http://prefetch.net/articles/linuxpci.html)
在/ sys / bus / pci(_express)/ devices /下,您将找到与lspci输出匹配的链接。当您输入网卡的文件夹时,有很多文件和文件夹。
你可以做一个发现和grep
cd /sys/bus/.../devices/0000:00:03.0/
someuser@somemachine:/sys/bus/pci/devices/0000:00:03.0$ find -type f -exec grep 'ethX' /dev/null {} \; 2>/dev/null
其中ethX是您获取输出的设备名称,如
./virtio0/net/ethX/uevent:INTERFACE=eth0
(在我的情况下是带有virtio设备的虚拟机)
由于此信息来自正在运行的内核,我打赌你也会在那里找到硬件地址。
快乐的嬉戏!