ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am searching how I can uniquely identify a computer. I want to use it in a program I'm making to see which computer is talking to me (once send a hash of those, and then I know who it is).
What I was thinking of were the following items:
- CPU type, speed + CPUID (if present).
- Memory type, serials (if present)
- Harddrive type + serials (if present).
- Mainboard type + serials (if present).
But does anyone know how to get those?
At windows I can find out my cputype(--serial) + memory type(++serial)
At linux I can find out my cputype(--serial) + harddrives
Where could i start looking? Is there some program which implements those features already?
If your requirement is to communicate these numbers using ethernet, then the ethernet MAC should, itself, be unique enough. For TCP/IP based communications, each host should be caching these in its own arp table. On a linux host, you can dump this table using the arp command.
Other than recent Intel CPUs having a CPU-ID, I don't think there is any standard way of uniquely identifying a host. The ethernet MAC was contrived to solve this problem, although there is no guarantee that any given host has one & only one such number, or even that they are absolutely unique (disreputable vendors have produced ethernet hardware with non-unique MACs).
--- rod.
Other than recent Intel CPUs having a CPU-ID, I don't think there is any standard way of uniquely identifying a host. The ethernet MAC was contrived to solve this problem, although there is no guarantee that any given host has one & only one such number, or even that they are absolutely unique (disreputable vendors have produced ethernet hardware with non-unique MACs).
Also keep in mind that if you are in a hostile environment the MAC can be trivially spoofed.
The ethernet MAC was contrived to solve this problem
Uh, no. The Ethernet MAC is a layer 2 identifier for packets, used to control packet routing. It's mapped to/from an IP address by the ARP protocol. It has nothing to do with identifying a PC, and in fact it exists only on the local LAN segment (so it doesn't even need to be unique, except on that LAN segment).
Also keep in mind that if you are in a hostile environment the MAC can be trivially spoofed.
And if you based the identification on some numbers about certain pieces of hardware, one could easily switch some part of hardware (for example ethernet cards don't pay much) and the identification would change.
There's no sure way to identify a computer, and I don't think there should be. It's like implanting a chip into your head to identify you. Then somebody figures out how to cheat, and suddenly you've done something you didn't
Uh, no. The Ethernet MAC is a layer 2 identifier for packets, used to control packet routing. It's mapped to/from an IP address by the ARP protocol. It has nothing to do with identifying a PC, and in fact it exists only on the local LAN segment (so it doesn't even need to be unique, except on that LAN segment).
You misunderstood my meaning. For ethernet to work, a destination host/interface must be uniquely identified, since that is the only way an ethernet interface knows which nonbroadcast packets are destined for it. The MAC serves this purpose. MACs exist on all ethernet LANs, by definition. I did not intend to say that the MAC was intended to serve any higher purpose than to identify source & desination hosts on a LAN. According to the IEEE 802.3, MACs are supposed to be unique, although you are correct that in practice, this need only apply to interfaces on a single LAN, roughly speaking (ethernet bridges pass MACs between segments).
--- rod.
Thank you for your answers so far! the dmidecode looks promising, although it doens't give me the same things as cpu-z under windows (like it cannot identify my memory). Maybe cpu-z is collecting magic numbers and then recognizing these to say which memory is what and stuff like that.
Oh, the environment is absolutely not hostile at all... It's just that I once send a huge batch from the client -> server with all kinds of data and then send a hash back, which uniquely defines that machine. In all later communications this hash is used (until some hardware components change). And that's exactly the issue ;-). I HAVE to know it when hardware changes. So basically that's a change of mobo, cpu, drives and memory. The rest is of less importance.
Is there another tool than dmidecode which also provides me with similar information? (I checked out Todd Allen's cpuid & also browsed through the /proc dir), but maybe you guys (and mayhaps you girls) have another bright idea?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.