What's MAC address ? What is a unique ID for a PC? [duplicate]
I have a PC with dual cores, it has two MAC addresses : 00-1D.... & 00-21..... Are these IDs for the two cores ? If I want to get hold of a unique ID for this 开发者_StackOverflow社区PC, how to get it with a Java call ? Maybe there is something in Java like "System.getId()" ?
Frank
MAC stands for Media Access Control. The MAC address usually represents a unique id for your network adapter(s). You must have two network adapters in your pc (LAN, WLAN?).
Have a look here this describes how to get a unique system identifier in JAVA: How to get a unique computer identifier in Java (like disk id or motherboard id)
And .NET: http://sowkot.blogspot.com/2008/08/generating-unique-keyfinger-print-for.html
Michael
(at the time I answered this, it was already answered what exactly a MAC address is, so I am not going to repeat it, so I just answered an unanswered question, the downvote makes no sense)
If I want to get hold of a unique ID for this PC, how to get it with a Java call
You should not bind unique identifiers to hardware, but to enduser. Hardware can be changed, the enduser not. So, ask enduser to fill some registration form (or provide a dongle, as answered by Pascal).
A MAC address is a number that identifies a Network Card Interface. You can't use that to identify a particular machine in a reliable way (a user can change his NIC, a power user can even change the MAC address dynamically).
Maybe you could use a software-protection dongle (looks like there are Java solutions). But note that even this solution doesn't solve the whole trusted client problem.
From Google :: Media Access Control address (MAC address) is a unique identifier assigned to most network adapters or network interface.
The ID's are for network interfaces. They are also not immutable, and not always unique because of this.
Look into java.net.NetworkInterface and java.net.InetAddress for methods of fetching MAC information.
The MAC is a media access control identification, the first two bytes represent the country and the 4 bytes represent the Manufacturer. No two adapters are the same, unfortunately, due to the advent of modern mass-production of NIC's, the MAC can be easily changed dynamically. Back in the old days, the NIC's consisted of DIP Switches (Dual Inline Pins) which allowed you to change the setting of the NIC such as IRQ, jumper address and so on...
They have nothing to do with processor cores, that's a separate hardware thing.
There is no portable way of getting the MAC address, theoretically you could use the ifconfig
command for *nix/Linux variants. For the Windows environment you could use the ipconfig
command, using either, you could search for the relevant adapter in question... as this example under Linux would show...my network adapter is called 'eth0'...
ifconfig eth0 | grep HWaddr | cut -d\t -f4
would return:
HWaddr 00:02:03:04:05:06
精彩评论