Results 1 to 3 of 3
Hi,
I need a small shell based program that prints the mac address of physical ethernet adapter from it's firmware. I need this utility for license generation and appliance activation. ...
- 04-06-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 5
physical vs virtual mac address and mac address from NIC's firmware
Hi,
I need a small shell based program that prints the mac address of physical ethernet adapter from it's firmware. I need this utility for license generation and appliance activation. I have tried several example but none of them is flawless, The easiest method I have found is to parse the output of "ifconfig" command but it has also some drawbacks.
More description:
1. Firstly program should differentiate between physical and virtual adapters. Physical means installed on board(wired or wireless) or installed additionally. Virtual adapters are those created by VPN or created by virtualization apps such as VirtualBox/VMWare etc. I am not interested in virtual ones.
2. In case of more them one physical adapters(wired and wireless), it should print the mac address and description(name & vendor) of both/all adapters.
3. If media is disconnected then also it should be able to read the mac address and description(name, vendor) of card.
4. This one is bit complex. I know that 'ethtool' can show you the universal mac address but it's limited to use only 2 types of drivers and won't work in all cases.
I would appreciate if someone point me out the right direction. I am new to Linux world.
Thanks
Prashant
- 05-05-2011 #2Just Joined!
- Join Date
- Jan 2010
- Posts
- 27
This (lets call it original) MAC address is read from the firmware/hardware when linux kernel driver (compiled in monolithic way or as module, LKML) for the adapter is initialized.
So if you are afraid of getting spoofed MAC address, you should repeat the driver init-sequence just right before you read MAC.
That means either unloading+inserting appropriate module or (when driver is inside monolith) rebooting the whole kernel and putting your check at the very start of inittab or like.
Advanced option may be writing custom LKML which (once loaded) would walk every physical adapter, put one down, rerun init-sequence for every needed pair adapter-driver (be it monolithic or modular) and then would put it up.
Such code may even be integrated directly into kernel as some IOCTL (after testing it as LKML). Such code may even exist already, but I haven't heard of it.
OTOH, these 3 ways sound too intrusive -- they would require network downtime. Without shutting ifaces down, any possible MAC address change (though rare one) would introduce malfunctioning network.
Thus I guess Linux Netdev guys decided to implement ETHTOOL_GPERMADDR for all existing drivers (little by little) instead:
https://patchwork.kernel.org/patch/52008/
But that's my speculation : ) , not a fact.
Do you mean using it's option "--show-permaddr" ?I know that 'ethtool' can show you the universal mac address but it's limited to use only 2 types of drivers and won't work in all cases.
At least RH kernels seem to support this for quite large amount of adapter models for 9 years already:
Announcements of Fedora Core changes and events
On what kernels should your licensing software work? Have you any legal rights to require only newest kernels?
- 05-06-2011 #3Just Joined!
- Join Date
- Apr 2011
- Posts
- 5
Hi saulius2,
Many thanks for such a detailed answer.
My app is requirements are:
Kernel :: 2.6.24-27 or Higher
GCC :: 4.2.4 or Higher
GLIBC :: 2.7 or Higher
My development system id Ubuntu 8.04 hardy
I did some testing of this tool on ubuntu, fedora and I getting permanent address using ethtool API. Although app has been tested on more distributions. This tool is going to be the heart of licensing system so it has to work on as much distributions as possible. Imaging a situation where app is working fine on distro X but tool is not able to fetch perma addr, then this is going to be a show stopper.
As I am new to linux, I am planning to integrate a secondary method in this tool to get current address in case tool is able to fetch perma addr just for safer side but this purely based on the fact that I have to support as many distros as possible.
I googled about your suggestions but to be honest, this is beyond my skills sets on network programming and kernel related stuff. You have also mentioned the cons of using these techniques thus it would be safer to use something which is simpler. What do you say?
BTW, when you say 2 types of drivers, is that mean ethernet and wireless?I know that 'ethtool' can show you the universal mac address but it's limited to use only 2 types of drivers and won't work in all cases.
Cheers
Prashant


Reply With Quote
