LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2007, 12:56 PM   #1
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Rep: Reputation: 15
How to get serial numbers?


No This is not a warez/crackz/serialz question .

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?


Thanks a lot!
 
Old 07-19-2007, 01:03 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Take a look at dmidecode. For example, as root:

dmidecode > dmi.txt
 
Old 07-19-2007, 01:18 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 07-19-2007, 01:57 PM   #4
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Quote:
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.
 
Old 07-19-2007, 02:10 PM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Quote:
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).
 
Old 07-19-2007, 02:12 PM   #6
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
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
 
Old 07-19-2007, 02:33 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by macemoneta
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.
 
Old 07-19-2007, 02:34 PM   #8
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Original Poster
Rep: Reputation: 15
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?


Thanks!
 
Old 07-19-2007, 03:04 PM   #9
brianmcgee
Member
 
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399

Rep: Reputation: 40
If you need to track also hardware modifications maybe you should have a look at how system profiles for the Red Hat Network are generated:

At first, following information is gathered from the system:

Red Hat Linux version, Hostname, IP address, CPU model, CPU speed, Amount of RAM, PCI devices, Disk sizes.

Then a hash value is calculated from that information to generate a unique serial.

But maybe you can also use the ssh-host-keys that were generated during first boot of your system.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File serial numbers exvor Programming 4 07-20-2007 04:57 PM
RH doesn't detect my Serial modem connected to a PCI Serial card ricky_ds Linux - Hardware 1 08-17-2006 02:37 PM
sequence of numbers, how to extract which numbers are missing jonlake Programming 13 06-26-2006 03:28 AM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM
zoom external serial with usb to serial adapter foustware Linux - Hardware 1 12-07-2003 02:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration