Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What unique hardware signatures can you get from, for example, a FreeBSD system?

I am right now using the ethernet mac address (getifaddrs(3)) but as we all know this can easily be changed with ifconfig. So what else is there? Anything in sysctl?

I am using C to do this so if I can just find out where to look I will most likely find a way to get it.

share|improve this question
4  
What are you trying to accomplish by uniquely identifying the hardware? –  cjm Apr 27 '11 at 18:43
2  
If you are using this for software licensing, be aware that binding to a hardware id might annoy your users, e.g. if it changes just because they had to replace a faulty network card or motherboard. –  Mikel Apr 27 '11 at 23:33
add comment

2 Answers

up vote 0 down vote accepted

The original way to do this was using hostid.

The man page notes that it's:

a 32-bit identifier... normally a DARPA Internet address for the local machine

i.e. it's the machine's IP address in hex.

This means it won't change just because somebody had to replace a broken network card.
It also means it's not guaranteed to be unique, for example if networking isn't configured, or the machine uses a private IP address.

In fact, it might not even be set, and can be changed by the superuser using sethostid or sysctl.

I can't find anything of much use in the sysctl -a output besides kern.hostid.
On OpenBSD there is hw.uuid, but that's not available on FreeBSD.

After that, there are several commands that might help, including:

Most of these work by calling ioctl on the relevant device.

If you need to do it in C, check out the source code for the above commands for more details.

You could also look at libvolume_id or libblkid to get the id of the root file system. Because they are ports, obviously neither of those are part of the base system, but one or the other might get installed as part of a standard desktop installation.

See also: Getting a unique id from a Unix-like system.

share|improve this answer
1  
At least since 7.2, if not before, FreeBSD has kern.hostid as a 32-bit unique identifier and kern.hostuuid as a 128-bit unique identifier. hostid is really to small for a good unique identifier. –  penguin359 Apr 28 '11 at 10:31
    
@penguin359: Ah. Thanks for that. Didn't see it in the man page. –  Mikel Apr 28 '11 at 11:02
    
I didn't either, I just did sysctl -a | host –  penguin359 Apr 28 '11 at 20:44
    
@penguin359 really good stuff, thank you very much! I will upvote Mikel's answer because it contains this thread. Thank you @Mikel. When I read draeth's answer it hit me that I could use hardware ID's like PCI DEVID and such to assemble a hardware signature. –  nocturnal Apr 29 '11 at 5:23
add comment

Linux has a tool called 'dmidecode' that can pull S/Ns from a lot of the hardware present, including memory modules (if provided via DMI), disks, CPUs etc. This could be of help - but realize many of these can change without actually changing machine!

I do not know for sure if FreeBSD has the same tool, but I'm positive they have something to fill that niche.

share|improve this answer
    
${PORTSDIR}/sysutils/dmidecode –  Mel May 20 '11 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.