Linux设备上的永久或半永久ID

用来唯一地识别机器
1. 网卡MAC
MAC地址本来是永久地保存在 网卡的EEPROM里的,通过驱动程序读取出来,该地址放在 Link层用来识别自身。但是驱动程序可以用
自己配置的MAC地址,而不是从网卡芯片读取的
缺点:
1) 有些机器上没有网卡
2) 通ifconfig命令 可以修改地址
命令:

ifconfig eth0
ip link show eth0
cat /sys/class/net/eth0/address 

2. 存储芯片ID
/sys/block/mmcblk2/device/cid

Name Field Linux attribute* Description
Manufacturer ID MID manfid Assigned by SD-3C, LLC.
OEM/Application ID OID oemid Identifies the card OEM and/or the card contents. Assigned by SD-3C, LLC.
Product Name PNM name 5 characters long (ASCII)
Product Revision PRV hwrev, fwrev Two binary coded decimal (BCD) digits. Each is four bits. The PRV is in the form x.y. The PRV can also be found by using the hwrev and fwrev, where x=hwrev and y=fwrev
Serial Number PSN serial This 32 bit field is intended to be read as an unsigned integer
Manufacture Date Code MDT date Manufacture date is stored in the form yym (offset from 2000)
CRC7 checksum CRC 7 bit code used for checking errors in the card register

这个比较难修改,除非修改内核

3. 存储分区ID
文件系统分区时生成的ID, 可以通过分区程序等进行修改

blkid
fdisk -l /dev/mmcblk2

PTUUID
PARTUUID
UUID

4. 安装系统时生成的machine-id
/var/lib/dbus/machine-id
/etc/machine-id
缺点: 非常容易被root权限用户修改

5. 内核随机UUID

/proc/sys/kernel/random/uuid
/proc/sys/kernel/random/boot_id

每次重启会变

6. USB设备的序列号
存在USB设备的EEPROM中
/sys/bus/usb/devices/*/serial

cat  sys/bus/usb/devices/1-4.3/serial

缺点:
1) USB设备是可以热插拔的
2) 有些设备没有序列号,另外有些设备的序列号是伪造的,同一批设备都是一样的

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注